Search in sources :

Example 11 with ResponseFromHub

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

the class ErrorStateControllerTests method shouldReturnErrorResponseWhenAskedAndInCycle3MatchRequestSentState.

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

Example 12 with ResponseFromHub

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

the class ErrorStateControllerTests method shouldReturnErrorResponseWhenAskedAndInRequesterErrorState.

@Test
public void shouldReturnErrorResponseWhenAskedAndInRequesterErrorState() {
    RequesterErrorState state = RequesterErrorStateBuilder.aRequesterErrorState().build();
    StateController stateController = new RequesterErrorStateController(state, responseFromHubFactory, stateTransitionAction, transactionsConfigProxy, identityProvidersConfigProxy, hubEventLogger);
    when(sessionRepository.getStateController(sessionId, ErrorResponsePreparedState.class)).thenReturn(stateController);
    ResponseFromHub responseFromHub = authnRequestFromTransactionHandler.getErrorResponseFromHub(sessionId);
    assertThat(responseFromHub.getStatus()).isEqualTo(TransactionIdaStatus.NoAuthenticationContext);
}
Also used : RequesterErrorState(uk.gov.ida.hub.policy.domain.state.RequesterErrorState) StateController(uk.gov.ida.hub.policy.domain.StateController) ResponseFromHub(uk.gov.ida.hub.policy.domain.ResponseFromHub) Test(org.junit.Test)

Example 13 with ResponseFromHub

use of uk.gov.ida.hub.policy.domain.ResponseFromHub 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 14 with ResponseFromHub

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

the class ErrorStateControllerTests method shouldReturnErrorResponseWhenAskedAndInUserAccountCreatedState.

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

Example 15 with ResponseFromHub

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

the class SessionServiceTest method sendErrorResponseFromHub_shouldReturnDtoWithSamlRequestPostLocationAndRelayState.

@Test
public void sendErrorResponseFromHub_shouldReturnDtoWithSamlRequestPostLocationAndRelayState() throws Exception {
    SessionId sessionId = createNewSessionId();
    when(sessionRepository.sessionExists(sessionId)).thenReturn(true);
    ResponseFromHub responseFromHub = aResponseFromHubDto().withRelayState("relayState").build();
    when(authnRequestHandler.getErrorResponseFromHub(sessionId)).thenReturn(responseFromHub);
    final SamlMessageDto samlMessageDto = new SamlMessageDto("saml");
    when(samlEngineProxy.generateErrorResponseFromHub(any())).thenReturn(samlMessageDto);
    AuthnResponseFromHubContainerDto dto = service.getRpErrorResponse(sessionId);
    assertThat(dto.getSamlResponse()).isEqualTo(samlMessageDto.getSamlMessage());
    assertThat(dto.getPostEndpoint()).isEqualTo(responseFromHub.getAssertionConsumerServiceUri());
    assertThat(dto.getRelayState()).isEqualTo(responseFromHub.getRelayState());
    assertThat(dto.getResponseId()).isEqualTo(responseFromHub.getResponseId());
}
Also used : AuthnResponseFromHubContainerDto(uk.gov.ida.hub.policy.contracts.AuthnResponseFromHubContainerDto) AuthnResponseFromHubContainerDtoBuilder.anAuthnResponseFromHubContainerDto(uk.gov.ida.hub.policy.builder.AuthnResponseFromHubContainerDtoBuilder.anAuthnResponseFromHubContainerDto) SamlMessageDto(uk.gov.ida.hub.policy.contracts.SamlMessageDto) SessionId(uk.gov.ida.hub.policy.domain.SessionId) SessionId.createNewSessionId(uk.gov.ida.hub.policy.domain.SessionId.createNewSessionId) 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