Search in sources :

Example 1 with Cycle0And1MatchRequestSentState

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

the class ErrorStateControllerTests method shouldReturnErrorResponseWhenAskedAndInCycle0And1MatchRequestSentState.

@Test
public void shouldReturnErrorResponseWhenAskedAndInCycle0And1MatchRequestSentState() {
    Cycle0And1MatchRequestSentState state = Cycle0And1MatchRequestSentStateBuilder.aCycle0And1MatchRequestSentState().build();
    StateController stateController = new Cycle0And1MatchRequestSentStateController(state, hubEventLogger, stateTransitionAction, policyConfiguration, levelOfAssuranceValidator, transactionsConfigProxy, responseFromHubFactory, assertionRestrictionFactory, matchingServiceConfigProxy, attributeQueryService);
    when(sessionRepository.getStateController(sessionId, ErrorResponsePreparedState.class)).thenReturn(stateController);
    ResponseFromHub responseFromHub = authnRequestFromTransactionHandler.getErrorResponseFromHub(sessionId);
    assertThat(responseFromHub.getStatus()).isEqualTo(TransactionIdaStatus.NoAuthenticationContext);
}
Also used : Cycle0And1MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState) StateController(uk.gov.ida.hub.policy.domain.StateController) ResponseFromHub(uk.gov.ida.hub.policy.domain.ResponseFromHub) Test(org.junit.Test)

Example 2 with Cycle0And1MatchRequestSentState

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

the class IdpSelectedStateControllerTest method handleSuccessResponseFromIdp_shouldTransitionToCycle0And1MatchRequestSentState.

@Test
public void handleSuccessResponseFromIdp_shouldTransitionToCycle0And1MatchRequestSentState() {
    ArgumentCaptor<Cycle0And1MatchRequestSentState> stateArgumentCaptor = ArgumentCaptor.forClass(Cycle0And1MatchRequestSentState.class);
    PersistentId persistentId = aPersistentId().withNameId("idname").build();
    final String encryptedMatchingDatasetAssertion = "blah";
    SuccessFromIdp successFromIdp = aSuccessFromIdp().withIssuerId(IDP_ENTITY_ID).withPersistentId(persistentId).withPrincipalIpAddressSeenByIdp(PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_IDP).withPrincipalIpAddressAsSeenByHub(PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_HUB).withLevelOfAssurance(PROVIDED_LOA).withEncryptedMatchingDatasetAssertion(encryptedMatchingDatasetAssertion).build();
    when(identityProvidersConfigProxy.getEnabledIdentityProviders(TRANSACTION_ENTITY_ID, controller.isRegistrationContext(), PROVIDED_LOA)).thenReturn(singletonList(IDP_ENTITY_ID));
    when(policyConfiguration.getMatchingServiceResponseWaitPeriod()).thenReturn(new org.joda.time.Duration(600L));
    when(identityProvidersConfigProxy.getIdpConfig(IDP_ENTITY_ID)).thenReturn(anIdpConfigDto().withLevelsOfAssurance(LEVELS_OF_ASSURANCE).build());
    controller.handleSuccessResponseFromIdp(successFromIdp);
    verify(stateTransitionAction).transitionTo(stateArgumentCaptor.capture());
    assertThat(stateArgumentCaptor.getValue()).isInstanceOf(Cycle0And1MatchRequestSentState.class);
    assertThat(stateArgumentCaptor.getValue().getEncryptedMatchingDatasetAssertion()).isEqualTo(encryptedMatchingDatasetAssertion);
}
Also used : SuccessFromIdp(uk.gov.ida.hub.policy.domain.SuccessFromIdp) SuccessFromIdpBuilder.aSuccessFromIdp(uk.gov.ida.hub.policy.builder.domain.SuccessFromIdpBuilder.aSuccessFromIdp) Cycle0And1MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState) PersistentId(uk.gov.ida.hub.policy.domain.PersistentId) PersistentIdBuilder.aPersistentId(uk.gov.ida.hub.policy.builder.domain.PersistentIdBuilder.aPersistentId) Test(org.junit.Test)

Example 3 with Cycle0And1MatchRequestSentState

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

the class IdpSelectedStateController method createCycle0And1MatchRequestSentState.

private State createCycle0And1MatchRequestSentState(SuccessFromIdp successFromIdp) {
    String authnStatementAssertion = successFromIdp.getAuthnStatementAssertion();
    String matchingServiceEntityId = getMatchingServiceEntityId();
    return new Cycle0And1MatchRequestSentState(state.getRequestId(), state.getRequestIssuerEntityId(), state.getSessionExpiryTimestamp(), state.getAssertionConsumerServiceUri(), new SessionId(state.getSessionId().getSessionId()), state.getTransactionSupportsEidas(), state.isRegistering(), successFromIdp.getIssuer(), state.getRelayState().orNull(), successFromIdp.getLevelOfAssurance(), matchingServiceEntityId, successFromIdp.getEncryptedMatchingDatasetAssertion(), authnStatementAssertion, successFromIdp.getPersistentId());
}
Also used : Cycle0And1MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState) SessionId(uk.gov.ida.hub.policy.domain.SessionId)

Aggregations

Cycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState)3 Test (org.junit.Test)2 PersistentIdBuilder.aPersistentId (uk.gov.ida.hub.policy.builder.domain.PersistentIdBuilder.aPersistentId)1 SuccessFromIdpBuilder.aSuccessFromIdp (uk.gov.ida.hub.policy.builder.domain.SuccessFromIdpBuilder.aSuccessFromIdp)1 PersistentId (uk.gov.ida.hub.policy.domain.PersistentId)1 ResponseFromHub (uk.gov.ida.hub.policy.domain.ResponseFromHub)1 SessionId (uk.gov.ida.hub.policy.domain.SessionId)1 StateController (uk.gov.ida.hub.policy.domain.StateController)1 SuccessFromIdp (uk.gov.ida.hub.policy.domain.SuccessFromIdp)1