fix(mobile-api): read roles services-system sends as bare ids

services-system writes a role already seen in a response as its bare id. The
module check missed it, so a role granted two modules was refused the second;
the super-admin target guard now reads it too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-11-26 22:37:49 +08:00
1 parent 4c48ebea2e
commit 69e2b4eb7b
4 files changed
+22 -3

No files matched your search

@@ -32,6 +32,16 @@ class AdminModuleAccessTest {
Map.of("name", "BO_EMPTY"))));
}
@Test
void roleSentAsBareIdBecauseItAppearedEarlier_isGranted() {
// services-system's @JsonIdentityInfo writes a role already seen in the response as its bare id.
when(rest.getForEntity(any(String.class), any(ParameterizedTypeReference.class), eq("BO")))
.thenReturn(ResponseEntity.ok(List.of(
Map.of("name", "BO_USERS", "roles", List.of(Map.of("id", 5))),
Map.of("name", "BO_ROLES", "roles", List.of(5)))));
assertThat(AdminModuleAccess.grantedAny(rest, Set.of(5L), "BO_ROLES")).isTrue();
}
@Test
void roleGrantedModule_isGranted() {
assertThat(AdminModuleAccess.grantedAny(rest, Set.of(6L), "BO_LEADS")).isTrue();