|
|
|
@ -60,7 +60,8 @@ public class D4ScienceContextMapperTest {
|
|
|
|
|
.map(ProviderConfigProperty::getName)
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
assertThat(configPropertyNames).containsExactly(OIDCAttributeMapperHelper.TOKEN_CLAIM_NAME,
|
|
|
|
|
assertThat(configPropertyNames).containsExactlyInAnyOrder(OIDCAttributeMapperHelper.TOKEN_CLAIM_NAME,
|
|
|
|
|
OIDCAttributeMapperHelper.INCLUDE_IN_LIGHTWEIGHT_ACCESS_TOKEN,
|
|
|
|
|
OIDCAttributeMapperHelper.INCLUDE_IN_ACCESS_TOKEN, D4ScienceContextMapper.HTTP_REQUEST_HEADER_NAME,
|
|
|
|
|
D4ScienceContextMapper.NARROW_RESOURCE_ACCESS);
|
|
|
|
|
}
|
|
|
|
@ -109,8 +110,11 @@ public class D4ScienceContextMapperTest {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private KeycloakSession givenKeycloakSession(boolean withHeader) {
|
|
|
|
|
KeycloakSession keycloakSession = Mockito.mock(KeycloakSession.class);
|
|
|
|
|
ClientModel clientModel = Mockito.mock(ClientModel.class);
|
|
|
|
|
when(clientModel.getName()).thenReturn("test-client-id");
|
|
|
|
|
KeycloakContext context = Mockito.mock(KeycloakContext.class);
|
|
|
|
|
when(context.getClient()).thenReturn(clientModel);
|
|
|
|
|
KeycloakSession keycloakSession = Mockito.mock(KeycloakSession.class);
|
|
|
|
|
when(keycloakSession.getContext()).thenReturn(context);
|
|
|
|
|
HttpHeaders headers = Mockito.mock(HttpHeaders.class);
|
|
|
|
|
when(context.getRequestHeaders()).thenReturn(headers);
|
|
|
|
@ -135,13 +139,12 @@ public class D4ScienceContextMapperTest {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new D4ScienceContextMapper().transformAccessToken(at, mappingModel, keycloakSession,
|
|
|
|
|
userSessionModel, givenClientSessionContext());
|
|
|
|
|
userSessionModel, givenClientSessionContext(keycloakSession));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ClientSessionContext givenClientSessionContext() {
|
|
|
|
|
ClientModel clientModel = Mockito.mock(ClientModel.class);
|
|
|
|
|
when(clientModel.getName()).thenReturn("test-client-id");
|
|
|
|
|
private ClientSessionContext givenClientSessionContext(KeycloakSession keycloakSession) {
|
|
|
|
|
AuthenticatedClientSessionModel acsm = Mockito.mock(AuthenticatedClientSessionModel.class);
|
|
|
|
|
ClientModel clientModel = keycloakSession.getContext().getClient();
|
|
|
|
|
when(acsm.getClient()).thenReturn(clientModel);
|
|
|
|
|
ClientSessionContext csc = Mockito.mock(ClientSessionContext.class);
|
|
|
|
|
when(csc.getClientSession()).thenReturn(acsm);
|
|
|
|
|