use of uk.gov.ida.hub.samlengine.logging.data.AttributeStatementLogData in project verify-hub by alphagov.
the class VerifiedAttributesLoggerTest method shouldLogPreviousAddressHistory.
@Test
public void shouldLogPreviousAddressHistory() throws Exception {
AttributeValue previousAddressAttributeValue = new AddressAttributeValueBuilder_1_1().withFrom(DateTime.now().minusYears(10)).withTo(DateTime.now().minusYears(1)).withVerified(false).build();
Attribute previousAddressAttribute = new AttributeBuilder().buildObject();
previousAddressAttribute.setName(IdaConstants.Attributes_1_1.PreviousAddress.NAME);
previousAddressAttribute.getAttributeValues().add(previousAddressAttributeValue);
List<Attribute> attributes = aMatchingDatasetAttributeStatement_1_1().addPreviousAddress(previousAddressAttribute).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.PreviousAddress.NAME)).isEqualTo(ImmutableList.of(new VerifiedAttributeLogData(false, "more than 180 days")));
}
use of uk.gov.ida.hub.samlengine.logging.data.AttributeStatementLogData in project verify-hub by alphagov.
the class VerifiedAttributesLoggerTest method shouldLogFirstNameHistory.
@Test
public void shouldLogFirstNameHistory() throws Exception {
AttributeValue oldFirstNameAttributeValue = new PersonNameAttributeValueBuilder().withTo(DateTime.now().minusDays(181)).withVerified(true).build();
AttributeValue currentFirstNameAttributeValue = new PersonNameAttributeValueBuilder().withFrom(DateTime.now()).withTo(null).build();
Attribute firstNameAttribute = new AttributeBuilder().buildObject();
firstNameAttribute.setName(IdaConstants.Attributes_1_1.Firstname.NAME);
firstNameAttribute.getAttributeValues().add(oldFirstNameAttributeValue);
firstNameAttribute.getAttributeValues().add(currentFirstNameAttributeValue);
List<Attribute> attributes = aMatchingDatasetAttributeStatement_1_1().withFirstname(firstNameAttribute).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.Firstname.NAME)).isEqualTo(ImmutableList.of(new VerifiedAttributeLogData(true, "more than 180 days"), new VerifiedAttributeLogData(false, null)));
}
Aggregations