Search in sources :

Example 66 with Response

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

the class EncryptedResponseFromMatchingServiceValidatorTest method validateIssuer_shouldDoNothingIfFormatAttributeIsMissing.

@Test
public void validateIssuer_shouldDoNothingIfFormatAttributeIsMissing() throws Exception {
    Issuer issuer = anIssuer().withFormat(null).build();
    Response response = aResponse().withIssuer(issuer).withStatus(happyStatus).build();
    validator.validate(response);
}
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)

Example 67 with Response

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

the class EncryptedResponseFromMatchingServiceValidatorTest method validateResponse_shouldThrowExceptionIfResponseHasUnencryptedAssertion.

@Test
public void validateResponse_shouldThrowExceptionIfResponseHasUnencryptedAssertion() throws Exception {
    Assertion assertion = anAssertion().buildUnencrypted();
    Response response = aResponse().withStatus(happyStatus).addAssertion(assertion).build();
    assertValidationFailure(response, unencryptedAssertion());
}
Also used : ResponseBuilder.aResponse(uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse) Response(org.opensaml.saml.saml2.core.Response) AssertionBuilder.anAssertion(uk.gov.ida.saml.core.test.builders.AssertionBuilder.anAssertion) Assertion(org.opensaml.saml.saml2.core.Assertion) Test(org.junit.jupiter.api.Test)

Example 68 with Response

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

the class EncryptedResponseFromMatchingServiceValidatorTest method validateResponse_shouldThrowExceptionForSuccessResponsesWithNoAssertions.

@Test
public void validateResponse_shouldThrowExceptionForSuccessResponsesWithNoAssertions() throws Exception {
    Response response = aResponse().withStatus(happyStatus).withNoDefaultAssertion().build();
    assertValidationFailure(response, missingSuccessUnEncryptedAssertions());
}
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 69 with Response

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

the class EncryptedResponseFromMatchingServiceValidatorTest method validate_shouldDoNothingIfAResponderStatusContainsASubStatusOfNoMatch.

@Test
public void validate_shouldDoNothingIfAResponderStatusContainsASubStatusOfNoMatch() throws Exception {
    Status status = createStatus(StatusCode.RESPONDER, createSubStatusCode(SamlStatusCode.NO_MATCH));
    Response response = aResponse().withStatus(status).withNoDefaultAssertion().build();
    validator.validate(response);
}
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 70 with Response

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

the class EncryptedResponseFromMatchingServiceValidatorTest method validate_shouldThrowExceptionIfSubStatusIsNull.

@Test
public void validate_shouldThrowExceptionIfSubStatusIsNull() throws Exception {
    Response response = aResponse().withStatus(createStatus(StatusCode.SUCCESS)).build();
    assertValidationFailure(response, SamlTransformationErrorFactory.missingSubStatus());
}
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)

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