Search in sources :

Example 71 with Response

use of org.opensaml.saml2.core.Response in project verify-hub by alphagov.

the class EncryptedResponseFromMatchingServiceValidatorTest method validate_shouldThrowExceptionIfIdIsMissing.

@Test
public void validate_shouldThrowExceptionIfIdIsMissing() throws Exception {
    Response response = aResponse().withId(null).build();
    assertValidationFailure(response, missingId());
}
Also used : ResponseBuilder.aResponse(uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse) Response(org.opensaml.saml.saml2.core.Response) Test(org.junit.jupiter.api.Test)

Example 72 with Response

use of org.opensaml.saml2.core.Response in project verify-hub by alphagov.

the class EncryptedResponseFromMatchingServiceValidatorTest method validateRequest_shouldThrowExceptionIfResponseDoesNotContainASignature.

@Test
public void validateRequest_shouldThrowExceptionIfResponseDoesNotContainASignature() throws Exception {
    Response response = aResponse().withoutSignatureElement().build();
    assertValidationFailure(response, missingSignature());
}
Also used : ResponseBuilder.aResponse(uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse) Response(org.opensaml.saml.saml2.core.Response) Test(org.junit.jupiter.api.Test)

Example 73 with Response

use of org.opensaml.saml2.core.Response in project verify-hub by alphagov.

the class EncryptedResponseFromMatchingServiceValidatorTest method validateResponse_shouldThrowExceptionForFailureResponsesWithAssertions.

@Test
public void validateResponse_shouldThrowExceptionForFailureResponsesWithAssertions() throws Exception {
    Status status = createStatus(StatusCode.RESPONDER, createSubStatusCode(SamlStatusCode.NO_MATCH));
    Response response = aResponse().withStatus(status).build();
    assertValidationFailure(response, nonSuccessHasUnEncryptedAssertions());
}
Also used : ResponseValidatorTestHelper.createStatus(uk.gov.ida.saml.hub.validators.response.helpers.ResponseValidatorTestHelper.createStatus) Status(org.opensaml.saml.saml2.core.Status) ResponseBuilder.aResponse(uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse) Response(org.opensaml.saml.saml2.core.Response) Test(org.junit.jupiter.api.Test)

Example 74 with Response

use of org.opensaml.saml2.core.Response in project verify-hub by alphagov.

the class EncryptedResponseFromMatchingServiceValidatorTest method validate_shouldThrowIfResponseContainsTooManyAssertions.

@Test
public void validate_shouldThrowIfResponseContainsTooManyAssertions() throws Exception {
    Response response = aResponse().withStatus(happyStatus).addEncryptedAssertion(anAssertion().build()).addEncryptedAssertion(anAssertion().build()).build();
    assertValidationFailure(response, unexpectedNumberOfAssertions(1, 2));
}
Also used : ResponseBuilder.aResponse(uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse) Response(org.opensaml.saml.saml2.core.Response) Test(org.junit.jupiter.api.Test)

Example 75 with Response

use of org.opensaml.saml2.core.Response in project verify-hub by alphagov.

the class EncryptedResponseFromMatchingServiceValidatorTest method validate_shouldThrowInvalidSamlExceptionIfIssuerIdIsMissing.

@Test
public void validate_shouldThrowInvalidSamlExceptionIfIssuerIdIsMissing() throws Exception {
    Issuer issuer = anIssuer().withIssuerId(null).build();
    Response response = aResponse().withIssuer(issuer).build();
    assertValidationFailure(response, emptyIssuer());
}
Also used : ResponseBuilder.aResponse(uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse) Response(org.opensaml.saml.saml2.core.Response) Issuer(org.opensaml.saml.saml2.core.Issuer) IssuerBuilder.anIssuer(uk.gov.ida.saml.core.test.builders.IssuerBuilder.anIssuer) Test(org.junit.jupiter.api.Test)

Aggregations

Response (org.opensaml.saml.saml2.core.Response)245 Test (org.junit.jupiter.api.Test)148 ResponseBuilder.aResponse (uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse)84 Assertion (org.opensaml.saml.saml2.core.Assertion)62 EncryptedAssertion (org.opensaml.saml.saml2.core.EncryptedAssertion)51 Element (org.w3c.dom.Element)44 Status (org.opensaml.saml.saml2.core.Status)37 DateTime (org.joda.time.DateTime)36 WSSecurityException (org.apache.wss4j.common.ext.WSSecurityException)31 Document (org.w3c.dom.Document)31 SamlAssertionWrapper (org.apache.wss4j.common.saml.SamlAssertionWrapper)26 SAMLCallback (org.apache.wss4j.common.saml.SAMLCallback)19 SubjectConfirmationDataBean (org.apache.wss4j.common.saml.bean.SubjectConfirmationDataBean)19 SamlValidationResponse (uk.gov.ida.saml.core.validation.SamlValidationResponse)19 IdpIdaStatus (uk.gov.ida.saml.hub.domain.IdpIdaStatus)18 Authentication (org.springframework.security.core.Authentication)16 ResponseValidatorTestHelper.createStatus (uk.gov.ida.saml.hub.validators.response.helpers.ResponseValidatorTestHelper.createStatus)16 Crypto (org.apache.wss4j.common.crypto.Crypto)15 NameID (org.opensaml.saml.saml2.core.NameID)14 AttributeStatement (org.opensaml.saml.saml2.core.AttributeStatement)13