use of org.opensaml.saml2.core.Response in project verify-hub by alphagov.
the class IdpIdaStatusUnmarshallerTest method shouldMapSamlStatusDetailOfLoaPendingToAuthenticationPending.
@Test
public void shouldMapSamlStatusDetailOfLoaPendingToAuthenticationPending() throws Exception {
String pendingXml = readXmlFile("status-pending.xml");
Response pendingResponse = stringToOpenSamlObjectTransformer.apply(pendingXml);
IdpIdaStatus idpIdaStatus = getStatusFrom(pendingResponse);
assertThat(idpIdaStatus.getStatusCode()).isEqualTo(IdpIdaStatus.Status.AuthenticationPending);
}
use of org.opensaml.saml2.core.Response in project verify-hub by alphagov.
the class SamlMessageSenderHandlerTest method generateAuthnResponseFromHub_shouldAddExternalCommunicationEvent.
@Test
public void generateAuthnResponseFromHub_shouldAddExternalCommunicationEvent() throws Exception {
SessionId sessionId = SessionId.createNewSessionId();
String expectedSamlMessageId = UUID.randomUUID().toString();
Response openSamlResponse = setUpAuthnResponseFromHub(sessionId, expectedSamlMessageId);
SamlMessage authnResponse = samlMessageSenderHandler.generateAuthnResponseFromHub(sessionId, principalIpAddressAsSeenByHub);
assertThat(authnResponse.getSamlMessage()).isEqualTo(samlRequest);
assertThat(authnResponse.getPostEndpoint()).isEqualTo(postEndPoint.toString());
assertThat(authnResponse.getRegistration()).isNotPresent();
assertThat(authnResponse.getRelayState().isPresent()).isTrue();
assertThat(authnResponse.getRelayState().get()).isEqualTo(relayState.get());
assertThat(authnResponse.getSamlMessageType()).isEqualTo(SamlMessageType.SAML_RESPONSE);
verify(externalCommunicationEventLogger).logResponseFromHub(expectedSamlMessageId, sessionId, postEndPoint, principalIpAddressAsSeenByHub);
verify(protectiveMonitoringLogger).logAuthnResponse(openSamlResponse, Direction.OUTBOUND, SignatureStatus.VALID_SIGNATURE);
}
use of org.opensaml.saml2.core.Response in project verify-hub by alphagov.
the class SamlMessageSenderHandlerTest method generateErrorResponseFromHub_shouldThrowSamlTransformationException.
@Test
public void generateErrorResponseFromHub_shouldThrowSamlTransformationException() {
Assertions.assertThrows(SamlTransformationErrorException.class, () -> {
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);
});
}
use of org.opensaml.saml2.core.Response in project verify-hub by alphagov.
the class SamlMessageSenderHandlerTest method generateAuthResponseFromHub_shouldThrowSamlTransformationException.
@Test
public void generateAuthResponseFromHub_shouldThrowSamlTransformationException() {
Assertions.assertThrows(SamlTransformationErrorException.class, () -> {
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);
});
}
use of org.opensaml.saml2.core.Response in project verify-hub by alphagov.
the class SamlMessageSenderHandlerTest method setUpErrorResponseFromHub.
private Response setUpErrorResponseFromHub(SessionId sessionId, String expectedSamlMessageId) throws MarshallingException, SignatureException {
AuthnResponseFromHubContainerDto hubContainerDto = new AuthnResponseFromHubContainerDto(samlRequest, postEndPoint, relayState, expectedSamlMessageId);
when(sessionProxy.getErrorResponseFromHub(sessionId)).thenReturn(hubContainerDto);
Response openSamlResponse = aResponse().withId(expectedSamlMessageId).build();
when(responseTransformer.apply(anyString())).thenReturn(openSamlResponse);
return openSamlResponse;
}
Aggregations