Search in sources :

Example 21 with SamlRequestDto

use of uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto in project verify-hub by alphagov.

the class SamlMessageReceiverApiResourceTest method shouldErrorWhenSamlStringIsTooSmall.

@Test
public void shouldErrorWhenSamlStringIsTooSmall() throws Exception {
    SamlRequestDto authnRequestWrapper = new SamlRequestDto("too small", "relayState", "ipAddress");
    Response clientResponse = postSAML(authnRequestWrapper, Urls.SamlProxyUrls.SAML2_SSO_RECEIVER_API_ROOT);
    assertError(clientResponse, ExceptionType.INVALID_SAML);
}
Also used : Response(javax.ws.rs.core.Response) ResponseBuilder.aResponse(uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse) SamlRequestDto(uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto) Test(org.junit.Test)

Example 22 with SamlRequestDto

use of uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto in project verify-hub by alphagov.

the class SamlMessageReceiverApiResourceTest method createAuthnRequest.

private SamlRequestDto createAuthnRequest(String issuer, String relayState, String publicCert, String privateKey) throws JsonProcessingException {
    String id = AuthnRequestIdGenerator.generateRequestId();
    Optional<Boolean> forceAuthentication = Optional.of(false);
    Optional<Integer> assertionConsumerServiceIndex = Optional.of(1);
    Optional<URI> assertionConsumerServiceUrl = Optional.empty();
    String anAuthnRequest = authnRequestFactory.anAuthnRequest(id, issuer, forceAuthentication, assertionConsumerServiceUrl, assertionConsumerServiceIndex, publicCert, privateKey, Endpoints.SSO_REQUEST_ENDPOINT, Optional.empty());
    SamlRequestDto authnRequestWrapper = new SamlRequestDto(anAuthnRequest, relayState, "ipAddress");
    return authnRequestWrapper;
}
Also used : SamlRequestDto(uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto) URI(java.net.URI)

Aggregations

SamlRequestDto (uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto)22 Test (org.junit.Test)21 Response (javax.ws.rs.core.Response)18 ResponseBuilder.aResponse (uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse)14 SessionId (uk.gov.ida.common.SessionId)5 URI (java.net.URI)3 ResponseActionDto (uk.gov.ida.hub.samlproxy.domain.ResponseActionDto)2 AuthnRequest (org.opensaml.saml.saml2.core.AuthnRequest)1 AuthnRequestBuilder.anAuthnRequest (uk.gov.ida.saml.core.test.builders.AuthnRequestBuilder.anAuthnRequest)1