Search in sources :

Example 76 with SessionId

use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.

the class EidasCycle3MatchRequestSentStateBuilderTest method build.

@Test
public void build() {
    EidasCycle3MatchRequestSentState state = EidasCycle3MatchRequestSentStateBuilder.anEidasCycle3MatchRequestSentState().build();
    assertThat(state.getRequestId()).isEqualTo("requestId");
    assertThat(state.getIdentityProviderEntityId()).isEqualTo("identityProviderEntityId");
    assertThat(state.getSessionExpiryTimestamp()).isEqualTo(DateTime.now().plusMinutes(10));
    assertThat(state.getRelayState()).isEqualTo(Optional.absent());
    assertThat(state.getRequestIssuerEntityId()).isEqualTo("requestIssuerId");
    assertThat(state.getEncryptedIdentityAssertion()).isEqualTo("encryptedIdentityAssertion");
    assertThat(state.getAssertionConsumerServiceUri()).isEqualTo(URI.create("assertionConsumerServiceUri"));
    assertThat(state.getMatchingServiceAdapterEntityId()).isEqualTo("matchingServiceAdapterEntityId");
    assertThat(state.getSessionId()).isEqualTo(new SessionId("sessionId"));
    assertThat(state.getIdpLevelOfAssurance()).isEqualTo(LevelOfAssurance.LEVEL_2);
    assertThat(state.getPersistentId()).isEqualTo(new PersistentId("default-name-id"));
    assertThat(state.getTransactionSupportsEidas()).isEqualTo(true);
}
Also used : EidasCycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.EidasCycle3MatchRequestSentState) SessionId(uk.gov.ida.hub.policy.domain.SessionId) PersistentId(uk.gov.ida.hub.policy.domain.PersistentId) Test(org.junit.Test)

Example 77 with SessionId

use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.

the class NoMatchStateBuilderTest method build.

@Test
public void build() {
    NoMatchState noMatchState = NoMatchStateBuilder.aNoMatchState().build();
    assertThat(noMatchState.getRequestId()).isEqualTo("request ID");
    assertThat(noMatchState.getIdentityProviderEntityId()).isEqualTo("idp entity id");
    assertThat(noMatchState.getRequestIssuerEntityId()).isEqualTo("requestIssuerId");
    assertThat(noMatchState.getSessionExpiryTimestamp()).isEqualTo(DateTime.now().plusMinutes(10));
    assertThat(noMatchState.getAssertionConsumerServiceUri()).isEqualTo(URI.create("/someUri"));
    assertThat(noMatchState.getRelayState()).isEqualTo(Optional.absent());
    assertThat(noMatchState.getSessionId()).isEqualTo(new SessionId("sessionId"));
    assertThat(noMatchState.getTransactionSupportsEidas()).isEqualTo(false);
}
Also used : NoMatchState(uk.gov.ida.hub.policy.domain.state.NoMatchState) SessionId(uk.gov.ida.hub.policy.domain.SessionId) Test(org.junit.Test)

Example 78 with SessionId

use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.

the class AwaitingCycle3DataStateControllerTest method shouldMoveFromAwaitingC3StateToCycle3DataSentStateWhenCycle3DataIsReceived.

@Test
public void shouldMoveFromAwaitingC3StateToCycle3DataSentStateWhenCycle3DataIsReceived() throws Exception {
    final SessionId sessionId = SessionId.createNewSessionId();
    AwaitingCycle3DataState state = anAwaitingCycle3DataState().withSessionId(sessionId).build();
    AwaitingCycle3DataStateController controller = new AwaitingCycle3DataStateController(state, hubEventLogger, stateTransitionAction, transactionsConfigProxy, responseFromHubFactory, policyConfiguration, assertionRestrictionsFactory, matchingServiceConfigProxy);
    when(policyConfiguration.getMatchingServiceResponseWaitPeriod()).thenReturn(Duration.standardMinutes(5));
    ArgumentCaptor<Cycle3MatchRequestSentState> argumentCaptor = ArgumentCaptor.forClass(Cycle3MatchRequestSentState.class);
    when(matchingServiceConfigProxy.getMatchingService(state.getMatchingServiceEntityId())).thenReturn(aMatchingServiceConfigEntityDataDto().build());
    controller.handleCycle3DataSubmitted("principalIpAsSeenByHub");
    verify(stateTransitionAction, times(1)).transitionTo(argumentCaptor.capture());
    final Cycle3MatchRequestSentState cycle3MatchRequestSentState = argumentCaptor.getValue();
    assertThat(cycle3MatchRequestSentState.getEncryptedMatchingDatasetAssertion()).isEqualTo(state.getEncryptedMatchingDatasetAssertion());
}
Also used : AwaitingCycle3DataStateBuilder.anAwaitingCycle3DataState(uk.gov.ida.hub.policy.builder.state.AwaitingCycle3DataStateBuilder.anAwaitingCycle3DataState) AwaitingCycle3DataState(uk.gov.ida.hub.policy.domain.state.AwaitingCycle3DataState) Cycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState) SessionId(uk.gov.ida.hub.policy.domain.SessionId) SessionIdBuilder.aSessionId(uk.gov.ida.hub.policy.builder.domain.SessionIdBuilder.aSessionId) HasSessionId.hasSessionId(uk.gov.ida.hub.policy.matchers.HasSessionId.hasSessionId) Test(org.junit.Test)

Example 79 with SessionId

use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.

the class AwaitingCycle3DataStateControllerTest method handleCycle3DataSubmitted_shouldLogCycle3DataObtainedAndPrincipalIpAddressSeenByHubToEventSink.

@Test
public void handleCycle3DataSubmitted_shouldLogCycle3DataObtainedAndPrincipalIpAddressSeenByHubToEventSink() {
    final SessionId sessionId = aSessionId().build();
    final String principalIpAddressAsSeenByHub = "principal-ip-address-as-seen-by-hub";
    final String requestId = "requestId";
    final AwaitingCycle3DataStateController awaitingCycle3DataStateController = setUpAwaitingCycle3DataStateController(requestId, sessionId);
    awaitingCycle3DataStateController.handleCycle3DataSubmitted(principalIpAddressAsSeenByHub);
    ArgumentCaptor<EventSinkHubEvent> argumentCaptor = ArgumentCaptor.forClass(EventSinkHubEvent.class);
    verify(eventSinkProxy, atLeastOnce()).logHubEvent(argumentCaptor.capture());
    Condition<EventSinkHubEvent> combinedConditions = AllOf.allOf(hasSessionId(sessionId), hasDetail(EventDetailsKey.session_event_type, CYCLE3_DATA_OBTAINED), hasDetail(EventDetailsKey.request_id, requestId), hasDetail(EventDetailsKey.principal_ip_address_as_seen_by_hub, principalIpAddressAsSeenByHub));
    assertThat(argumentCaptor.getAllValues()).haveAtLeast(1, combinedConditions);
}
Also used : SessionId(uk.gov.ida.hub.policy.domain.SessionId) SessionIdBuilder.aSessionId(uk.gov.ida.hub.policy.builder.domain.SessionIdBuilder.aSessionId) HasSessionId.hasSessionId(uk.gov.ida.hub.policy.matchers.HasSessionId.hasSessionId) EventSinkHubEvent(uk.gov.ida.hub.policy.domain.EventSinkHubEvent) Test(org.junit.Test)

Example 80 with SessionId

use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.

the class Cycle3MatchRequestSentStateControllerTest method shouldReturnErrorResponseWhenAskedAndInAwaitingCycle3DataState.

@Test
public void shouldReturnErrorResponseWhenAskedAndInAwaitingCycle3DataState() {
    final String requestId = "requestId";
    final SessionId sessionId = SessionId.createNewSessionId();
    Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().withSessionId(sessionId).withRequestId(requestId).build();
    Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, null, policyConfiguration, null, responseFromHubFactory, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
    final ResponseFromHub responseFromHub = controller.getErrorResponse();
    assertThat(responseFromHub.getStatus()).isEqualTo(TransactionIdaStatus.NoAuthenticationContext);
}
Also used : Cycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState) Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState(uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState) Matchers.anyString(org.mockito.Matchers.anyString) SessionId(uk.gov.ida.hub.policy.domain.SessionId) ResponseFromHub(uk.gov.ida.hub.policy.domain.ResponseFromHub) Test(org.junit.Test)

Aggregations

SessionId (uk.gov.ida.hub.policy.domain.SessionId)92 Test (org.junit.Test)83 Response (javax.ws.rs.core.Response)41 URI (java.net.URI)33 ResponseProcessingDetails (uk.gov.ida.hub.policy.domain.ResponseProcessingDetails)14 SessionId.createNewSessionId (uk.gov.ida.hub.policy.domain.SessionId.createNewSessionId)13 Cycle3MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState)12 Matchers.anyString (org.mockito.Matchers.anyString)9 Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState (uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState)9 InboundResponseFromMatchingServiceDto (uk.gov.ida.hub.policy.contracts.InboundResponseFromMatchingServiceDto)6 MatchingServiceRequestErrorState (uk.gov.ida.hub.policy.domain.state.MatchingServiceRequestErrorState)6 SessionIdBuilder.aSessionId (uk.gov.ida.hub.policy.builder.domain.SessionIdBuilder.aSessionId)5 AuthnResponseFromHubContainerDto (uk.gov.ida.hub.policy.contracts.AuthnResponseFromHubContainerDto)5 Cycle3AttributeRequestData (uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData)5 EventSinkHubEvent (uk.gov.ida.hub.policy.domain.EventSinkHubEvent)5 NoMatchFromMatchingService (uk.gov.ida.hub.policy.domain.NoMatchFromMatchingService)5 ResponseFromHub (uk.gov.ida.hub.policy.domain.ResponseFromHub)5 SamlRequestDto (uk.gov.ida.hub.policy.contracts.SamlRequestDto)4 SamlResponseWithAuthnRequestInformationDto (uk.gov.ida.hub.policy.contracts.SamlResponseWithAuthnRequestInformationDto)4 AuthnRequestFromHubContainerDto (uk.gov.ida.hub.policy.domain.AuthnRequestFromHubContainerDto)4