use of uk.gov.ida.hub.policy.contracts.SamlResponseWithAuthnRequestInformationDto in project verify-hub by alphagov.
the class SessionServiceTest method shouldCreateSessionIfProvidedAssertionConsumerServiceUrlMatches.
@Test
public void shouldCreateSessionIfProvidedAssertionConsumerServiceUrlMatches() throws Exception {
URI assertionConsumerServiceUri = UriBuilder.fromUri(UUID.randomUUID().toString()).build();
SamlResponseWithAuthnRequestInformationDto samlResponse = aSamlResponseWithAuthnRequestInformationDto().withAssertionConsumerServiceUrl(assertionConsumerServiceUri).build();
final SessionId sessionId = SessionIdBuilder.aSessionId().with("coffee-pasta").build();
givenSamlEngineTranslatesRequest(samlResponse);
givenConfigReturnsAssertionConsumerServiceURLFor(samlResponse, assertionConsumerServiceUri);
givenSessionIsCreated(samlResponse, assertionConsumerServiceUri, sessionId, false);
SessionId result = service.create(requestDto);
assertThat(result, is(sessionId));
}
use of uk.gov.ida.hub.policy.contracts.SamlResponseWithAuthnRequestInformationDto in project verify-hub by alphagov.
the class SessionServiceTest method shouldCreateASessionFromInputs.
@Test
public void shouldCreateASessionFromInputs() {
// Given
SamlResponseWithAuthnRequestInformationDto samlResponse = aSamlResponseWithAuthnRequestInformationDto().build();
URI assertionConsumerServiceUri = UriBuilder.fromUri(UUID.randomUUID().toString()).build();
final SessionId sessionId = SessionIdBuilder.aSessionId().with("coffee-pasta").build();
givenSamlEngineTranslatesRequest(samlResponse);
givenConfigReturnsAssertionConsumerServiceURLFor(samlResponse, assertionConsumerServiceUri);
givenSessionIsCreated(samlResponse, assertionConsumerServiceUri, sessionId, false);
// When
SessionId result = service.create(requestDto);
// Then
assertThat(result, is(sessionId));
}
use of uk.gov.ida.hub.policy.contracts.SamlResponseWithAuthnRequestInformationDto in project verify-hub by alphagov.
the class SessionServiceTest method shouldThrowSessionCreationFailureExceptionIfCallToConfigServiceThrowsExceptionBecauseAssertionConsumerServiceUriIsInvalid.
@Test(expected = SessionCreationFailureException.class)
public void shouldThrowSessionCreationFailureExceptionIfCallToConfigServiceThrowsExceptionBecauseAssertionConsumerServiceUriIsInvalid() throws Exception {
SamlResponseWithAuthnRequestInformationDto samlResponse = aSamlResponseWithAuthnRequestInformationDto().build();
givenSamlEngineTranslatesRequest(samlResponse);
stub(configProxy.getAssertionConsumerServiceUri(samlResponse.getIssuer(), samlResponse.getAssertionConsumerServiceIndex())).toThrow(new WebApplicationException());
service.create(requestDto);
}
use of uk.gov.ida.hub.policy.contracts.SamlResponseWithAuthnRequestInformationDto in project verify-hub by alphagov.
the class SessionService method create.
public SessionId create(final SamlAuthnRequestContainerDto requestDto) {
SamlResponseWithAuthnRequestInformationDto samlResponse = samlEngineProxy.translate(requestDto.getSamlRequest());
URI assertionConsumerServiceUri = getAssertionConsumerServiceUri(samlResponse);
boolean transactionSupportsEidas = getTransactionSupportsEidas(samlResponse.getIssuer());
return authnRequestHandler.handleRequestFromTransaction(samlResponse, requestDto.getRelayState(), requestDto.getPrincipalIPAddressAsSeenByHub(), assertionConsumerServiceUri, transactionSupportsEidas);
}
Aggregations