Search in sources :

Example 71 with Assertion

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

the class IPAddressValidatorTest method validate_shouldNotThrowWhenSecondAttributeStatementContainsAnIPAddressAttribute.

@Test
public void validate_shouldNotThrowWhenSecondAttributeStatementContainsAnIPAddressAttribute() throws Exception {
    Assertion assertion = anAssertion().addAttributeStatement(anAttributeStatement().build()).addAttributeStatement(anAttributeStatement().addAttribute(IPAddressAttributeBuilder.anIPAddress().build()).build()).buildUnencrypted();
    validator.validate(assertion);
}
Also used : 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 72 with Assertion

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

the class IPAddressValidatorTest method validate_shouldNotThrowWhenFirstAttributeStatementContainsMultipleAttributesIncludingIPAddressAttribute.

@Test
public void validate_shouldNotThrowWhenFirstAttributeStatementContainsMultipleAttributesIncludingIPAddressAttribute() throws Exception {
    Assertion assertion = anAssertion().addAttributeStatement(anAttributeStatement().addAttribute(aPersonName_1_1().buildAsFirstname()).addAttribute(IPAddressAttributeBuilder.anIPAddress().build()).build()).buildUnencrypted();
    validator.validate(assertion);
}
Also used : 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 73 with Assertion

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

the class IPAddressValidatorTest method validate_shouldNotThrowWhenFirstAttributeStatementContainsAnIPAddressAttribute.

@Test
public void validate_shouldNotThrowWhenFirstAttributeStatementContainsAnIPAddressAttribute() throws Exception {
    Assertion assertion = anAssertion().addAttributeStatement(anAttributeStatement().addAttribute(IPAddressAttributeBuilder.anIPAddress().build()).build()).buildUnencrypted();
    validator.validate(assertion);
}
Also used : 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 74 with Assertion

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

the class IPAddressValidatorTest method validate_shouldThrowWhenAssertionContainsAttributeStatementsButNoIPAddressAttribute.

@Test
public void validate_shouldThrowWhenAssertionContainsAttributeStatementsButNoIPAddressAttribute() throws Exception {
    Assertion assertion = anAssertion().addAttributeStatement(anAttributeStatement().build()).buildUnencrypted();
    validateException(SamlTransformationErrorFactory.missingIPAddress(assertion.getID()), assertion);
}
Also used : 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 75 with Assertion

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

the class PassthroughAssertionUnmarshallerTest method transform_shouldThrowExceptionIfGpg45StatusIsNotRecognised.

@Test
public void transform_shouldThrowExceptionIfGpg45StatusIsNotRecognised() {
    Assertions.assertThrows(IllegalStateException.class, () -> {
        String gpg45Status = "status not known";
        Assertion theAssertion = givenAFraudEventAssertion(gpg45Status);
        unmarshaller.fromAssertion(theAssertion);
    });
}
Also used : AssertionBuilder.anAssertion(uk.gov.ida.saml.core.test.builders.AssertionBuilder.anAssertion) Assertion(org.opensaml.saml.saml2.core.Assertion) PassthroughAssertion(uk.gov.ida.saml.core.domain.PassthroughAssertion) Test(org.junit.jupiter.api.Test)

Aggregations

Assertion (org.opensaml.saml.saml2.core.Assertion)175 Test (org.junit.jupiter.api.Test)118 Response (org.opensaml.saml.saml2.core.Response)62 AssertionBuilder.anAssertion (uk.gov.ida.saml.core.test.builders.AssertionBuilder.anAssertion)61 EncryptedAssertion (org.opensaml.saml.saml2.core.EncryptedAssertion)58 AttributeStatement (org.opensaml.saml.saml2.core.AttributeStatement)43 Attribute (org.opensaml.saml.saml2.core.Attribute)25 DateTime (org.joda.time.DateTime)22 Element (org.w3c.dom.Element)22 NameID (org.opensaml.saml.saml2.core.NameID)20 XMLObject (org.opensaml.core.xml.XMLObject)19 PassthroughAssertion (uk.gov.ida.saml.core.domain.PassthroughAssertion)17 ValidatedResponse (uk.gov.ida.saml.security.validators.ValidatedResponse)15 Authentication (org.springframework.security.core.Authentication)14 SubjectConfirmation (org.opensaml.saml.saml2.core.SubjectConfirmation)13 Test (org.junit.Test)12 AuthnStatement (org.opensaml.saml.saml2.core.AuthnStatement)12 Conditions (org.opensaml.saml.saml2.core.Conditions)12 HashMap (java.util.HashMap)11 NameIDBuilder (org.opensaml.saml.saml2.core.impl.NameIDBuilder)11