Search in sources :

Example 11 with SessionId

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

the class Cycle3MatchRequestSentStateControllerTest method shouldReturnWaitResponseWhenAskedAndInCycle3MatchRequestSentState.

@Test
public void shouldReturnWaitResponseWhenAskedAndInCycle3MatchRequestSentState() {
    final String requestId = "requestId";
    final SessionId sessionId = SessionId.createNewSessionId();
    Cycle3MatchRequestSentState state = aCycle3MatchRequestSentState().withSessionId(sessionId).withRequestId(requestId).build();
    Cycle3MatchRequestSentStateController controller = new Cycle3MatchRequestSentStateController(state, hubEventLogger, stateTransitionAction, policyConfiguration, null, null, transactionsConfigProxy, matchingServiceConfigProxy, assertionRestrictionFactory, attributeQueryService);
    when(policyConfiguration.getMatchingServiceResponseWaitPeriod()).thenReturn(Duration.standardMinutes(5));
    final ResponseProcessingDetails responseProcessingDetails = controller.getResponseProcessingDetails();
    assertThat(responseProcessingDetails.getResponseProcessingStatus()).isEqualTo(ResponseProcessingStatus.WAIT);
}
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) ResponseProcessingDetails(uk.gov.ida.hub.policy.domain.ResponseProcessingDetails) Test(org.junit.Test)

Example 12 with SessionId

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

the class EidasAwaitingCycle3DataStateControllerTest method handleCancellation.

@Test
public void handleCancellation() {
    doNothing().when(hubEventLogger).logCycle3DataInputCancelled(state.getSessionId(), state.getRequestIssuerEntityId(), state.getSessionExpiryTimestamp(), state.getRequestId());
    final Cycle3DataInputCancelledState expectedState = new Cycle3DataInputCancelledState(state.getRequestId(), state.getSessionExpiryTimestamp(), state.getRelayState(), state.getRequestIssuerEntityId(), state.getAssertionConsumerServiceUri(), new SessionId(state.getSessionId().getSessionId()), state.getTransactionSupportsEidas());
    controller.handleCancellation();
    verify(stateTransitionAction).transitionTo(expectedState);
}
Also used : Cycle3DataInputCancelledState(uk.gov.ida.hub.policy.domain.state.Cycle3DataInputCancelledState) SessionId(uk.gov.ida.hub.policy.domain.SessionId) Test(org.junit.Test)

Example 13 with SessionId

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

the class AuthnRequestFromTransactionResourceIntegrationTest method getSignInProcessDto_shouldReturnSignInDetailsDto.

@Test
public void getSignInProcessDto_shouldReturnSignInDetailsDto() {
    SessionId session = SessionId.createNewSessionId();
    TestSessionResourceHelper.createSessionInIdpSelectedState(session, samlResponse.getIssuer(), idpEntityId, client, buildUriForTestSession(IDP_SELECTED_STATE, session));
    Response response = getAuthRequestSignInProcess(session);
    assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    AuthnRequestSignInDetailsDto entity = response.readEntity(AuthnRequestSignInDetailsDto.class);
    assertThat(entity.getRequestIssuerId()).isEqualTo(samlResponse.getIssuer());
}
Also used : Response(javax.ws.rs.core.Response) AuthnRequestSignInDetailsDto(uk.gov.ida.hub.policy.domain.AuthnRequestSignInDetailsDto) SessionId(uk.gov.ida.hub.policy.domain.SessionId) Test(org.junit.Test)

Example 14 with SessionId

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

the class Cycle3DataResourceTest method should_ReturnSuccessWhenDataSubmitted.

@Test
public void should_ReturnSuccessWhenDataSubmitted() throws JsonProcessingException {
    // Given
    SessionId sessionId = SessionIdBuilder.aSessionId().build();
    String rpEntityId = new Cycle3DTO(sessionId).getRequestIssuerId();
    String msaEntityId = new Cycle3DTO(sessionId).getMatchingServiceEntityId();
    Response sessionCreatedResponse = createSessionInAwaitingCycle3DataState(sessionId);
    assertThat(sessionCreatedResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    final Cycle3UserInput cycle3UserInput = new Cycle3UserInput("test-value", "principal-ip-address-seen-by-hub");
    samlEngineStub.setupStubForAttributeQueryRequest(AttributeQueryContainerDtoBuilder.anAttributeQueryContainerDto().build());
    configStub.setUpStubForMatchingServiceRequest(rpEntityId, msaEntityId);
    final MatchingProcessDto cycle3Attribute = new MatchingProcessDto(Optional.of("TUFTY_CLUB_CARD"));
    configStub.setUpStubForEnteringAwaitingCycle3DataState(rpEntityId, cycle3Attribute);
    samlSoapProxyProxyStub.setUpStubForSendHubMatchingServiceRequest(sessionId);
    // When
    postCycle3Data(sessionId, cycle3UserInput);
    // Then
    assertThat(getSessionStateName(sessionId)).isEqualTo(Cycle3MatchRequestSentState.class.getName());
}
Also used : Response(javax.ws.rs.core.Response) Cycle3DTO(uk.gov.ida.integrationtest.hub.policy.rest.Cycle3DTO) MatchingProcessDto(uk.gov.ida.hub.policy.domain.MatchingProcessDto) Cycle3UserInput(uk.gov.ida.hub.policy.domain.Cycle3UserInput) Cycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState) SessionId(uk.gov.ida.hub.policy.domain.SessionId) Test(org.junit.Test)

Example 15 with SessionId

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

the class Cycle3DataResourceTest method shouldUpdateSessionStateToCancelledCycle3InputStateWhenInputToCycle3IsCancelled.

@Test
public void shouldUpdateSessionStateToCancelledCycle3InputStateWhenInputToCycle3IsCancelled() throws JsonProcessingException {
    // Given
    SessionId sessionId = SessionIdBuilder.aSessionId().build();
    Response sessionCreatedResponse = createSessionInAwaitingCycle3DataState(sessionId);
    assertThat(sessionCreatedResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    // When
    cancelCycle3Data(sessionId);
    // Then
    assertThat(getSessionStateName(sessionId)).isEqualTo(Cycle3DataInputCancelledState.class.getName());
}
Also used : Response(javax.ws.rs.core.Response) Cycle3DataInputCancelledState(uk.gov.ida.hub.policy.domain.state.Cycle3DataInputCancelledState) SessionId(uk.gov.ida.hub.policy.domain.SessionId) 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