Added missing mocks for new version
This commit is contained in:
parent
abe8df688b
commit
7b5656485b
|
@ -60,7 +60,8 @@ public class D4ScienceContextMapperTest {
|
||||||
.map(ProviderConfigProperty::getName)
|
.map(ProviderConfigProperty::getName)
|
||||||
.collect(Collectors.toList());
|
.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,
|
OIDCAttributeMapperHelper.INCLUDE_IN_ACCESS_TOKEN, D4ScienceContextMapper.HTTP_REQUEST_HEADER_NAME,
|
||||||
D4ScienceContextMapper.NARROW_RESOURCE_ACCESS);
|
D4ScienceContextMapper.NARROW_RESOURCE_ACCESS);
|
||||||
}
|
}
|
||||||
|
@ -109,8 +110,11 @@ public class D4ScienceContextMapperTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private KeycloakSession givenKeycloakSession(boolean withHeader) {
|
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);
|
KeycloakContext context = Mockito.mock(KeycloakContext.class);
|
||||||
|
when(context.getClient()).thenReturn(clientModel);
|
||||||
|
KeycloakSession keycloakSession = Mockito.mock(KeycloakSession.class);
|
||||||
when(keycloakSession.getContext()).thenReturn(context);
|
when(keycloakSession.getContext()).thenReturn(context);
|
||||||
HttpHeaders headers = Mockito.mock(HttpHeaders.class);
|
HttpHeaders headers = Mockito.mock(HttpHeaders.class);
|
||||||
when(context.getRequestHeaders()).thenReturn(headers);
|
when(context.getRequestHeaders()).thenReturn(headers);
|
||||||
|
@ -135,13 +139,12 @@ public class D4ScienceContextMapperTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
return new D4ScienceContextMapper().transformAccessToken(at, mappingModel, keycloakSession,
|
return new D4ScienceContextMapper().transformAccessToken(at, mappingModel, keycloakSession,
|
||||||
userSessionModel, givenClientSessionContext());
|
userSessionModel, givenClientSessionContext(keycloakSession));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClientSessionContext givenClientSessionContext() {
|
private ClientSessionContext givenClientSessionContext(KeycloakSession keycloakSession) {
|
||||||
ClientModel clientModel = Mockito.mock(ClientModel.class);
|
|
||||||
when(clientModel.getName()).thenReturn("test-client-id");
|
|
||||||
AuthenticatedClientSessionModel acsm = Mockito.mock(AuthenticatedClientSessionModel.class);
|
AuthenticatedClientSessionModel acsm = Mockito.mock(AuthenticatedClientSessionModel.class);
|
||||||
|
ClientModel clientModel = keycloakSession.getContext().getClient();
|
||||||
when(acsm.getClient()).thenReturn(clientModel);
|
when(acsm.getClient()).thenReturn(clientModel);
|
||||||
ClientSessionContext csc = Mockito.mock(ClientSessionContext.class);
|
ClientSessionContext csc = Mockito.mock(ClientSessionContext.class);
|
||||||
when(csc.getClientSession()).thenReturn(acsm);
|
when(csc.getClientSession()).thenReturn(acsm);
|
||||||
|
|
Loading…
Reference in New Issue