Search in sources :

Example 6 with IdaAuthnRequestFromHub

use of uk.gov.ida.saml.hub.domain.IdaAuthnRequestFromHub in project verify-hub by alphagov.

the class SamlMessageSenderApiResourceTest method sendJsonAuthnRequestFromHub_shouldRespondWithNextLocation.

@Test
public void sendJsonAuthnRequestFromHub_shouldRespondWithNextLocation() throws Exception {
    SessionId sessionId = SessionId.createNewSessionId();
    URI nextLocationUri = URI.create("http://blah");
    IdaAuthnRequestFromHub authnRequestFromHub = anIdaAuthnRequest().withIssuer(HUB_ENTITY_ID).buildFromHub();
    Function<IdaAuthnRequestFromHub, String> idaAuthnRequestFromHubToStringTransformer = new HubTransformersFactory().getIdaAuthnRequestFromHubToStringTransformer(getKeyStore(), SIGNATURE_ALGORITHM, DIGEST_ALGORITHM);
    String samlString = idaAuthnRequestFromHubToStringTransformer.apply(authnRequestFromHub);
    policyStubRule.aValidAuthnRequestFromHubToIdp(sessionId, new AuthnRequestFromHubContainerDto(samlString, nextLocationUri, false));
    Response response = getResponseFromSamlProxy(Urls.SamlProxyUrls.SEND_AUTHN_REQUEST_API_RESOURCE, sessionId);
    assertThat(response.readEntity(SamlMessageSenderHandler.SamlMessage.class).getPostEndpoint()).isEqualTo(nextLocationUri.toASCIIString());
}
Also used : ResponseForHubBuilder.anAuthnResponse(uk.gov.ida.saml.core.test.builders.ResponseForHubBuilder.anAuthnResponse) Response(javax.ws.rs.core.Response) IdaAuthnRequestFromHub(uk.gov.ida.saml.hub.domain.IdaAuthnRequestFromHub) HubTransformersFactory(uk.gov.ida.saml.hub.api.HubTransformersFactory) AuthnRequestFromHubContainerDto(uk.gov.ida.hub.samlproxy.domain.AuthnRequestFromHubContainerDto) SessionId(uk.gov.ida.common.SessionId) URI(java.net.URI) Test(org.junit.Test)

Aggregations

IdaAuthnRequestFromHub (uk.gov.ida.saml.hub.domain.IdaAuthnRequestFromHub)6 Test (org.junit.Test)5 IdaAuthnRequestFromHubDto (uk.gov.ida.hub.samlengine.contracts.IdaAuthnRequestFromHubDto)4 URI (java.net.URI)2 Response (javax.ws.rs.core.Response)1 SessionId (uk.gov.ida.common.SessionId)1 SamlRequestDto (uk.gov.ida.hub.samlengine.domain.SamlRequestDto)1 AuthnRequestFromHubContainerDto (uk.gov.ida.hub.samlproxy.domain.AuthnRequestFromHubContainerDto)1 ResponseForHubBuilder.anAuthnResponse (uk.gov.ida.saml.core.test.builders.ResponseForHubBuilder.anAuthnResponse)1 HubTransformersFactory (uk.gov.ida.saml.hub.api.HubTransformersFactory)1