use of uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto in project verify-hub by alphagov.
the class SamlMessageReceiverApiResourceTest method shouldErrorWhenRelayStateIsInvalid.
@Test
public void shouldErrorWhenRelayStateIsInvalid() throws Exception {
SamlRequestDto authnRequestWrapper = createAuthnRequest(TEST_RP, INVALID_RELAY_STATE, TEST_PUBLIC_CERT, TEST_PRIVATE_KEY);
Response clientResponse = postSAML(authnRequestWrapper, Urls.SamlProxyUrls.SAML2_SSO_RECEIVER_API_ROOT);
assertError(clientResponse, ExceptionType.INVALID_SAML);
}
use of uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto in project verify-hub by alphagov.
the class SamlMessageReceiverApiResourceTest method shouldErrorWhenAuthnRequestIsInvalid.
@Test
public void shouldErrorWhenAuthnRequestIsInvalid() throws Exception {
String id = AuthnRequestIdGenerator.generateRequestId();
Optional<Boolean> forceAuthentication = Optional.of(false);
Optional<Integer> assertionConsumerServiceIndex = Optional.of(1);
String issuer = TEST_RP;
Optional<URI> assertionConsumerServiceUrl = Optional.empty();
String anAuthnRequest = authnRequestFactory.anInvalidAuthnRequest(id, issuer, forceAuthentication, assertionConsumerServiceUrl, assertionConsumerServiceIndex, TEST_PUBLIC_CERT, TEST_PRIVATE_KEY, Endpoints.SSO_REQUEST_ENDPOINT, Optional.empty());
SamlRequestDto authnRequestWrapper = new SamlRequestDto(anAuthnRequest, "relayState", "ipAddress");
configStubRule.setupStubForCertificates(issuer);
Response clientResponse = postSAML(authnRequestWrapper, Urls.SamlProxyUrls.SAML2_SSO_RECEIVER_API_ROOT);
assertError(clientResponse, ExceptionType.INVALID_SAML);
}
use of uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto in project verify-hub by alphagov.
the class SamlMessageReceiverApiResourceTest method shouldErrorWhenAProblemOccursWithinSessionProxy.
@Test
public void shouldErrorWhenAProblemOccursWithinSessionProxy() throws Exception {
SamlRequestDto authnRequestWrapper = createAuthnRequest(TEST_RP, RELAY_STATE, TEST_RP_PUBLIC_SIGNING_CERT, TEST_RP_PRIVATE_SIGNING_KEY);
configStubRule.setupStubForCertificates(TEST_RP);
policyStubRule.returnErrorForCreateSession();
Response clientResponse = postSAML(authnRequestWrapper, Urls.SamlProxyUrls.SAML2_SSO_RECEIVER_API_ROOT);
assertError(clientResponse, ExceptionType.NETWORK_ERROR);
}
use of uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto in project verify-hub by alphagov.
the class SamlMessageReceiverApiResourceTest method shouldReturnErrorWhenInvalidResponseFromIdp.
@Test
public void shouldReturnErrorWhenInvalidResponseFromIdp() throws Exception {
org.opensaml.saml.saml2.core.Response idpAuthnResponse = aResponse().withIssuer(anIssuer().withIssuerId(STUB_IDP_ONE).build()).withoutSignatureElement().build();
SamlRequestDto authnRequestWrapper = new SamlRequestDto(authnRequestToStringTransformer.apply(idpAuthnResponse), "relayState", "ipAddress");
Response clientResponse = postSAML(authnRequestWrapper, Urls.SamlProxyUrls.SAML2_SSO_RECEIVER_API_RESOURCE);
assertError(clientResponse, ExceptionType.INVALID_SAML);
}
use of uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto in project verify-hub by alphagov.
the class SamlMessageReceiverApiResourceTest method shouldErrorWhenNonBase64SamlRequest.
@Test
public void shouldErrorWhenNonBase64SamlRequest() throws Exception {
SamlRequestDto authnRequestWrapper = new SamlRequestDto(TestSamlRequestFactory.createNonBase64Request(), "relayState", "ipAddress");
Response clientResponse = postSAML(authnRequestWrapper, Urls.SamlProxyUrls.SAML2_SSO_RECEIVER_API_ROOT);
assertError(clientResponse, ExceptionType.INVALID_SAML);
}
Aggregations