Search in sources :

Example 1 with HubAssertion

use of uk.gov.ida.saml.core.domain.HubAssertion in project verify-hub by alphagov.

the class HubAssertionMarshallerTest method transform_shouldTransformAssertionSubjects.

@Test
public void transform_shouldTransformAssertionSubjects() {
    HubAssertion assertion = aHubAssertion().build();
    marshaller.toSaml(assertion);
    verify(outboundAssertionToSubjectTransformer).transform(assertion);
}
Also used : 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 2 with HubAssertion

use of uk.gov.ida.saml.core.domain.HubAssertion 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 3 with HubAssertion

use of uk.gov.ida.saml.core.domain.HubAssertion 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 4 with HubAssertion

use of uk.gov.ida.saml.core.domain.HubAssertion 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 5 with HubAssertion

use of uk.gov.ida.saml.core.domain.HubAssertion in project verify-hub by alphagov.

the class HubAttributeQueryRequestToSamlAttributeQueryTransformerTest method transform_shouldSetTheSPNameQualifierAndNameQualifierToValuesThatShouldntBeThereButCurrentlyHaveNoWhereBetterToBe.

@Test
public void transform_shouldSetTheSPNameQualifierAndNameQualifierToValuesThatShouldntBeThereButCurrentlyHaveNoWhereBetterToBe() {
    final String authnStatementAssertion = aPassthroughAssertion().withUnderlyingAssertion(ENCRYPTED_AUTHN_ASSERTION).buildAuthnStatementAssertionAsString();
    final HubAssertion cycle3DataAssertion = aHubAssertion().build();
    HubAttributeQueryRequest originalQuery = aHubAttributeQueryRequest().withEncryptedAuthnAssertion(authnStatementAssertion).withCycle3DataAssertion(cycle3DataAssertion).withAssertionConsumerServiceUrl(URI.create("/foo")).withAuthnRequestIssuerEntityId("authn-request-issuer").build();
    AttributeQuery transformedQuery = transformer.apply(originalQuery);
    NameID nameID = transformedQuery.getSubject().getNameID();
    assertThat(nameID.getSPNameQualifier()).isEqualTo("authn-request-issuer");
    assertThat(nameID.getNameQualifier()).isEqualTo("/foo");
}
Also used : AttributeQuery(org.opensaml.saml.saml2.core.AttributeQuery) NameID(org.opensaml.saml.saml2.core.NameID) HubAttributeQueryRequestBuilder.aHubAttributeQueryRequest(uk.gov.ida.saml.hub.test.builders.HubAttributeQueryRequestBuilder.aHubAttributeQueryRequest) HubAttributeQueryRequest(uk.gov.ida.saml.hub.domain.HubAttributeQueryRequest) 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)

Aggregations

HubAssertion (uk.gov.ida.saml.core.domain.HubAssertion)14 Test (org.junit.jupiter.api.Test)8 Assertion (org.opensaml.saml.saml2.core.Assertion)8 HubAssertionBuilder.aHubAssertion (uk.gov.ida.saml.core.test.builders.HubAssertionBuilder.aHubAssertion)8 AttributeQuery (org.opensaml.saml.saml2.core.AttributeQuery)3 AssertionRestrictions (uk.gov.ida.saml.core.domain.AssertionRestrictions)3 Cycle3Dataset (uk.gov.ida.saml.core.domain.Cycle3Dataset)3 Test (org.junit.Test)2 Attribute (org.opensaml.saml.saml2.core.Attribute)2 AttributeStatement (org.opensaml.saml.saml2.core.AttributeStatement)2 EncryptedAssertion (org.opensaml.saml.saml2.core.EncryptedAssertion)2 Issuer (org.opensaml.saml.saml2.core.Issuer)2 NameID (org.opensaml.saml.saml2.core.NameID)2 EidasAttributeQueryRequestDtoBuilder.anEidasAttributeQueryRequestDto (uk.gov.ida.hub.samlengine.builders.EidasAttributeQueryRequestDtoBuilder.anEidasAttributeQueryRequestDto)2 EidasAttributeQueryRequestDto (uk.gov.ida.hub.samlengine.domain.EidasAttributeQueryRequestDto)2 PersistentId (uk.gov.ida.saml.core.domain.PersistentId)2 SimpleStringAttributeBuilder.aSimpleStringAttribute (uk.gov.ida.saml.core.test.builders.SimpleStringAttributeBuilder.aSimpleStringAttribute)2 HubAttributeQueryRequest (uk.gov.ida.saml.hub.domain.HubAttributeQueryRequest)2 HubEidasAttributeQueryRequest (uk.gov.ida.saml.hub.domain.HubEidasAttributeQueryRequest)2 HubAttributeQueryRequestBuilder.aHubAttributeQueryRequest (uk.gov.ida.saml.hub.test.builders.HubAttributeQueryRequestBuilder.aHubAttributeQueryRequest)2