Search in sources :

Example 6 with SamlResponseWithAuthnRequestInformationDto

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));
}
Also used : URI(java.net.URI) SamlResponseWithAuthnRequestInformationDtoBuilder.aSamlResponseWithAuthnRequestInformationDto(uk.gov.ida.hub.policy.proxy.SamlResponseWithAuthnRequestInformationDtoBuilder.aSamlResponseWithAuthnRequestInformationDto) SamlResponseWithAuthnRequestInformationDto(uk.gov.ida.hub.policy.contracts.SamlResponseWithAuthnRequestInformationDto) SessionId(uk.gov.ida.hub.policy.domain.SessionId) SessionId.createNewSessionId(uk.gov.ida.hub.policy.domain.SessionId.createNewSessionId) Test(org.junit.Test)

Example 7 with SamlResponseWithAuthnRequestInformationDto

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));
}
Also used : SamlResponseWithAuthnRequestInformationDtoBuilder.aSamlResponseWithAuthnRequestInformationDto(uk.gov.ida.hub.policy.proxy.SamlResponseWithAuthnRequestInformationDtoBuilder.aSamlResponseWithAuthnRequestInformationDto) SamlResponseWithAuthnRequestInformationDto(uk.gov.ida.hub.policy.contracts.SamlResponseWithAuthnRequestInformationDto) URI(java.net.URI) SessionId(uk.gov.ida.hub.policy.domain.SessionId) SessionId.createNewSessionId(uk.gov.ida.hub.policy.domain.SessionId.createNewSessionId) Test(org.junit.Test)

Example 8 with SamlResponseWithAuthnRequestInformationDto

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);
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) SamlResponseWithAuthnRequestInformationDtoBuilder.aSamlResponseWithAuthnRequestInformationDto(uk.gov.ida.hub.policy.proxy.SamlResponseWithAuthnRequestInformationDtoBuilder.aSamlResponseWithAuthnRequestInformationDto) SamlResponseWithAuthnRequestInformationDto(uk.gov.ida.hub.policy.contracts.SamlResponseWithAuthnRequestInformationDto) Test(org.junit.Test)

Example 9 with SamlResponseWithAuthnRequestInformationDto

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);
}
Also used : SamlResponseWithAuthnRequestInformationDto(uk.gov.ida.hub.policy.contracts.SamlResponseWithAuthnRequestInformationDto) URI(java.net.URI)

Aggregations

SamlResponseWithAuthnRequestInformationDto (uk.gov.ida.hub.policy.contracts.SamlResponseWithAuthnRequestInformationDto)9 Test (org.junit.Test)7 URI (java.net.URI)6 SamlResponseWithAuthnRequestInformationDtoBuilder.aSamlResponseWithAuthnRequestInformationDto (uk.gov.ida.hub.policy.proxy.SamlResponseWithAuthnRequestInformationDtoBuilder.aSamlResponseWithAuthnRequestInformationDto)6 SessionId (uk.gov.ida.hub.policy.domain.SessionId)4 SessionId.createNewSessionId (uk.gov.ida.hub.policy.domain.SessionId.createNewSessionId)4 HashMap (java.util.HashMap)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Before (org.junit.Before)1 Matchers.anyString (org.mockito.Matchers.anyString)1 EventDetailsKey (uk.gov.ida.eventsink.EventDetailsKey)1 EventSinkHubEvent (uk.gov.ida.hub.policy.domain.EventSinkHubEvent)1