use of uk.gov.ida.hub.policy.domain.IdaAuthnRequestFromHubDto in project verify-hub by alphagov.
the class SessionServiceTest method shouldGetACountryAuthnRequestWithOverriddenSsoUrl.
@Test
public void shouldGetACountryAuthnRequestWithOverriddenSsoUrl() throws Exception {
// Given
SessionId sessionId = createNewSessionId();
when(sessionRepository.sessionExists(sessionId)).thenReturn(true);
when(sessionRepository.isSessionInState(sessionId, CountrySelectedState.class)).thenReturn(true);
AuthnRequestFromHub authnRequestFromHub = anAuthnRequestFromHub().withSsoUrl(URI.create("/theSsoUri")).build();
when(authnRequestHandler.getIdaAuthnRequestFromHub(sessionId)).thenReturn(authnRequestFromHub);
URI ssoUri = UriBuilder.fromUri(UUID.randomUUID().toString()).build();
SamlRequestDto samlRequest = new SamlRequestDto("samlRequest", ssoUri);
when(samlEngineProxy.generateCountryAuthnRequestFromHub(any(IdaAuthnRequestFromHubDto.class))).thenReturn(samlRequest);
// When
AuthnRequestFromHubContainerDto countryAuthnRequest = service.getIdpAuthnRequest(sessionId);
// Then
AuthnRequestFromHubContainerDto expected = new AuthnRequestFromHubContainerDto(samlRequest.getSamlRequest(), ssoUri, authnRequestFromHub.getRegistering());
assertThat(countryAuthnRequest).isEqualToComparingFieldByField(expected);
ArgumentCaptor<IdaAuthnRequestFromHubDto> requestFromHubDtoArgumentCaptor = ArgumentCaptor.forClass(IdaAuthnRequestFromHubDto.class);
verify(samlEngineProxy).generateCountryAuthnRequestFromHub(requestFromHubDtoArgumentCaptor.capture());
assertThat(requestFromHubDtoArgumentCaptor.getValue().getOverriddenSsoUrl(), notNullValue());
}
use of uk.gov.ida.hub.policy.domain.IdaAuthnRequestFromHubDto in project verify-hub by alphagov.
the class SessionService method getIdpAuthnRequest.
public AuthnRequestFromHubContainerDto getIdpAuthnRequest(SessionId sessionId) {
getSessionIfItExists(sessionId);
final AuthnRequestFromHub request = authnRequestHandler.getIdaAuthnRequestFromHub(sessionId);
final IdaAuthnRequestFromHubDto authnRequestFromHub = new IdaAuthnRequestFromHubDto(request.getId(), request.getForceAuthentication(), request.getSessionExpiryTimestamp(), request.getRecipientEntityId(), request.getLevelsOfAssurance(), request.getUseExactComparisonType(), request.getOverriddenSsoUrl());
boolean countryIdentityProvider = sessionRepository.isSessionInState(sessionId, CountrySelectedState.class);
final SamlRequestDto samlRequest = countryIdentityProvider ? samlEngineProxy.generateCountryAuthnRequestFromHub(authnRequestFromHub) : samlEngineProxy.generateIdpAuthnRequestFromHub(authnRequestFromHub);
return new AuthnRequestFromHubContainerDto(samlRequest.getSamlRequest(), samlRequest.getSsoUri(), request.getRegistering());
}
Aggregations