use of uk.gov.ida.hub.policy.contracts.SamlResponseWithAuthnRequestInformationDto in project verify-hub by alphagov.
the class AuthnRequestFromTransactionHandlerTest method testHandleRequestFromTransaction_logsToEventSink.
@Test
public void testHandleRequestFromTransaction_logsToEventSink() {
final SamlResponseWithAuthnRequestInformationDto samlResponseWithAuthnRequestInformationDto = SamlResponseWithAuthnRequestInformationDtoBuilder.aSamlResponseWithAuthnRequestInformationDto().build();
final String ipAddress = "ipaddress";
final URI assertionConsumerServiceUri = URI.create("blah");
final Optional<String> relayState = Optional.of("relaystate");
when(policyConfiguration.getSessionLength()).thenReturn(Duration.standardHours(1));
when(transactionsConfigProxy.getLevelsOfAssurance(samlResponseWithAuthnRequestInformationDto.getIssuer())).thenReturn(asList(LevelOfAssurance.LEVEL_1, LevelOfAssurance.LEVEL_1));
authnRequestFromTransactionHandler.handleRequestFromTransaction(samlResponseWithAuthnRequestInformationDto, relayState, ipAddress, assertionConsumerServiceUri, false);
verify(hubEventLogger, times(1)).logSessionStartedEvent(Matchers.<SamlResponseWithAuthnRequestInformationDto>any(), anyString(), Matchers.<DateTime>any(), Matchers.<SessionId>any(), Matchers.<LevelOfAssurance>any(), Matchers.<LevelOfAssurance>any());
}
use of uk.gov.ida.hub.policy.contracts.SamlResponseWithAuthnRequestInformationDto in project verify-hub by alphagov.
the class HubEventLoggerTest method logSessionOpenEvent_shouldSendEvent.
@Test
public void logSessionOpenEvent_shouldSendEvent() {
final SamlResponseWithAuthnRequestInformationDto samlResponse = aSamlResponseWithAuthnRequestInformationDto().withId(REQUEST_ID).withIssuer(TRANSACTION_ENTITY_ID).build();
eventLogger.logSessionStartedEvent(samlResponse, PRINCIPAL_IP_ADDRESS_SEEN_BY_HUB, SESSION_EXPIRY_TIMESTAMP, SESSION_ID, MINIMUM_LEVEL_OF_ASSURANCE, REQUIRED_LEVEL_OF_ASSURANCE);
final Map<EventDetailsKey, String> details = new HashMap<>();
details.put(principal_ip_address_as_seen_by_hub, PRINCIPAL_IP_ADDRESS_SEEN_BY_HUB);
details.put(message_id, samlResponse.getId());
details.put(minimum_level_of_assurance, MINIMUM_LEVEL_OF_ASSURANCE.name());
details.put(required_level_of_assurance, REQUIRED_LEVEL_OF_ASSURANCE.name());
details.put(session_event_type, SESSION_STARTED);
final EventSinkHubEvent expectedEvent = createExpectedEventSinkHubEvent(details);
verify(eventSinkProxy).logHubEvent(argThat(new EventMatching(expectedEvent)));
verify(eventEmitter).record(argThat(new EventMatching(expectedEvent)));
}
use of uk.gov.ida.hub.policy.contracts.SamlResponseWithAuthnRequestInformationDto in project verify-hub by alphagov.
the class SessionTimeoutIntegrationTests method setUp.
@Before
public void setUp() throws Exception {
SamlResponseWithAuthnRequestInformationDto samlResponse = SamlResponseWithAuthnRequestInformationDtoBuilder.aSamlResponseWithAuthnRequestInformationDto().withIssuer(THE_TX_ID).build();
samlRequest = SamlAuthnRequestContainerDtoBuilder.aSamlAuthnRequestContainerDto().build();
samlEngineStub.setupStubForAuthnRequestTranslate(samlResponse);
configStub.setUpStubForLevelsOfAssurance(samlResponse.getIssuer());
eventSinkStub.setupStubForLogging();
configStub.setUpStubForAssertionConsumerServiceUri(samlResponse.getIssuer());
configStub.setupStubForEidasEnabledForTransaction(THE_TX_ID, false);
}
use of uk.gov.ida.hub.policy.contracts.SamlResponseWithAuthnRequestInformationDto in project verify-hub by alphagov.
the class SessionServiceTest method shouldThrowSessionCreationFailureExceptionIfProvidedAssertionConsumerServiceUrlDoesntMatch.
@Test(expected = SessionCreationFailureException.class)
public void shouldThrowSessionCreationFailureExceptionIfProvidedAssertionConsumerServiceUrlDoesntMatch() throws Exception {
SamlResponseWithAuthnRequestInformationDto samlResponse = aSamlResponseWithAuthnRequestInformationDto().withAssertionConsumerServiceUrl(URI.create("http://wrongurl")).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);
service.create(requestDto);
}
use of uk.gov.ida.hub.policy.contracts.SamlResponseWithAuthnRequestInformationDto in project verify-hub by alphagov.
the class SessionServiceTest method shouldCreateSessionWithTransactionSupportsEidas.
@Test
public void shouldCreateSessionWithTransactionSupportsEidas() throws Exception {
// Given
URI assertionConsumerServiceUri = UriBuilder.fromUri(UUID.randomUUID().toString()).build();
SamlResponseWithAuthnRequestInformationDto samlResponse = aSamlResponseWithAuthnRequestInformationDto().build();
final SessionId sessionId = SessionIdBuilder.aSessionId().with("coffee-pasta").build();
givenSamlEngineTranslatesRequest(samlResponse);
givenConfigReturnsAssertionConsumerServiceURLFor(samlResponse, assertionConsumerServiceUri);
givenConfigReturnsTransactionSupportsEidas(samlResponse, true);
givenSessionIsCreated(samlResponse, assertionConsumerServiceUri, sessionId, true);
// When
SessionId result = service.create(requestDto);
// Then
assertThat(result, is(sessionId));
verify(authnRequestHandler).handleRequestFromTransaction(samlResponse, requestDto.getRelayState(), requestDto.getPrincipalIPAddressAsSeenByHub(), assertionConsumerServiceUri, true);
}
Aggregations