Search in sources :

Example 6 with SamlRequestWithAuthnRequestInformationDto

use of uk.gov.ida.hub.samlengine.contracts.SamlRequestWithAuthnRequestInformationDto in project verify-hub by alphagov.

the class RpAuthnRequestTranslatorResourceTest method shouldThrowExceptionWhenTheRequestIdIsADuplicate.

@Test
public void shouldThrowExceptionWhenTheRequestIdIsADuplicate() throws Exception {
    SamlRequestWithAuthnRequestInformationDto requestDto = aSamlAuthnRequest().withId("_iamtheoneandonlytheresnootherrequestididratherbe").withIssuer(TEST_RP).withPublicCert(TEST_RP_PUBLIC_SIGNING_CERT).withPrivateKey(TEST_RP_PRIVATE_SIGNING_KEY).build();
    post(requestDto, samlEngineAppRule.getUri(Urls.SamlEngineUrls.TRANSLATE_RP_AUTHN_REQUEST_RESOURCE));
    Response response = post(requestDto, samlEngineAppRule.getUri(Urls.SamlEngineUrls.TRANSLATE_RP_AUTHN_REQUEST_RESOURCE));
    assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
    ErrorStatusDto entity = response.readEntity(ErrorStatusDto.class);
    assertThat(entity.getExceptionType()).isEqualTo(ExceptionType.INVALID_SAML_DUPLICATE_REQUEST_ID);
}
Also used : SamlRequestWithAuthnRequestInformationDto(uk.gov.ida.hub.samlengine.contracts.SamlRequestWithAuthnRequestInformationDto) Response(javax.ws.rs.core.Response) ErrorStatusDto(uk.gov.ida.common.ErrorStatusDto) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 SamlRequestWithAuthnRequestInformationDto (uk.gov.ida.hub.samlengine.contracts.SamlRequestWithAuthnRequestInformationDto)6 Response (javax.ws.rs.core.Response)5 ErrorStatusDto (uk.gov.ida.common.ErrorStatusDto)3 TranslatedAuthnRequestDto (uk.gov.ida.hub.samlengine.contracts.TranslatedAuthnRequestDto)2 URI (java.net.URI)1 DateTime (org.joda.time.DateTime)1 AuthnRequest (org.opensaml.saml.saml2.core.AuthnRequest)1 DigestSHA256 (org.opensaml.xmlsec.algorithm.descriptors.DigestSHA256)1 Signature (org.opensaml.xmlsec.signature.Signature)1 SignatureImpl (org.opensaml.xmlsec.signature.impl.SignatureImpl)1 AuthnRequestFromRelyingPartyBuilder.anAuthnRequestFromRelyingParty (uk.gov.ida.hub.samlengine.builders.AuthnRequestFromRelyingPartyBuilder.anAuthnRequestFromRelyingParty)1 SignatureBuilder.aSignature (uk.gov.ida.saml.core.test.builders.SignatureBuilder.aSignature)1 AuthnRequestFromRelyingParty (uk.gov.ida.saml.hub.domain.AuthnRequestFromRelyingParty)1