use of uk.gov.ida.saml.hub.domain.HubAttributeQueryRequest in project verify-hub by alphagov.
the class HubAttributeQueryRequestToSamlAttributeQueryTransformerTest method transform_shouldSetAttributesToUserAccountCreationAttributes.
@Test
public void transform_shouldSetAttributesToUserAccountCreationAttributes() {
Attribute attribute1 = openSamlXmlObjectFactory.createAttribute();
Attribute attribute2 = openSamlXmlObjectFactory.createAttribute();
when(attributeQueryAttributeFactory.createAttribute(CURRENT_ADDRESS)).thenReturn(attribute1);
when(attributeQueryAttributeFactory.createAttribute(DATE_OF_BIRTH)).thenReturn(attribute2);
HubAttributeQueryRequest hubAttributeQueryRequest = aHubAttributeQueryRequest().addUserAccountCreationAttribute(CURRENT_ADDRESS).addUserAccountCreationAttribute(DATE_OF_BIRTH).build();
AttributeQuery transformedQuery = transformer.apply(hubAttributeQueryRequest);
List<Attribute> transformedQueryAttributes = transformedQuery.getAttributes();
assertThat(transformedQueryAttributes.size()).isEqualTo(2);
assertThat(transformedQueryAttributes).contains(attribute1);
assertThat(transformedQueryAttributes).contains(attribute2);
}
use of uk.gov.ida.saml.hub.domain.HubAttributeQueryRequest 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");
}
use of uk.gov.ida.saml.hub.domain.HubAttributeQueryRequest in project verify-hub by alphagov.
the class HubAttributeQueryRequestToSamlAttributeQueryTransformerTest method transform_shouldNotExplodeWhenUserAccountCreationAttributesAreAbsent.
@Test
public void transform_shouldNotExplodeWhenUserAccountCreationAttributesAreAbsent() {
HubAttributeQueryRequest hubAttributeQueryRequest = aHubAttributeQueryRequest().withoutUserAccountCreationAttributes().build();
AttributeQuery transformedQuery = transformer.apply(hubAttributeQueryRequest);
List<Attribute> transformedQueryAttributes = transformedQuery.getAttributes();
assertThat(transformedQueryAttributes.size()).isEqualTo(0);
}
use of uk.gov.ida.saml.hub.domain.HubAttributeQueryRequest in project verify-hub by alphagov.
the class HubAttributeQueryRequestToSamlAttributeQueryTransformerTest method transform_shouldProperlyTransform.
@Test
public void transform_shouldProperlyTransform() {
PersistentId persistentId = new PersistentId("default-name-id");
HubAttributeQueryRequest originalQuery = aHubAttributeQueryRequest().withId("originalId").withPersistentId(persistentId).build();
AttributeQuery transformedQuery = transformer.apply(originalQuery);
assertThat(transformedQuery.getID()).isEqualTo(originalQuery.getId());
assertThat(transformedQuery.getSubject().getNameID().getValue()).isEqualTo(persistentId.getNameId());
assertThat(transformedQuery.getIssuer().getValue()).isEqualTo(originalQuery.getIssuer());
assertThat(transformedQuery.getVersion()).isEqualTo(SAMLVersion.VERSION_20);
}
use of uk.gov.ida.saml.hub.domain.HubAttributeQueryRequest in project verify-hub by alphagov.
the class AttributeQueryGeneratorTest method handle_shouldDelegateToTransformerWithCorrectData.
@Test
public void handle_shouldDelegateToTransformerWithCorrectData() {
DateTimeFreezer.freezeTime();
HubAttributeQueryRequest hubAttributeQueryRequest = aHubAttributeQueryRequest();
attributeQueryGenerator.createAttributeQueryContainer(hubAttributeQueryRequest, URI.create("/dont_care"), MATCHING_SERVICE_ENTITY_ID, null, false);
verify(transformer).apply(hubAttributeQueryRequestCaptor.capture());
HubAttributeQueryRequest request = hubAttributeQueryRequestCaptor.getValue();
assertThat(request.getId()).isEqualTo(hubAttributeQueryRequest.getId());
assertThat(request.getEncryptedAuthnAssertion()).isEqualTo(hubAttributeQueryRequest.getEncryptedAuthnAssertion());
assertThat(request.getCycle3AttributeAssertion().isPresent()).isEqualTo(false);
assertThat(request.getIssueInstant()).isEqualTo(DateTime.now());
assertThat(request.getAssertionConsumerServiceUrl()).isEqualTo(hubAttributeQueryRequest.getAssertionConsumerServiceUrl());
assertThat(request.getAuthnRequestIssuerEntityId()).isEqualTo(hubAttributeQueryRequest.getAuthnRequestIssuerEntityId());
}
Aggregations