Skip to content

Commit

Permalink
~~Fix integration test failures by handling a NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
Naduni Pamudika committed Jan 3, 2025
1 parent f78fbae commit c4d9496
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5055,14 +5055,16 @@ public static Set<String> extractVisibleEnvironmentsForUser(List<Environment> en
String[] permittedRoles = environment.getVisibilityRoles();
if (permittedRoles != null && permittedRoles[0].equals("all")) {
environmentStringSet.add(environment.toString());
} else {
} else if (permittedRoles != null) {
for (String role : userRoles) {
for (String permission : permittedRoles) {
if (role.equals(permission)) {
environmentStringSet.add(environment.toString());
}
}
}
} else {
environmentStringSet.add(environment.toString());
}
}
}
Expand All @@ -5076,16 +5078,18 @@ public static Map<String, Environment> extractVisibleEnvironmentsForUser(String
Map<String, Environment> environmentsMap = getEnvironments(organization);
for (Environment environment : environmentsMap.values()) {
String[] permittedRoles = environment.getVisibilityRoles();
if (permittedRoles[0].equals("all")) {
if (permittedRoles != null && permittedRoles[0].equals("all")) {
returnEnvironments.put(environment.getName(), environment);
} else {
} else if (permittedRoles != null) {
for (String role : userRoles) {
for (String permission : permittedRoles) {
if (role.equals(permission)) {
returnEnvironments.put(environment.getName(), environment);
}
}
}
} else {
returnEnvironments.put(environment.getName(), environment);
}
}
return returnEnvironments;
Expand Down

0 comments on commit c4d9496

Please sign in to comment.