Search in sources :

Example 11 with HubAttributeQueryRequest

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

the class HubAttributeQueryRequestToSamlAttributeQueryTransformerTest method transform_shouldContainBothMdsAndAuthnAssertionsEncrypted.

@Test
public void transform_shouldContainBothMdsAndAuthnAssertionsEncrypted() {
    HubAttributeQueryRequest originalQuery = aHubAttributeQueryRequest().withEncryptedMatchingDatasetAssertion(ENCRYPTED_MDS_ASSERTION).withEncryptedAuthnAssertion(ENCRYPTED_AUTHN_ASSERTION).build();
    final EncryptedAssertion value1 = new EncryptedAssertionBuilder().buildObject();
    final EncryptedAssertion value2 = new EncryptedAssertionBuilder().buildObject();
    when(encryptedAssertionUnmarshaller.transform(ENCRYPTED_MDS_ASSERTION)).thenReturn(value1);
    when(encryptedAssertionUnmarshaller.transform(ENCRYPTED_AUTHN_ASSERTION)).thenReturn(value2);
    AttributeQuery transformedQuery = transformer.apply(originalQuery);
    List<XMLObject> encryptedAssertions = transformedQuery.getSubject().getSubjectConfirmations().get(0).getSubjectConfirmationData().getUnknownXMLObjects(EncryptedAssertion.DEFAULT_ELEMENT_NAME);
    assertThat(encryptedAssertions.size()).isEqualTo(2);
    assertThat(encryptedAssertions).contains(value1, value2);
}
Also used : AttributeQuery(org.opensaml.saml.saml2.core.AttributeQuery) EncryptedAssertion(org.opensaml.saml.saml2.core.EncryptedAssertion) EncryptedAssertionBuilder(org.opensaml.saml.saml2.core.impl.EncryptedAssertionBuilder) XMLObject(org.opensaml.core.xml.XMLObject) HubAttributeQueryRequestBuilder.aHubAttributeQueryRequest(uk.gov.ida.saml.hub.test.builders.HubAttributeQueryRequestBuilder.aHubAttributeQueryRequest) HubAttributeQueryRequest(uk.gov.ida.saml.hub.domain.HubAttributeQueryRequest) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)11 HubAttributeQueryRequest (uk.gov.ida.saml.hub.domain.HubAttributeQueryRequest)11 AttributeQuery (org.opensaml.saml.saml2.core.AttributeQuery)6 HubAttributeQueryRequestBuilder.aHubAttributeQueryRequest (uk.gov.ida.saml.hub.test.builders.HubAttributeQueryRequestBuilder.aHubAttributeQueryRequest)6 XMLObject (org.opensaml.core.xml.XMLObject)2 Attribute (org.opensaml.saml.saml2.core.Attribute)2 EncryptedAssertion (org.opensaml.saml.saml2.core.EncryptedAssertion)2 AttributeQueryContainerDto (uk.gov.ida.hub.samlengine.domain.AttributeQueryContainerDto)2 HubAssertion (uk.gov.ida.saml.core.domain.HubAssertion)2 HubAssertionBuilder.aHubAssertion (uk.gov.ida.saml.core.test.builders.HubAssertionBuilder.aHubAssertion)2 URI (java.net.URI)1 Assertion (org.opensaml.saml.saml2.core.Assertion)1 NameID (org.opensaml.saml.saml2.core.NameID)1 EncryptedAssertionBuilder (org.opensaml.saml.saml2.core.impl.EncryptedAssertionBuilder)1 Element (org.w3c.dom.Element)1 PersistentId (uk.gov.ida.saml.core.domain.PersistentId)1 PassthroughAssertionBuilder.aPassthroughAssertion (uk.gov.ida.saml.core.test.builders.PassthroughAssertionBuilder.aPassthroughAssertion)1