Search in sources :

Example 1 with SamlValidationSpecification

use of uk.gov.ida.saml.core.validation.errors.SamlValidationSpecification in project verify-hub by alphagov.

the class SamlMessageSenderHandlerTest method generateErrorResponseFromHub_shouldThrowSamlTransformationException.

@Test(expected = SamlTransformationErrorException.class)
public void generateErrorResponseFromHub_shouldThrowSamlTransformationException() throws MarshallingException, SignatureException {
    SessionId sessionId = SessionId.createNewSessionId();
    String expectedSamlMessageId = UUID.randomUUID().toString();
    Response openSamlResponse = setUpErrorResponseFromHub(sessionId, expectedSamlMessageId);
    when(samlMessageSignatureValidator.validate(openSamlResponse, SPSSODescriptor.DEFAULT_ELEMENT_NAME)).thenReturn(SamlValidationResponse.anInvalidResponse(new SamlValidationSpecification("bad", true)));
    samlMessageSenderHandler.generateErrorResponseFromHub(sessionId, principalIpAddressAsSeenByHub);
}
Also used : Response(org.opensaml.saml.saml2.core.Response) ResponseBuilder.aResponse(uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse) SamlValidationResponse(uk.gov.ida.saml.core.validation.SamlValidationResponse) Matchers.anyString(org.mockito.Matchers.anyString) SessionId(uk.gov.ida.common.SessionId) SamlValidationSpecification(uk.gov.ida.saml.core.validation.errors.SamlValidationSpecification) Test(org.junit.Test)

Example 2 with SamlValidationSpecification

use of uk.gov.ida.saml.core.validation.errors.SamlValidationSpecification in project verify-hub by alphagov.

the class SamlMessageSenderHandlerTest method generateAuthRequestFromHub_shouldThrowSamlTransformationException.

@Test(expected = SamlTransformationErrorException.class)
public void generateAuthRequestFromHub_shouldThrowSamlTransformationException() throws MarshallingException, SignatureException {
    SessionId sessionId = SessionId.createNewSessionId();
    String expectedSamlMessageId = UUID.randomUUID().toString();
    when(sessionProxy.getAuthnRequestFromHub(sessionId)).thenReturn(new AuthnRequestFromHubContainerDto(samlRequest, postEndPoint, true));
    AuthnRequest authnRequest = anAuthnRequest().withId(expectedSamlMessageId).build();
    when(authnRequestTransformer.apply(samlRequest)).thenReturn(authnRequest);
    when(samlMessageSignatureValidator.validate(authnRequest, SPSSODescriptor.DEFAULT_ELEMENT_NAME)).thenReturn(SamlValidationResponse.anInvalidResponse(new SamlValidationSpecification("bad", true)));
    samlMessageSenderHandler.generateAuthnRequestFromHub(sessionId, principalIpAddressAsSeenByHub);
}
Also used : AuthnRequest(org.opensaml.saml.saml2.core.AuthnRequest) AuthnRequestBuilder.anAuthnRequest(uk.gov.ida.saml.core.test.builders.AuthnRequestBuilder.anAuthnRequest) Matchers.anyString(org.mockito.Matchers.anyString) AuthnRequestFromHubContainerDto(uk.gov.ida.hub.samlproxy.domain.AuthnRequestFromHubContainerDto) SessionId(uk.gov.ida.common.SessionId) SamlValidationSpecification(uk.gov.ida.saml.core.validation.errors.SamlValidationSpecification) Test(org.junit.Test)

Example 3 with SamlValidationSpecification

use of uk.gov.ida.saml.core.validation.errors.SamlValidationSpecification in project verify-hub by alphagov.

the class SamlMessageSenderHandlerTest method generateAuthResponseFromHub_shouldThrowSamlTransformationException.

@Test(expected = SamlTransformationErrorException.class)
public void generateAuthResponseFromHub_shouldThrowSamlTransformationException() throws MarshallingException, SignatureException {
    SessionId sessionId = SessionId.createNewSessionId();
    String expectedSamlMessageId = UUID.randomUUID().toString();
    Response openSamlResponse = setUpAuthnResponseFromHub(sessionId, expectedSamlMessageId);
    when(samlMessageSignatureValidator.validate(openSamlResponse, SPSSODescriptor.DEFAULT_ELEMENT_NAME)).thenReturn(SamlValidationResponse.anInvalidResponse(new SamlValidationSpecification("bad", true)));
    samlMessageSenderHandler.generateAuthnResponseFromHub(sessionId, principalIpAddressAsSeenByHub);
}
Also used : Response(org.opensaml.saml.saml2.core.Response) ResponseBuilder.aResponse(uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse) SamlValidationResponse(uk.gov.ida.saml.core.validation.SamlValidationResponse) Matchers.anyString(org.mockito.Matchers.anyString) SessionId(uk.gov.ida.common.SessionId) SamlValidationSpecification(uk.gov.ida.saml.core.validation.errors.SamlValidationSpecification) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 Matchers.anyString (org.mockito.Matchers.anyString)3 SessionId (uk.gov.ida.common.SessionId)3 SamlValidationSpecification (uk.gov.ida.saml.core.validation.errors.SamlValidationSpecification)3 Response (org.opensaml.saml.saml2.core.Response)2 ResponseBuilder.aResponse (uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse)2 SamlValidationResponse (uk.gov.ida.saml.core.validation.SamlValidationResponse)2 AuthnRequest (org.opensaml.saml.saml2.core.AuthnRequest)1 AuthnRequestFromHubContainerDto (uk.gov.ida.hub.samlproxy.domain.AuthnRequestFromHubContainerDto)1 AuthnRequestBuilder.anAuthnRequest (uk.gov.ida.saml.core.test.builders.AuthnRequestBuilder.anAuthnRequest)1