use of org.opensaml.saml.saml2.core.Attribute 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 org.opensaml.saml.saml2.core.Attribute 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 org.opensaml.saml.saml2.core.Attribute in project verify-hub by alphagov.
the class VerifiedAttributesLoggerTest method shouldLogCurrentAddressHistory.
@Test
public void shouldLogCurrentAddressHistory() throws Exception {
AttributeValue currentAddressAttributeValue = new AddressAttributeValueBuilder_1_1().withFrom(DateTime.now().minusYears(1)).withVerified(true).build();
Attribute currentAddressAttribute = new AttributeBuilder().buildObject();
currentAddressAttribute.setName(IdaConstants.Attributes_1_1.CurrentAddress.NAME);
currentAddressAttribute.getAttributeValues().add(currentAddressAttributeValue);
List<Attribute> attributes = aMatchingDatasetAttributeStatement_1_1().withCurrentAddress(currentAddressAttribute).build().getAttributes();
AttributeStatementLogData actual = mapper.readValue(formatAttributes("any-issuer", LEVEL_2, attributes), AttributeStatementLogData.class);
Map<String, List<VerifiedAttributeLogData>> attributesMap = actual.getAttributes();
assertThat(attributesMap.get(IdaConstants.Attributes_1_1.CurrentAddress.NAME)).isEqualTo(List.of(new VerifiedAttributeLogData(true, null)));
}
use of org.opensaml.saml.saml2.core.Attribute in project verify-hub by alphagov.
the class VerifiedAttributesLoggerTest method shouldLogSurnameNameHistory.
@Test
public void shouldLogSurnameNameHistory() throws Exception {
AttributeValue surnameAttributeValue = new PersonNameAttributeValueBuilder().withFrom(DateTime.parse("2000-12-31")).withVerified(true).build();
Attribute surnameAttribute = new AttributeBuilder().buildObject();
surnameAttribute.setName(IdaConstants.Attributes_1_1.Surname.NAME);
surnameAttribute.getAttributeValues().add(surnameAttributeValue);
List<Attribute> attributes = aMatchingDatasetAttributeStatement_1_1().withSurname(surnameAttribute).build().getAttributes();
AttributeStatementLogData actual = mapper.readValue(formatAttributes("any-issuer", LEVEL_2, attributes), AttributeStatementLogData.class);
Map<String, List<VerifiedAttributeLogData>> attributesMap = actual.getAttributes();
assertThat(attributesMap.get(IdaConstants.Attributes_1_1.Surname.NAME)).isEqualTo(List.of(new VerifiedAttributeLogData(true, null)));
}
use of org.opensaml.saml.saml2.core.Attribute in project verify-hub by alphagov.
the class VerifiedAttributesLoggerTest method shouldLogIssuerAndLevelOfAssurance.
@Test
public void shouldLogIssuerAndLevelOfAssurance() throws Exception {
List<Attribute> anyAttributesList = aMatchingDatasetAttributeStatement_1_1().build().getAttributes();
AttributeStatementLogData actual = mapper.readValue(formatAttributes("some-issuer", LEVEL_2, anyAttributesList), AttributeStatementLogData.class);
assertThat(actual.getIssuer()).isEqualTo("some-issuer");
assertThat(actual.getLevelOfAssurance()).isEqualTo(LEVEL_2);
}
Aggregations