Search in sources :

Example 51 with Assertion

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

the class HubAssertionMarshallerTest method transform_shouldTransformAssertionIssuerInstance.

@Test
public void transform_shouldTransformAssertionIssuerInstance() {
    DateTime issueInstant = DateTime.parse("2012-12-31T12:34:56Z");
    HubAssertion assertion = aHubAssertion().withIssueInstant(issueInstant).build();
    Assertion transformedAssertion = marshaller.toSaml(assertion);
    assertThat(transformedAssertion.getIssueInstant()).isEqualTo(issueInstant);
}
Also used : HubAssertionBuilder.aHubAssertion(uk.gov.ida.saml.core.test.builders.HubAssertionBuilder.aHubAssertion) HubAssertion(uk.gov.ida.saml.core.domain.HubAssertion) Assertion(org.opensaml.saml.saml2.core.Assertion) DateTime(org.joda.time.DateTime) HubAssertionBuilder.aHubAssertion(uk.gov.ida.saml.core.test.builders.HubAssertionBuilder.aHubAssertion) HubAssertion(uk.gov.ida.saml.core.domain.HubAssertion) Test(org.junit.jupiter.api.Test)

Example 52 with Assertion

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

the class HubAssertionMarshallerTest method transform_shouldTransformAssertionIssuer.

@Test
public void transform_shouldTransformAssertionIssuer() {
    String assertionIssuerId = "assertion issuer";
    HubAssertion assertion = aHubAssertion().withIssuerId(assertionIssuerId).build();
    Assertion transformedAssertion = marshaller.toSaml(assertion);
    assertThat(transformedAssertion.getIssuer().getValue()).isEqualTo(assertionIssuerId);
}
Also used : HubAssertionBuilder.aHubAssertion(uk.gov.ida.saml.core.test.builders.HubAssertionBuilder.aHubAssertion) HubAssertion(uk.gov.ida.saml.core.domain.HubAssertion) Assertion(org.opensaml.saml.saml2.core.Assertion) HubAssertionBuilder.aHubAssertion(uk.gov.ida.saml.core.test.builders.HubAssertionBuilder.aHubAssertion) HubAssertion(uk.gov.ida.saml.core.domain.HubAssertion) Test(org.junit.jupiter.api.Test)

Example 53 with Assertion

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

the class HubAssertionMarshallerTest method transform_shouldTransformCycle3DataAssertion.

@Test
public void transform_shouldTransformCycle3DataAssertion() {
    String attributeName = "someName";
    String value = "some value";
    HubAssertion assertion = aHubAssertion().withCycle3Data(aCycle3Dataset().addCycle3Data(attributeName, value).build()).build();
    Attribute expectedAttribute = aSimpleStringAttribute().build();
    when(attributeFactory.createCycle3DataAttribute(attributeName, value)).thenReturn(expectedAttribute);
    Assertion transformedAssertion = marshaller.toSaml(assertion);
    List<AttributeStatement> attributeStatements = transformedAssertion.getAttributeStatements();
    assertThat(attributeStatements.size()).isGreaterThan(0);
    Attribute attribute = attributeStatements.get(0).getAttributes().get(0);
    assertThat(attribute).isEqualTo(expectedAttribute);
}
Also used : SimpleStringAttributeBuilder.aSimpleStringAttribute(uk.gov.ida.saml.core.test.builders.SimpleStringAttributeBuilder.aSimpleStringAttribute) Attribute(org.opensaml.saml.saml2.core.Attribute) AttributeStatement(org.opensaml.saml.saml2.core.AttributeStatement) HubAssertionBuilder.aHubAssertion(uk.gov.ida.saml.core.test.builders.HubAssertionBuilder.aHubAssertion) HubAssertion(uk.gov.ida.saml.core.domain.HubAssertion) Assertion(org.opensaml.saml.saml2.core.Assertion) HubAssertionBuilder.aHubAssertion(uk.gov.ida.saml.core.test.builders.HubAssertionBuilder.aHubAssertion) HubAssertion(uk.gov.ida.saml.core.domain.HubAssertion) Test(org.junit.jupiter.api.Test)

Example 54 with Assertion

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

the class DuplicateAssertionValidatorTest method validateMatchingDataSetAssertion_shouldPassIfTwoAssertionsHaveTheSameIdButTheFirstAssertionHasExpired.

@Test
public void validateMatchingDataSetAssertion_shouldPassIfTwoAssertionsHaveTheSameIdButTheFirstAssertionHasExpired() throws Exception {
    DateTime futureDate = DateTime.now().plusMinutes(6);
    Assertion assertion = createAssertion("expired-duplicate", futureDate);
    duplicateAssertionValidator.validateMatchingDataSetAssertion(assertion, "issuer");
    assertThat(duplicateIds.get("expired-duplicate")).isEqualTo(futureDate.toDateTime(UTC));
}
Also used : AssertionBuilder.anAssertion(uk.gov.ida.saml.core.test.builders.AssertionBuilder.anAssertion) Assertion(org.opensaml.saml.saml2.core.Assertion) DateTime(org.joda.time.DateTime) Test(org.junit.jupiter.api.Test)

Example 55 with Assertion

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

the class DuplicateAssertionValidatorTest method validateAuthnStatementAssertion_shouldPassIfTheAssertionIsNotADuplicateOfAPreviousOne.

@Test
public void validateAuthnStatementAssertion_shouldPassIfTheAssertionIsNotADuplicateOfAPreviousOne() throws Exception {
    Assertion assertion = anAssertion().withId("not-duplicate").buildUnencrypted();
    duplicateAssertionValidator.validateAuthnStatementAssertion(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)

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