Search in sources :

Example 16 with ResponseAction

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

the class SessionResourceAuthnResponseFromIdpIntegrationTests method responsePost_shouldHandleFraudResponse.

@Test
public void responsePost_shouldHandleFraudResponse() throws Exception {
    samlEngineStub.setupStubForIdpAuthnResponseTranslate(InboundResponseFromIdpDtoBuilder.fraudResponse(idpEntityId));
    Response response = postIdpResponse(sessionId, samlResponseDto);
    assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    ResponseAction expected = ResponseAction.other(sessionId, true);
    ResponseAction actualResponseAction = response.readEntity(ResponseAction.class);
    assertThat(actualResponseAction).isEqualToComparingFieldByField(expected);
}
Also used : Response(javax.ws.rs.core.Response) ResponseAction(uk.gov.ida.hub.policy.domain.ResponseAction) Test(org.junit.Test)

Example 17 with ResponseAction

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

the class SessionResourceAuthnResponseFromIdpIntegrationTests method responsePost_shouldHandleNoAuthnContextResponse.

@Test
public void responsePost_shouldHandleNoAuthnContextResponse() throws Exception {
    samlEngineStub.setupStubForIdpAuthnResponseTranslate(InboundResponseFromIdpDtoBuilder.noAuthnContextResponse(idpEntityId));
    Response response = postIdpResponse(sessionId, samlResponseDto);
    ResponseAction expected = ResponseAction.other(sessionId, true);
    ResponseAction actualResponseAction = response.readEntity(ResponseAction.class);
    assertThat(actualResponseAction).isEqualToComparingFieldByField(expected);
}
Also used : Response(javax.ws.rs.core.Response) ResponseAction(uk.gov.ida.hub.policy.domain.ResponseAction) Test(org.junit.Test)

Example 18 with ResponseAction

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

the class SessionResourceIntegrationTest method shouldUpdateSessionStateAndSendAnAttributeQueryRequestWhenASuccessResponseIsReceivedFromIdp.

@Test
public void shouldUpdateSessionStateAndSendAnAttributeQueryRequestWhenASuccessResponseIsReceivedFromIdp() throws JsonProcessingException {
    // Given
    SessionId sessionId = SessionId.createNewSessionId();
    Response sessionCreatedResponse = TestSessionResourceHelper.createSessionInIdpSelectedState(sessionId, rpEntityId, idpEntityId, client, policy.uri(UriBuilder.fromPath(TEST_SESSION_RESOURCE_PATH + IDP_SELECTED_STATE).build().toASCIIString()));
    assertThat(sessionCreatedResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    LevelOfAssurance loaAchieved = LevelOfAssurance.LEVEL_2;
    samlEngineStub.setupStubForIdpAuthnResponseTranslate(InboundResponseFromIdpDtoBuilder.successResponse(idpEntityId, loaAchieved));
    samlEngineStub.setupStubForAttributeQueryRequest(anAttributeQueryContainerDto().build());
    configStub.setUpStubForMatchingServiceRequest(idpEntityId, IdpSelectedStateBuilder.anIdpSelectedState().build().getMatchingServiceEntityId());
    samlSoapProxyProxyStub.setUpStubForSendHubMatchingServiceRequest(sessionId);
    // When
    URI idpResponseUri = UriBuilder.fromPath(Urls.PolicyUrls.IDP_AUTHN_RESPONSE_RESOURCE).build(sessionId);
    Response response = client.target(policy.uri(idpResponseUri.toASCIIString())).request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(aSamlAuthnResponseContainerDto().withSessionId(sessionId).build()));
    // Then
    ResponseAction expectedResult = ResponseAction.success(sessionId, true, loaAchieved);
    assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    ResponseAction actualResult = response.readEntity(ResponseAction.class);
    assertThat(actualResult).isEqualToComparingFieldByField(expectedResult);
    assertThat(getSessionStateName(sessionId)).isEqualTo(Cycle0And1MatchRequestSentState.class.getName());
}
Also used : Response(javax.ws.rs.core.Response) LevelOfAssurance(uk.gov.ida.hub.policy.domain.LevelOfAssurance) Cycle0And1MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState) SessionId(uk.gov.ida.hub.policy.domain.SessionId) URI(java.net.URI) ResponseAction(uk.gov.ida.hub.policy.domain.ResponseAction) Test(org.junit.Test)

Aggregations

ResponseAction (uk.gov.ida.hub.policy.domain.ResponseAction)18 Test (org.junit.Test)16 SamlAuthnResponseTranslatorDto (uk.gov.ida.hub.policy.contracts.SamlAuthnResponseTranslatorDto)10 InboundResponseFromIdpDto (uk.gov.ida.hub.policy.domain.InboundResponseFromIdpDto)9 Response (javax.ws.rs.core.Response)8 AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse (uk.gov.ida.hub.policy.builder.domain.AuthenticationErrorResponseBuilder.anAuthenticationErrorResponse)3 AuthenticationErrorResponse (uk.gov.ida.hub.policy.domain.AuthenticationErrorResponse)3 LevelOfAssurance (uk.gov.ida.hub.policy.domain.LevelOfAssurance)3 SessionId (uk.gov.ida.hub.policy.domain.SessionId)3 URI (java.net.URI)1 RequesterErrorResponseBuilder.aRequesterErrorResponse (uk.gov.ida.hub.policy.builder.domain.RequesterErrorResponseBuilder.aRequesterErrorResponse)1 AttributeQueryContainerDto (uk.gov.ida.hub.policy.contracts.AttributeQueryContainerDto)1 AttributeQueryRequestDto (uk.gov.ida.hub.policy.contracts.AttributeQueryRequestDto)1 RequesterErrorResponse (uk.gov.ida.hub.policy.domain.RequesterErrorResponse)1 SuccessFromIdp (uk.gov.ida.hub.policy.domain.SuccessFromIdp)1 IdpSelectedStateController (uk.gov.ida.hub.policy.domain.controller.IdpSelectedStateController)1 Cycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState)1 IdpSelectedState (uk.gov.ida.hub.policy.domain.state.IdpSelectedState)1