use of uk.gov.ida.common.SessionId in project verify-hub by alphagov.
the class ExecuteAttributeQueryRequestTest method run_shouldCallInboundMessageValidatorWithAttributeQuery.
@Test
public void run_shouldCallInboundMessageValidatorWithAttributeQuery() throws Exception {
when(attributeQueryRequestClient.sendQuery(any(Element.class), anyString(), any(SessionId.class), any(URI.class))).thenReturn(matchingServiceResponse);
Response response = aResponse().build();
when(elementToResponseTransformer.apply(matchingServiceResponse)).thenReturn(response);
executeAttributeQueryRequest.execute(sessionId, attributeQueryContainerDto);
verify(matchingRequestSignatureValidator).validate(attributeQuery, AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME);
}
use of uk.gov.ida.common.SessionId in project verify-hub by alphagov.
the class ExecuteAttributeQueryRequestTest method run_shouldSendToTheCorrectUri.
@Test
public void run_shouldSendToTheCorrectUri() throws Exception {
when(attributeQueryRequestClient.sendQuery(any(Element.class), anyString(), any(SessionId.class), any(URI.class))).thenReturn(matchingServiceResponse);
when(elementToResponseTransformer.apply(matchingServiceResponse)).thenReturn(aResponse().build());
executeAttributeQueryRequest.execute(sessionId, attributeQueryContainerDto);
final ArgumentCaptor<URI> uriArgumentCaptor = ArgumentCaptor.forClass(URI.class);
verify(attributeQueryRequestClient).sendQuery(any(Element.class), anyString(), any(SessionId.class), uriArgumentCaptor.capture());
final URI uri = uriArgumentCaptor.getValue();
assertThat(uri).isEqualTo(matchingServiceUri);
}
use of uk.gov.ida.common.SessionId in project verify-hub by alphagov.
the class ExecuteAttributeQueryRequestTest method run_shouldUseCorrectSignatureValidators.
@Test
public void run_shouldUseCorrectSignatureValidators() throws Exception {
when(attributeQueryRequestClient.sendQuery(any(Element.class), anyString(), any(SessionId.class), any(URI.class))).thenReturn(matchingServiceResponse);
final Response response = aResponse().build();
when(elementToResponseTransformer.apply(matchingServiceResponse)).thenReturn(response);
executeAttributeQueryRequest.execute(sessionId, attributeQueryContainerDto);
verify(matchingRequestSignatureValidator).validate(attributeQuery, AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME);
verify(matchingResponseSignatureValidator).validate(response, AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME);
}
use of uk.gov.ida.common.SessionId in project verify-hub by alphagov.
the class CountryMetadataConsumerTest method shouldReturnErrorWhenValidatingEidasAuthnResponseContainingInvalidSignature.
@Test
public void shouldReturnErrorWhenValidatingEidasAuthnResponseContainingInvalidSignature() throws Exception {
// Given
SessionId sessionId = SessionId.createNewSessionId();
String response = authnResponseFactory.aSamlResponseFromIdp("a-request", countryMetadata.getCountryMetadataUri(), anotherIdpSigningCert, anotherIdpSigningKey, "", SIGNATURE_ALGORITHM, DIGEST_ALGORITHM);
// When
Response responseFromSamlProxy = postSAML(new SamlRequestDto(response, sessionId.getSessionId(), "127.0.0.1"));
// Then
assertThat(responseFromSamlProxy.getStatus()).isEqualTo(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
}
use of uk.gov.ida.common.SessionId in project verify-hub by alphagov.
the class MetadataConsumerTests method shouldReturnBadRequestWhenEntityIdCannotBeFoundInMetadata.
@Test
public void shouldReturnBadRequestWhenEntityIdCannotBeFoundInMetadata() throws Exception {
SessionId sessionId = SessionId.createNewSessionId();
policyStubRule.register(UriBuilder.fromPath(Urls.PolicyUrls.IDP_AUTHN_RESPONSE_RESOURCE).build(sessionId).getPath(), 200, ResponseActionDto.success(sessionId, true, LEVEL_2));
String response = authnResponseFactory.aSamlResponseFromIdp("non-existent-entity-id", STUB_IDP_PUBLIC_PRIMARY_CERT, STUB_IDP_PUBLIC_PRIMARY_PRIVATE_KEY, "", SIGNATURE_ALGORITHM, DIGEST_ALGORITHM);
SamlRequestDto samlRequestDto = new SamlRequestDto(response, sessionId.getSessionId(), "127.0.0.1");
assertThat(postSAML(samlRequestDto).getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
}
Aggregations