use of org.opensaml.saml2.core.Attribute in project verify-hub by alphagov.
the class MatchingDatasetAssertionValidatorTest method validate_shouldThrowExceptionWhenAttributeValueTypeIsValidButIncorrectForAttribute.
@Test
public void validate_shouldThrowExceptionWhenAttributeValueTypeIsValidButIncorrectForAttribute() {
Attribute attribute = aPersonName_1_1().addValue(aPersonNameValue().withFrom(null).build()).buildAsFirstname();
attribute.setName(IdaConstants.Attributes_1_1.DateOfBirth.NAME);
AttributeStatement attributeStatement = aMatchingDatasetAttributeStatement_1_1().withDateOfBirth(attribute).build();
Assertion matchingDatasetAssertion = anAssertion().addAttributeStatement(attributeStatement).buildUnencrypted();
validateFail(() -> validator.validate(matchingDatasetAssertion, RESPONSE_ISSUER_ID), attributeWithIncorrectType(IdaConstants.Attributes_1_1.DateOfBirth.NAME, Date.TYPE_NAME, PersonName.TYPE_NAME));
}
use of org.opensaml.saml2.core.Attribute in project verify-hub by alphagov.
the class MatchingDatasetAssertionValidatorTest method validate_shouldThrowExceptionWhenAttributeIsMissingValue.
@Test
public void validate_shouldThrowExceptionWhenAttributeIsMissingValue() {
Attribute attribute = aPersonName_1_1().buildAsFirstnameWithNoAttributeValues();
AttributeStatement attributeStatement = aMatchingDatasetAttributeStatement_1_1().withFirstname(attribute).build();
Assertion matchingDatasetAssertion = anAssertion().addAttributeStatement(attributeStatement).buildUnencrypted();
validateFail(() -> validator.validate(matchingDatasetAssertion, RESPONSE_ISSUER_ID), emptyAttribute("MDS_firstname"));
}
use of org.opensaml.saml2.core.Attribute in project verify-hub by alphagov.
the class AttributeQueryAttributeFactoryTest method createAttribute_shouldNotSetFriendlyName.
@Test
public void createAttribute_shouldNotSetFriendlyName() {
UserAccountCreationAttribute userAccountCreationAttribute = UserAccountCreationAttribute.CURRENT_ADDRESS;
Attribute attribute = attributeQueryAttributeFactory.createAttribute(userAccountCreationAttribute);
assertThat(attribute.getFriendlyName()).isNull();
}
use of org.opensaml.saml2.core.Attribute in project verify-hub by alphagov.
the class AuthnRequestFromRelyingPartyUnmarshallerTest method createApplicationVersionExtensions.
private Extensions createApplicationVersionExtensions(String version) throws Exception {
Extensions extensions = new ExtensionsBuilder().buildObject();
Attribute versionsAttribute = new AttributeBuilder().buildObject();
versionsAttribute.setName("Versions");
versionsAttribute.getAttributeValues().add(createApplicationVersion(version));
extensions.getUnknownXMLObjects().add(encrypter.encrypt(versionsAttribute));
return extensions;
}
use of org.opensaml.saml2.core.Attribute in project verify-hub by alphagov.
the class HubAssertionMarshallerTest method transform_shouldTransformLevelOfCycle3DataAssertion.
@Test
public void transform_shouldTransformLevelOfCycle3DataAssertion() {
String attributeName = "someName";
String value = "some value";
HubAssertion assertion = aHubAssertion().withCycle3Data(aCycle3Dataset().addCycle3Data(attributeName, value).build()).build();
Attribute expectedAttribute = aSimpleStringAttribute().build();
when(attributeFactory.createCycle3DataAttribute(attributeName, value)).thenReturn(expectedAttribute);
Assertion transformedAssertion = marshaller.toSaml(assertion);
List<AttributeStatement> attributeStatements = transformedAssertion.getAttributeStatements();
assertThat(attributeStatements.size()).isGreaterThan(0);
Attribute attribute = attributeStatements.get(0).getAttributes().get(0);
assertThat(attribute).isEqualTo(expectedAttribute);
}
Aggregations