Search in sources :

Example 6 with IdpSelected

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

the class SessionTimeoutIntegrationTests method selectIdpShouldReturnErrorWhenSessionHasTimedOut.

@Test
public void selectIdpShouldReturnErrorWhenSessionHasTimedOut() {
    DateTimeFreezer.freezeTime(SOME_TIME);
    SessionId sessionId = client.target(policy.uri(Urls.PolicyUrls.NEW_SESSION_RESOURCE)).request().post(Entity.entity(samlRequest, MediaType.APPLICATION_JSON_TYPE), SessionId.class);
    DateTimeFreezer.freezeTime(SOME_TIME.plusMinutes(SOME_TIMEOUT + 1));
    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), SESSION_TIMEOUT);
}
Also used : IdpSelected(uk.gov.ida.hub.policy.domain.IdpSelected) SessionId(uk.gov.ida.hub.policy.domain.SessionId) URI(java.net.URI) Test(org.junit.Test)

Example 7 with IdpSelected

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

the class AuthnRequestFromTransactionResourceIntegrationTest method idpSelected_shouldThrowIfSessionInWrongState.

@Test
public void idpSelected_shouldThrowIfSessionInWrongState() {
    sessionId = SessionId.createNewSessionId();
    TestSessionResourceHelper.createSessionInSuccessfulMatchState(sessionId, transactionEntityId, idpEntityId, client, buildUriForTestSession(SUCCESSFUL_MATCH_STATE, sessionId));
    Response response = postIdpSelected(new IdpSelected("does-not-exist", principalIpAddress, REGISTERING, LEVEL_2));
    assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
    ErrorStatusDto error = response.readEntity(ErrorStatusDto.class);
    assertThat(error.getExceptionType()).isEqualTo(ExceptionType.INVALID_STATE);
}
Also used : Response(javax.ws.rs.core.Response) ErrorStatusDto(uk.gov.ida.common.ErrorStatusDto) IdpSelected(uk.gov.ida.hub.policy.domain.IdpSelected) Test(org.junit.Test)

Example 8 with IdpSelected

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

the class MatchingServiceResourcesIntegrationTest method anIdpIsSelectedForRegistration.

private void anIdpIsSelectedForRegistration(SessionId sessionId, String idpEntityId) {
    final URI policyUri = policy.uri(UriBuilder.fromPath(Urls.PolicyUrls.AUTHN_REQUEST_SELECT_IDP_RESOURCE).build(sessionId).getPath());
    postResponse(policyUri, new IdpSelected(idpEntityId, "this-is-an-ip-address", REGISTERING, LEVEL_2));
}
Also used : IdpSelected(uk.gov.ida.hub.policy.domain.IdpSelected) URI(java.net.URI)

Example 9 with IdpSelected

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

the class SessionResourceAuthnResponseFromIdpIntegrationTests method anIdpIsSelectedForRegistration.

private void anIdpIsSelectedForRegistration(SessionId sessionId, String idpEntityId) {
    final URI policyUri = policy.uri(UriBuilder.fromPath(Urls.PolicyUrls.AUTHN_REQUEST_SELECT_IDP_RESOURCE).build(sessionId).getPath());
    client.target(policyUri).request().post(Entity.entity(new IdpSelected(idpEntityId, "this-is-an-ip-address", REGISTERING, REQUESTED_LOA), MediaType.APPLICATION_JSON_TYPE));
}
Also used : IdpSelected(uk.gov.ida.hub.policy.domain.IdpSelected) URI(java.net.URI)

Example 10 with IdpSelected

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

the class SessionResourceIntegrationTest method anIdpIsSelectedForRegistration.

private void anIdpIsSelectedForRegistration(SessionId sessionId, String idpEntityId) {
    final URI policyUri = policy.uri(UriBuilder.fromPath(Urls.PolicyUrls.AUTHN_REQUEST_SELECT_IDP_RESOURCE).build(sessionId).getPath());
    post(policyUri, new IdpSelected(idpEntityId, "this-is-an-ip-address", REGISTERING, REQUESTED_LOA));
}
Also used : IdpSelected(uk.gov.ida.hub.policy.domain.IdpSelected) URI(java.net.URI)

Aggregations

IdpSelected (uk.gov.ida.hub.policy.domain.IdpSelected)11 Test (org.junit.Test)7 URI (java.net.URI)6 Response (javax.ws.rs.core.Response)4 SessionId (uk.gov.ida.hub.policy.domain.SessionId)3 ErrorStatusDto (uk.gov.ida.common.ErrorStatusDto)2 ValidationErrorMessage (io.dropwizard.jersey.validation.ValidationErrorMessage)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintStream (java.io.PrintStream)1