Address remarks

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
pull/619/head
Anatolii Bazko 2023-12-04 13:17:28 +01:00
parent a00f92d9af
commit 3bdf76df09
3 changed files with 7 additions and 7 deletions

View File

@ -35,14 +35,14 @@ public class KubernetesAuthorizationCheckerImpl implements AuthorizationChecker
}
public boolean isAuthorized(String username) {
return isAllowedUser(username) && !isDisabledUser(username);
return isAllowedUser(username) && !isDeniedUser(username);
}
private boolean isAllowedUser(String username) {
return allowUsers.isEmpty() || allowUsers.contains(username);
}
private boolean isDisabledUser(String username) {
private boolean isDeniedUser(String username) {
return !denyUsers.isEmpty() && denyUsers.contains(username);
}
}

View File

@ -52,7 +52,7 @@ public class OpenShiftAuthorizationCheckerImpl implements AuthorizationChecker {
public boolean isAuthorized(String username) throws InfrastructureException {
return isAllowedUser(cheServerKubernetesClientFactory.create(), username)
&& !isDisabledUser(cheServerKubernetesClientFactory.create(), username);
&& !isDeniedUser(cheServerKubernetesClientFactory.create(), username);
}
private boolean isAllowedUser(KubernetesClient client, String username) {
@ -75,7 +75,7 @@ public class OpenShiftAuthorizationCheckerImpl implements AuthorizationChecker {
return false;
}
private boolean isDisabledUser(KubernetesClient client, String username) {
private boolean isDeniedUser(KubernetesClient client, String username) {
// All users from all groups are allowed by default
if (denyUsers.isEmpty() && denyGroups.isEmpty()) {
return false;

View File

@ -50,14 +50,14 @@ public class OpenShiftAuthorizationCheckerTest {
List<Group> groups,
String allowedUsers,
String allowedGroups,
String disabledUsers,
String disabledGroups,
String deniedUsers,
String deniedGroups,
boolean expectedIsAuthorized)
throws InfrastructureException {
// give
OpenShiftAuthorizationCheckerImpl authorizationChecker =
new OpenShiftAuthorizationCheckerImpl(
allowedUsers, allowedGroups, disabledUsers, disabledGroups, clientFactory);
allowedUsers, allowedGroups, deniedUsers, deniedGroups, clientFactory);
groups.forEach(group -> client.resources(Group.class).create(group));
// when