use of uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto in project verify-hub by alphagov.
the class SamlMessageReceiverApiResourceTest method shouldReturn400IfAuthnResponseIsSignedByAnRp.
@Test
public void shouldReturn400IfAuthnResponseIsSignedByAnRp() throws Exception {
final String samlResponse = authnResponseFactory.aSamlResponseFromIdp(TEST_RP, TEST_RP_PUBLIC_SIGNING_CERT, TEST_RP_PRIVATE_SIGNING_KEY, Endpoints.SSO_RESPONSE_ENDPOINT, SIGNATURE_ALGORITHM, DIGEST_ALGORITHM);
SamlRequestDto authnResponse = new SamlRequestDto(samlResponse, "sessionId", "127.0.0.1");
final Response response = postSAML(authnResponse, Urls.SamlProxyUrls.SAML2_SSO_RECEIVER_API_RESOURCE);
assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_BAD_REQUEST);
}
use of uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto in project verify-hub by alphagov.
the class SamlMessageReceiverApiResourceTest method shouldCreateSessionForAuthnRequest.
@Test
public void shouldCreateSessionForAuthnRequest() throws Exception {
SamlRequestDto authnRequestWrapper = createAuthnRequest(TEST_RP, "relayState", TEST_RP_PUBLIC_SIGNING_CERT, TEST_RP_PRIVATE_SIGNING_KEY);
configStubRule.setupStubForCertificates(TEST_RP);
SessionId sessionId = SessionId.createNewSessionId();
policyStubRule.stubCreateSession(sessionId);
Response clientResponse = postSAML(authnRequestWrapper, Urls.SamlProxyUrls.SAML2_SSO_RECEIVER_API_ROOT);
assertThat(clientResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
assertThat(clientResponse.readEntity(SessionId.class)).isEqualTo(sessionId);
}
use of uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto in project verify-hub by alphagov.
the class SamlMessageReceiverApiResourceTest method responsePost_shouldRespondWithSuccessWhenPolicyRespondsWithSuccess.
@Test
public void responsePost_shouldRespondWithSuccessWhenPolicyRespondsWithSuccess() throws Exception {
String sessionId = UUID.randomUUID().toString();
policyStubRule.receiveAuthnResponseFromIdp(sessionId, LevelOfAssurance.LEVEL_2);
final String samlResponse = authnResponseFactory.aSamlResponseFromIdp(STUB_IDP_ONE, STUB_IDP_PUBLIC_PRIMARY_CERT, STUB_IDP_PUBLIC_PRIMARY_PRIVATE_KEY, Endpoints.SSO_RESPONSE_ENDPOINT, SIGNATURE_ALGORITHM, DIGEST_ALGORITHM);
SamlRequestDto authnResponse = new SamlRequestDto(samlResponse, sessionId, "127.0.0.1");
final Response response = postSAML(authnResponse, Urls.SamlProxyUrls.SAML2_SSO_RECEIVER_API_RESOURCE);
assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
}
use of uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto in project verify-hub by alphagov.
the class SamlMessageReceiverApiResourceTest method shouldReturn400IfAuthnRequestIsSignedByAnIdp.
@Test
public void shouldReturn400IfAuthnRequestIsSignedByAnIdp() throws Exception {
SamlRequestDto authnRequest = createAuthnRequest(STUB_IDP_ONE, "relayState", STUB_IDP_PUBLIC_PRIMARY_CERT, STUB_IDP_PUBLIC_PRIMARY_PRIVATE_KEY);
configStubRule.setupStubForNonExistentSigningCertificates(STUB_IDP_ONE);
Response clientResponse = postSAML(authnRequest, Urls.SamlProxyUrls.SAML2_SSO_RECEIVER_API_ROOT);
assertThat(clientResponse.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
}
use of uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto in project verify-hub by alphagov.
the class SamlMessageReceiverApiResourceTest method shouldErrorWhenAuthnRequestIsNotSigned.
@Test
public void shouldErrorWhenAuthnRequestIsNotSigned() throws Exception {
AuthnRequest authnRequest = anAuthnRequest().withIssuer(anIssuer().withIssuerId(TEST_RP).build()).withDestination(Endpoints.SSO_REQUEST_ENDPOINT).withId(AuthnRequestIdGenerator.generateRequestId()).withoutSignatureElement().build();
SamlRequestDto authnRequestWrapper = new SamlRequestDto(authnRequestToStringTransformer.apply(authnRequest), "relayState", "ipAddress");
Response clientResponse = postSAML(authnRequestWrapper, Urls.SamlProxyUrls.SAML2_SSO_RECEIVER_API_ROOT);
assertError(clientResponse, ExceptionType.INVALID_SAML);
}
Aggregations