Skip to content

Commit 7f9e8ab

Browse files
author
Nicole Schmidt
committed
Fix conflicts on checkAccess
1 parent 1e1ceed commit 7f9e8ab

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

plugins/acl/dynamic-role-based/src/main/java/org/apache/cloudstack/acl/DynamicRoleBasedAPIAccessChecker.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,11 @@ public boolean checkAccess(User user, String commandName, ApiKeyPairPermission .
160160
logger.info("Account for user id {} is Root Admin or Domain Admin, all APIs are allowed.", user.getUuid());
161161
return true;
162162
}
163-
List<RolePermission> allPermissions = roleAndPermissions.second();
164-
if (checkApiPermissionByRole(accountRole, commandName, allPermissions)) {
163+
164+
List<RolePermissionEntity> allRules = defineNewKeypairRules(accountRole, apiKeyPairPermissions);
165+
boolean override = apiKeyPairPermissions.length != 0;
166+
167+
if (checkApiPermissionByRole(accountRole, commandName, allRules, override)) {
165168
return true;
166169
}
167170
throw new UnavailableCommandException(String.format("The API [%s] does not exist or is not available for the account for user id [%s].", commandName, user.getUuid()));

plugins/acl/dynamic-role-based/src/test/java/org/apache/cloudstack/acl/DynamicRoleBasedAPIAccessCheckerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public void checkAccessTestValidApiKeyPairPermissionWithNullOverride() {
248248
Mockito.doReturn(Collections.singletonList(permission)).when(roleServiceMock).findAllPermissionsBy(Mockito.anyLong());
249249

250250
assertTrue(apiAccessCheckerSpy.checkAccess(getTestUser(), api, emptyPermissionArray));
251-
Mockito.verify(roleServiceMock, Mockito.times(1)).findAllPermissionsBy(Mockito.anyLong());
251+
Mockito.verify(roleServiceMock, Mockito.times(2)).findAllPermissionsBy(Mockito.anyLong());
252252
}
253253

254254
@Test(expected = UnavailableCommandException.class)

0 commit comments

Comments
 (0)