This commit is contained in:
2026-08-10 12:27:16 +08:00
parent eab51bc5ac
commit 14929bb257
3 changed files with 117 additions and 1 deletions
@@ -349,6 +349,22 @@ class RbacServiceTest {
eq(new AuthAccountClient.RevokeAccountSessionsRequest(Set.of(501L))));
}
@Test
void permissionStatusChangeRevokesMembersOfEveryGrantedRole() {
IamPermission custom = permission(21L, 100L, "merchant:custom:edit");
when(repository.findOwnedPermission(21L, 100L, "MERCHANT")).thenReturn(custom);
when(repository.findRoleIdsByPermission(100L, 21L)).thenReturn(Set.of(11L, 12L));
when(repository.findAssignedAuthUserIds(100L, 11L)).thenReturn(List.of(501L, 502L));
when(repository.findAssignedAuthUserIds(100L, 12L)).thenReturn(List.of(502L, 503L));
when(authClient.revokeSessions(any(), any())).thenReturn(ApiResponse.success(null));
service.changePermissionStatus(100L, "MERCHANT", 21L,
new ChangePermissionStatusRequest("DISABLED"));
verify(authClient).revokeSessions(eq("test-internal-token"),
eq(new AuthAccountClient.RevokeAccountSessionsRequest(Set.of(501L, 502L, 503L))));
}
@Test
void authFailureRejectsRoleStatusChangeSoIamTransactionCanRollBack() {
IamRole role = role(11L, 100L, "MERCHANT", "CUSTOM");