test(iam): verify authorization session revocation

This commit is contained in:
2026-08-10 12:37:46 +08:00
parent 14929bb257
commit 7684f3cfec
2 changed files with 7 additions and 0 deletions
@@ -167,11 +167,14 @@ class MemberServiceTest {
@Test void shouldHandleCase11() { @Test void shouldHandleCase11() {
UpdateMemberRequest request = new UpdateMemberRequest("测试成员", null, null, UpdateMemberRequest request = new UpdateMemberRequest("测试成员", null, null,
"EMPLOYEE", null, List.of()); "EMPLOYEE", null, List.of());
when(auth.revokeSessions(anyString(), any())).thenReturn(ApiResponse.success(null));
service.update(100L, 20L, request, service.update(100L, 20L, request,
Set.of("merchant:member:edit", "merchant:member:grant-role")); Set.of("merchant:member:edit", "merchant:member:grant-role"));
verify(repository).replaceRoles(100L, 20L, List.of()); verify(repository).replaceRoles(100L, 20L, List.of());
verify(auth).revokeSessions(eq("internal-token"),
eq(new AuthAccountClient.RevokeAccountSessionsRequest(Set.of(40L))));
} }
@Test void shouldHandleCase12() { @Test void shouldHandleCase12() {
@@ -18,6 +18,7 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import java.util.List; import java.util.List;
import java.util.Set;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*; import static org.mockito.ArgumentMatchers.*;
@@ -154,12 +155,15 @@ class PlatformInternalUserServiceTest {
IamRole role = new IamRole(); IamRole role = new IamRole();
role.setId(41L); role.setTenantId(0L); role.setAppCode("PLATFORM"); role.setStatus("ACTIVE"); role.setId(41L); role.setTenantId(0L); role.setAppCode("PLATFORM"); role.setStatus("ACTIVE");
when(roleMapper.selectById(41L)).thenReturn(role); when(roleMapper.selectById(41L)).thenReturn(role);
when(auth.revokeSessions(anyString(), any())).thenReturn(ApiResponse.success(null));
InternalUserResponse result = service.assignRoles(30L, InternalUserResponse result = service.assignRoles(30L,
new AssignInternalUserRolesRequest(List.of(41L, 41L))); new AssignInternalUserRolesRequest(List.of(41L, 41L)));
assertEquals(List.of(41L), result.roleIds()); assertEquals(List.of(41L), result.roleIds());
verify(repository).replaceRoles(0L, 30L, List.of(41L)); verify(repository).replaceRoles(0L, 30L, List.of(41L));
verify(auth).revokeSessions(eq("internal-token"),
eq(new AuthAccountClient.RevokeAccountSessionsRequest(Set.of(10L))));
} }
@Test @Test