Search in sources :

Example 6 with ResponseFromHub

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

the class EidasSuccessfulMatchStateControllerTest method getPreparedResponse_shouldReturnResponse.

@Test
public void getPreparedResponse_shouldReturnResponse() {
    List<EidasCountryDto> enabledIdentityProviders = Arrays.asList(new EidasCountryDto("country-entity-id", "simple-id", true));
    ResponseFromHub expectedResponseFromHub = ResponseFromHubBuilder.aResponseFromHubDto().build();
    when(countriesService.getCountries(state.getSessionId())).thenReturn(enabledIdentityProviders);
    when(responseFromHubFactory.createSuccessResponseFromHub(state.getRequestId(), state.getMatchingServiceAssertion(), state.getRelayState(), state.getRequestIssuerEntityId(), state.getAssertionConsumerServiceUri())).thenReturn(expectedResponseFromHub);
    ResponseFromHub result = controller.getPreparedResponse();
    Assert.assertEquals(result, expectedResponseFromHub);
}
Also used : EidasCountryDto(uk.gov.ida.hub.policy.domain.EidasCountryDto) ResponseFromHub(uk.gov.ida.hub.policy.domain.ResponseFromHub) Test(org.junit.Test)

Example 7 with ResponseFromHub

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

the class ErrorStateControllerTests method shouldReturnErrorResponseWhenAskedAndUserAccountCreationFailedState.

@Test
public void shouldReturnErrorResponseWhenAskedAndUserAccountCreationFailedState() {
    UserAccountCreationFailedState state = UserAccountCreationFailedStateBuilder.aUserAccountCreationFailedState().build();
    StateController stateController = new UserAccountCreationFailedStateController(state, responseFromHubFactory);
    when(sessionRepository.getStateController(sessionId, ErrorResponsePreparedState.class)).thenReturn(stateController);
    ResponseFromHub responseFromHub = authnRequestFromTransactionHandler.getErrorResponseFromHub(sessionId);
    assertThat(responseFromHub.getStatus()).isEqualTo(TransactionIdaStatus.NoAuthenticationContext);
}
Also used : StateController(uk.gov.ida.hub.policy.domain.StateController) UserAccountCreationFailedState(uk.gov.ida.hub.policy.domain.state.UserAccountCreationFailedState) ResponseFromHub(uk.gov.ida.hub.policy.domain.ResponseFromHub) Test(org.junit.Test)

Example 8 with ResponseFromHub

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

the class ErrorStateControllerTests method shouldReturnErrorResponseWhenAskedAndInTimeoutState.

@Test
public void shouldReturnErrorResponseWhenAskedAndInTimeoutState() {
    TimeoutState state = TimeoutStateBuilder.aTimeoutState().build();
    StateController stateController = new TimeoutStateController(state, responseFromHubFactory);
    when(sessionRepository.getStateController(sessionId, ErrorResponsePreparedState.class)).thenReturn(stateController);
    ResponseFromHub responseFromHub = authnRequestFromTransactionHandler.getErrorResponseFromHub(sessionId);
    assertThat(responseFromHub.getStatus()).isEqualTo(TransactionIdaStatus.NoAuthenticationContext);
}
Also used : TimeoutState(uk.gov.ida.hub.policy.domain.state.TimeoutState) StateController(uk.gov.ida.hub.policy.domain.StateController) ResponseFromHub(uk.gov.ida.hub.policy.domain.ResponseFromHub) Test(org.junit.Test)

Example 9 with ResponseFromHub

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

the class ErrorStateControllerTests method shouldReturnErrorResponseWhenAskedAndInMatchingServiceRequestErrorState.

@Test
public void shouldReturnErrorResponseWhenAskedAndInMatchingServiceRequestErrorState() {
    MatchingServiceRequestErrorState state = MatchingServiceRequestErrorStateBuilder.aMatchingServiceRequestErrorState().build();
    StateController stateController = new MatchingServiceRequestErrorStateController(state, responseFromHubFactory);
    when(sessionRepository.getStateController(sessionId, ErrorResponsePreparedState.class)).thenReturn(stateController);
    ResponseFromHub responseFromHub = authnRequestFromTransactionHandler.getErrorResponseFromHub(sessionId);
    assertThat(responseFromHub.getStatus()).isEqualTo(TransactionIdaStatus.NoAuthenticationContext);
}
Also used : MatchingServiceRequestErrorState(uk.gov.ida.hub.policy.domain.state.MatchingServiceRequestErrorState) StateController(uk.gov.ida.hub.policy.domain.StateController) ResponseFromHub(uk.gov.ida.hub.policy.domain.ResponseFromHub) Test(org.junit.Test)

Example 10 with ResponseFromHub

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

the class ErrorStateControllerTests method shouldReturnErrorResponseWhenAskedAndInIdpSelectedState.

@Test
public void shouldReturnErrorResponseWhenAskedAndInIdpSelectedState() {
    IdpSelectedState state = IdpSelectedStateBuilder.anIdpSelectedState().build();
    StateController stateController = new IdpSelectedStateController(state, hubEventLogger, stateTransitionAction, identityProvidersConfigProxy, transactionsConfigProxy, responseFromHubFactory, policyConfiguration, assertionRestrictionFactory, matchingServiceConfigProxy);
    when(sessionRepository.getStateController(sessionId, ErrorResponsePreparedState.class)).thenReturn(stateController);
    ResponseFromHub responseFromHub = authnRequestFromTransactionHandler.getErrorResponseFromHub(sessionId);
    assertThat(responseFromHub.getStatus()).isEqualTo(TransactionIdaStatus.NoAuthenticationContext);
}
Also used : IdpSelectedState(uk.gov.ida.hub.policy.domain.state.IdpSelectedState) StateController(uk.gov.ida.hub.policy.domain.StateController) ResponseFromHub(uk.gov.ida.hub.policy.domain.ResponseFromHub) Test(org.junit.Test)

Aggregations

ResponseFromHub (uk.gov.ida.hub.policy.domain.ResponseFromHub)27 Test (org.junit.Test)25 StateController (uk.gov.ida.hub.policy.domain.StateController)16 SessionId (uk.gov.ida.hub.policy.domain.SessionId)5 AuthnResponseFromHubContainerDto (uk.gov.ida.hub.policy.contracts.AuthnResponseFromHubContainerDto)3 SessionId.createNewSessionId (uk.gov.ida.hub.policy.domain.SessionId.createNewSessionId)3 Cycle3MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState)3 Matchers.anyString (org.mockito.Matchers.anyString)2 AuthnResponseFromHubContainerDtoBuilder.anAuthnResponseFromHubContainerDto (uk.gov.ida.hub.policy.builder.AuthnResponseFromHubContainerDtoBuilder.anAuthnResponseFromHubContainerDto)2 Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState (uk.gov.ida.hub.policy.builder.state.Cycle3MatchRequestSentStateBuilder.aCycle3MatchRequestSentState)2 SamlMessageDto (uk.gov.ida.hub.policy.contracts.SamlMessageDto)2 RequestForErrorResponseFromHubDto (uk.gov.ida.hub.policy.contracts.RequestForErrorResponseFromHubDto)1 EidasCountryDto (uk.gov.ida.hub.policy.domain.EidasCountryDto)1 LevelOfAssurance (uk.gov.ida.hub.policy.domain.LevelOfAssurance)1 AuthnFailedErrorState (uk.gov.ida.hub.policy.domain.state.AuthnFailedErrorState)1 AwaitingCycle3DataState (uk.gov.ida.hub.policy.domain.state.AwaitingCycle3DataState)1 Cycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState)1 Cycle3DataInputCancelledState (uk.gov.ida.hub.policy.domain.state.Cycle3DataInputCancelledState)1 FraudEventDetectedState (uk.gov.ida.hub.policy.domain.state.FraudEventDetectedState)1 IdpSelectedState (uk.gov.ida.hub.policy.domain.state.IdpSelectedState)1