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);
}
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);
}
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());
}
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);
}
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);
}
Aggregations