feat: return authorization snapshot outside jwt
This commit is contained in:
@@ -72,7 +72,8 @@ class AuthServiceSmallJwtTest {
|
||||
when(jwtEncoder.encode(any())).thenReturn(encoded);
|
||||
when(encoded.getTokenValue()).thenReturn("small-token");
|
||||
when(overseasTokenService.issue(account, snapshot)).thenReturn(
|
||||
new OverseasTokenService.OverseasTokenResponse("Bearer", "overseas-token", 900));
|
||||
new OverseasTokenService.OverseasTokenResponse("Bearer", "overseas-token", 900,
|
||||
snapshot.getRoles(), snapshot.getPermissions()));
|
||||
|
||||
var response = service.login(new LoginRequest("operator", "secret"));
|
||||
|
||||
@@ -98,6 +99,8 @@ class AuthServiceSmallJwtTest {
|
||||
verify(overseasTokenService).issue(account, snapshot);
|
||||
assertThat(response.overseasAccessToken()).isEqualTo("overseas-token");
|
||||
assertThat(response.overseasExpiresIn()).isEqualTo(900);
|
||||
assertThat(response.roles()).containsExactly("OVERSEAS_WAREHOUSE_PDA_OPERATOR");
|
||||
assertThat(response.authorities()).containsExactly("platform:order:list");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -162,7 +165,8 @@ class AuthServiceSmallJwtTest {
|
||||
when(jwtEncoder.encode(any())).thenReturn(encoded);
|
||||
when(encoded.getTokenValue()).thenReturn("domestic-refreshed");
|
||||
when(overseasTokenService.issue(account, snapshot)).thenReturn(
|
||||
new OverseasTokenService.OverseasTokenResponse("Bearer", "overseas-refreshed", 900));
|
||||
new OverseasTokenService.OverseasTokenResponse("Bearer", "overseas-refreshed", 900,
|
||||
snapshot.getRoles(), snapshot.getPermissions()));
|
||||
|
||||
var response = service.refresh("refresh-old");
|
||||
|
||||
@@ -173,6 +177,8 @@ class AuthServiceSmallJwtTest {
|
||||
assertThat(response.refreshExpiresIn()).isEqualTo(604800);
|
||||
assertThat(response.overseasAccessToken()).isEqualTo("overseas-refreshed");
|
||||
assertThat(response.overseasExpiresIn()).isEqualTo(900);
|
||||
assertThat(response.roles()).containsExactly("MERCHANT_ADMIN");
|
||||
assertThat(response.authorities()).containsExactly("merchant:order:list");
|
||||
verify(tokenSessionStore).consume("refresh-old");
|
||||
verify(tokenSessionStore).store(anyString(), org.mockito.ArgumentMatchers.eq(52L),
|
||||
org.mockito.ArgumentMatchers.eq(Set.of("MERCHANT_ADMIN")),
|
||||
|
||||
@@ -82,6 +82,9 @@ class OverseasTokenServiceTest {
|
||||
.doesNotContainKeys("roles", "authorities", "permissions", "userId", "tenantId", "appCode",
|
||||
"permissionVersion");
|
||||
assertThat(response.expiresIn()).isEqualTo(900);
|
||||
assertThat(response.roles()).containsExactly("OVERSEAS_WAREHOUSE_PDA_OPERATOR");
|
||||
assertThat(response.authorities()).containsExactlyInAnyOrder(authority, merchantAuthority,
|
||||
merchantCrossBorderAuthority, lastlegAuthority, financeAuthority, domesticAuthority);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user