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);
}
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);
}
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());
}
Aggregations