use of uk.gov.ida.saml.hub.domain.HubAttributeQueryRequest in project verify-hub by alphagov.
the class AttributeQueryGeneratorTest method handle_shouldReturnErrorDtoWhenTransformFails.
@Test
public void handle_shouldReturnErrorDtoWhenTransformFails() {
Assertions.assertThrows(UnableToGenerateSamlException.class, () -> {
HubAttributeQueryRequest hubAttributeQueryRequest = aHubAttributeQueryRequest();
when(transformer.apply(hubAttributeQueryRequest)).thenThrow(new RuntimeException("failed to create attribute query request"));
attributeQueryGenerator.createAttributeQueryContainer(hubAttributeQueryRequest, MATCHING_SERVICE_ENTITY_ID);
});
}
use of uk.gov.ida.saml.hub.domain.HubAttributeQueryRequest in project verify-hub by alphagov.
the class AttributeQueryGeneratorTest method handle_shouldReturnDtoWithSamlMatchingServiceRequest.
// This test should move to the request builder?
@Test
public void handle_shouldReturnDtoWithSamlMatchingServiceRequest() {
HubAttributeQueryRequest hubAttributeQueryRequest = aHubAttributeQueryRequest();
Element transformedRequest = mock(Element.class);
when(transformer.apply(any(HubAttributeQueryRequest.class))).thenReturn(transformedRequest);
AttributeQueryContainerDto attributeQueryDto = attributeQueryGenerator.createAttributeQueryContainer(hubAttributeQueryRequest, URI.create("/dont_care"), MATCHING_SERVICE_ENTITY_ID, null, false);
assertThat(attributeQueryDto.getSamlRequest()).isEqualTo(XmlUtils.writeToString(transformedRequest));
}
use of uk.gov.ida.saml.hub.domain.HubAttributeQueryRequest in project verify-hub by alphagov.
the class AttributeQueryGeneratorTest method handle_shouldReturnDtoWithMatchingServiceEndpointReturnedFromConfig.
@Test
public void handle_shouldReturnDtoWithMatchingServiceEndpointReturnedFromConfig() {
HubAttributeQueryRequest hubAttributeQueryRequest = aHubAttributeQueryRequest();
URI attributeQueryUri = URI.create("/attribute-query-uri");
AttributeQueryContainerDto attributeQueryDto = attributeQueryGenerator.createAttributeQueryContainer(hubAttributeQueryRequest, attributeQueryUri, MATCHING_SERVICE_ENTITY_ID, null, false);
assertThat(attributeQueryDto.getMatchingServiceUri()).isEqualTo(attributeQueryUri);
}
use of uk.gov.ida.saml.hub.domain.HubAttributeQueryRequest in project verify-hub by alphagov.
the class AttributeQueryGeneratorTest method handle_shouldSetEntityToEncryptFor.
@Test
public void handle_shouldSetEntityToEncryptFor() {
HubAttributeQueryRequest hubAttributeQueryRequest = aHubAttributeQueryRequest();
when(transformer.apply(any(HubAttributeQueryRequest.class))).thenThrow(new RuntimeException("Avoid NullPointerException later."));
try {
attributeQueryGenerator.createAttributeQueryContainer(hubAttributeQueryRequest, URI.create("/dont_care"), MATCHING_SERVICE_ENTITY_ID, null, false);
fail("Should have thrown exception.");
} catch (RuntimeException e) {
assertThat(e).hasMessage("Avoid NullPointerException later.");
}
verify(entityToEncryptForLocator).addEntityIdForRequestId(hubAttributeQueryRequest.getId(), MATCHING_SERVICE_ENTITY_ID);
verify(entityToEncryptForLocator).removeEntityIdForRequestId(hubAttributeQueryRequest.getId());
}
use of uk.gov.ida.saml.hub.domain.HubAttributeQueryRequest in project verify-hub by alphagov.
the class HubAttributeQueryRequestToSamlAttributeQueryTransformerTest method transform_shouldOnlyIncludeCycle3Unencrypted.
@Test
public void transform_shouldOnlyIncludeCycle3Unencrypted() {
final HubAssertion cycle3DataAssertion = aHubAssertion().build();
HubAttributeQueryRequest originalQuery = aHubAttributeQueryRequest().withCycle3DataAssertion(cycle3DataAssertion).build();
AttributeQuery transformedQuery = transformer.apply(originalQuery);
List<XMLObject> unknownXMLObjects = transformedQuery.getSubject().getSubjectConfirmations().get(0).getSubjectConfirmationData().getUnknownXMLObjects(Assertion.DEFAULT_ELEMENT_NAME);
assertThat(unknownXMLObjects.size()).isEqualTo(1);
assertThat(((Assertion) unknownXMLObjects.get(0)).getID()).isEqualTo(cycle3DataAssertion.getId());
}
Aggregations