Search in sources :

Example 1 with VerifiedAttributeLogData

use of uk.gov.ida.hub.samlengine.logging.data.VerifiedAttributeLogData in project verify-hub by alphagov.

the class VerifiedAttributesLoggerTest method shouldLogMiddleNamesNameHistory.

@Test
public void shouldLogMiddleNamesNameHistory() throws Exception {
    AttributeValue oldMiddleNamesAttributeValue = new PersonNameAttributeValueBuilder().withFrom(DateTime.parse("2000-12-31")).withTo(DateTime.now().minusDays(406)).withVerified(true).build();
    AttributeValue currentMiddleNamesAttributeValue = new PersonNameAttributeValueBuilder().withFrom(DateTime.now().minusDays(405)).withVerified(true).build();
    Attribute middleNamesAttribute = new AttributeBuilder().buildObject();
    middleNamesAttribute.setName(IdaConstants.Attributes_1_1.Middlename.NAME);
    middleNamesAttribute.getAttributeValues().add(oldMiddleNamesAttributeValue);
    middleNamesAttribute.getAttributeValues().add(currentMiddleNamesAttributeValue);
    List<Attribute> attributes = aMatchingDatasetAttributeStatement_1_1().withMiddleNames(middleNamesAttribute).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.Middlename.NAME)).isEqualTo(ImmutableList.of(new VerifiedAttributeLogData(true, "more than 405 days"), new VerifiedAttributeLogData(true, null)));
}
Also used : AttributeValue(org.opensaml.saml.saml2.core.AttributeValue) AttributeBuilder(org.opensaml.saml.saml2.core.impl.AttributeBuilder) Attribute(org.opensaml.saml.saml2.core.Attribute) AttributeStatementLogData(uk.gov.ida.hub.samlengine.logging.data.AttributeStatementLogData) PersonNameAttributeValueBuilder(uk.gov.ida.saml.core.test.builders.PersonNameAttributeValueBuilder) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) VerifiedAttributeLogData(uk.gov.ida.hub.samlengine.logging.data.VerifiedAttributeLogData) Test(org.junit.Test)

Example 2 with VerifiedAttributeLogData

use of uk.gov.ida.hub.samlengine.logging.data.VerifiedAttributeLogData 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(ImmutableList.of(new VerifiedAttributeLogData(true, null)));
}
Also used : AttributeValue(org.opensaml.saml.saml2.core.AttributeValue) AttributeBuilder(org.opensaml.saml.saml2.core.impl.AttributeBuilder) Attribute(org.opensaml.saml.saml2.core.Attribute) AttributeStatementLogData(uk.gov.ida.hub.samlengine.logging.data.AttributeStatementLogData) PersonNameAttributeValueBuilder(uk.gov.ida.saml.core.test.builders.PersonNameAttributeValueBuilder) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) VerifiedAttributeLogData(uk.gov.ida.hub.samlengine.logging.data.VerifiedAttributeLogData) Test(org.junit.Test)

Example 3 with VerifiedAttributeLogData

use of uk.gov.ida.hub.samlengine.logging.data.VerifiedAttributeLogData 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(ImmutableList.of(new VerifiedAttributeLogData(true, null)));
}
Also used : AttributeValue(org.opensaml.saml.saml2.core.AttributeValue) AddressAttributeValueBuilder_1_1(uk.gov.ida.saml.core.test.builders.AddressAttributeValueBuilder_1_1) AttributeBuilder(org.opensaml.saml.saml2.core.impl.AttributeBuilder) Attribute(org.opensaml.saml.saml2.core.Attribute) AttributeStatementLogData(uk.gov.ida.hub.samlengine.logging.data.AttributeStatementLogData) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) VerifiedAttributeLogData(uk.gov.ida.hub.samlengine.logging.data.VerifiedAttributeLogData) Test(org.junit.Test)

Example 4 with VerifiedAttributeLogData

use of uk.gov.ida.hub.samlengine.logging.data.VerifiedAttributeLogData in project verify-hub by alphagov.

the class VerifiedAttributesLoggerTest method shouldLogDateOfBirthHistory.

@Test
public void shouldLogDateOfBirthHistory() throws Exception {
    Attribute dateOfBirthAttribute = new AttributeBuilder().buildObject();
    dateOfBirthAttribute.setName(IdaConstants.Attributes_1_1.DateOfBirth.NAME);
    AttributeValue oldDateOfBirthAttributeValue = new DateAttributeValueBuilder().withTo(DateTime.now().minusDays(1)).withVerified(true).build();
    AttributeValue currentDateOfBirthAttributeValue = new DateAttributeValueBuilder().withTo(null).build();
    dateOfBirthAttribute.getAttributeValues().add(oldDateOfBirthAttributeValue);
    dateOfBirthAttribute.getAttributeValues().add(currentDateOfBirthAttributeValue);
    List<Attribute> attributes = aMatchingDatasetAttributeStatement_1_1().withDateOfBirth(dateOfBirthAttribute).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.DateOfBirth.NAME)).isEqualTo(ImmutableList.of(new VerifiedAttributeLogData(true, "less than 180 days"), new VerifiedAttributeLogData(false, null)));
}
Also used : AttributeBuilder(org.opensaml.saml.saml2.core.impl.AttributeBuilder) AttributeValue(org.opensaml.saml.saml2.core.AttributeValue) Attribute(org.opensaml.saml.saml2.core.Attribute) AttributeStatementLogData(uk.gov.ida.hub.samlengine.logging.data.AttributeStatementLogData) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) DateAttributeValueBuilder(uk.gov.ida.saml.core.test.builders.DateAttributeValueBuilder) VerifiedAttributeLogData(uk.gov.ida.hub.samlengine.logging.data.VerifiedAttributeLogData) Test(org.junit.Test)

Example 5 with VerifiedAttributeLogData

use of uk.gov.ida.hub.samlengine.logging.data.VerifiedAttributeLogData 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")));
}
Also used : AttributeValue(org.opensaml.saml.saml2.core.AttributeValue) AddressAttributeValueBuilder_1_1(uk.gov.ida.saml.core.test.builders.AddressAttributeValueBuilder_1_1) AttributeBuilder(org.opensaml.saml.saml2.core.impl.AttributeBuilder) Attribute(org.opensaml.saml.saml2.core.Attribute) AttributeStatementLogData(uk.gov.ida.hub.samlengine.logging.data.AttributeStatementLogData) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) VerifiedAttributeLogData(uk.gov.ida.hub.samlengine.logging.data.VerifiedAttributeLogData) Test(org.junit.Test)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)6 List (java.util.List)6 Test (org.junit.Test)6 Attribute (org.opensaml.saml.saml2.core.Attribute)6 AttributeValue (org.opensaml.saml.saml2.core.AttributeValue)6 AttributeBuilder (org.opensaml.saml.saml2.core.impl.AttributeBuilder)6 AttributeStatementLogData (uk.gov.ida.hub.samlengine.logging.data.AttributeStatementLogData)6 VerifiedAttributeLogData (uk.gov.ida.hub.samlengine.logging.data.VerifiedAttributeLogData)6 PersonNameAttributeValueBuilder (uk.gov.ida.saml.core.test.builders.PersonNameAttributeValueBuilder)3 AddressAttributeValueBuilder_1_1 (uk.gov.ida.saml.core.test.builders.AddressAttributeValueBuilder_1_1)2 DateAttributeValueBuilder (uk.gov.ida.saml.core.test.builders.DateAttributeValueBuilder)1