use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class MatchingServiceResourcesIntegrationTest method isResponseFromHubReady_shouldThrowExceptionWhenMatchingServiceWaitPeriodHasBeenExceeded.
@Test
public void isResponseFromHubReady_shouldThrowExceptionWhenMatchingServiceWaitPeriodHasBeenExceeded() throws Exception {
final SessionId sessionId = aSessionIsCreated();
anIdpIsSelectedForRegistration(sessionId, idpEntityId);
anIdpAuthnRequestWasGenerated(sessionId);
anAuthnResponseFromIdpWasReceivedAndMatchingRequestSent(sessionId);
theMatchingServiceResponseTimeoutHasBeenExceeded();
URI uri = UriBuilder.fromPath(Urls.PolicyUrls.RESPONSE_PROCESSING_DETAILS_RESOURCE).build(sessionId);
Response response = getResponse(policy.uri(uri.toASCIIString()));
assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
ResponseProcessingDetails responseProcessingDetails = response.readEntity(ResponseProcessingDetails.class);
assertThat(responseProcessingDetails.getResponseProcessingStatus()).isEqualTo(ResponseProcessingStatus.SHOW_MATCHING_ERROR_PAGE);
assertThat(responseProcessingDetails.getSessionId()).isEqualTo(sessionId);
assertThat(getSessionStateName(sessionId)).isEqualTo(MatchingServiceRequestErrorState.class.getName());
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class RpErrorResponseFromHubIntegrationTest method shouldGenerateAnErrorAuthnResponseFromHub.
@Test
public void shouldGenerateAnErrorAuthnResponseFromHub() throws Exception {
final SessionId sessionId = aSessionIsCreated();
SamlMessageDto samlMessageDto = new SamlMessageDto("saml");
samlEngineStub.setUpStubForErrorResponseGenerate(samlMessageDto);
URI uri = UriBuilder.fromPath(Urls.PolicyUrls.RP_ERROR_RESPONSE_RESOURCE).build(sessionId.getSessionId());
Response response = get(uri);
assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
AuthnResponseFromHubContainerDto authnResponseFromHubContainerDto = response.readEntity(AuthnResponseFromHubContainerDto.class);
assertThat(authnResponseFromHubContainerDto.getSamlResponse()).isEqualTo(samlMessageDto.getSamlMessage());
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class SessionResourceIntegrationTest method getSessionShouldFailWhenSessionDoesNotExist.
@Test
public void getSessionShouldFailWhenSessionDoesNotExist() {
SessionId invalidSessionId = SessionId.createNewSessionId();
URI uri = UriBuilder.fromUri(Urls.PolicyUrls.SESSION_RESOURCE_ROOT).path(Urls.SharedUrls.SESSION_ID_PARAM_PATH).build(invalidSessionId);
checkException(get(uri), ExceptionType.SESSION_NOT_FOUND);
}
use of uk.gov.ida.hub.policy.domain.SessionId 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());
}
use of uk.gov.ida.hub.policy.domain.SessionId in project verify-hub by alphagov.
the class SessionTimeoutIntegrationTests method selectIdpShouldReturnErrorWhenSessionDoesNotExistInPolicy.
@Test
public void selectIdpShouldReturnErrorWhenSessionDoesNotExistInPolicy() {
final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
System.setOut(new PrintStream(outContent));
SessionId sessionId = SessionId.createNewSessionId();
URI uri = UriBuilder.fromPath(Urls.PolicyUrls.AUTHN_REQUEST_SELECT_IDP_RESOURCE).buildFromEncoded(sessionId);
confirmError(policy.uri(uri.getPath()), new IdpSelected(STUB_IDP_ONE, "some-ip-address", REGISTERING, REQUESTED_LOA), ExceptionType.SESSION_NOT_FOUND);
assertThatEventEmitterWritesToStandardOutput(outContent);
System.setOut(System.out);
}
Aggregations