use of uk.gov.ida.common.SessionId in project verify-hub by alphagov.
the class SamlMessageReceiverApiResourceTest method shouldCreateSessionForAuthnRequest.
@Test
public void shouldCreateSessionForAuthnRequest() throws Exception {
SamlRequestDto authnRequestWrapper = createAuthnRequest(TEST_RP, "relayState", TEST_RP_PUBLIC_SIGNING_CERT, TEST_RP_PRIVATE_SIGNING_KEY);
configStubRule.setupStubForCertificates(TEST_RP);
SessionId sessionId = SessionId.createNewSessionId();
policyStubRule.stubCreateSession(sessionId);
Response clientResponse = postSAML(authnRequestWrapper, Urls.SamlProxyUrls.SAML2_SSO_RECEIVER_API_ROOT);
assertThat(clientResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
assertThat(clientResponse.readEntity(SessionId.class)).isEqualTo(sessionId);
}
use of uk.gov.ida.common.SessionId in project verify-hub by alphagov.
the class SamlMessageSenderApiResourceTest method sendJsonAuthnResponseFromHub_shouldErrorWhenAValidationFailureOccurs.
@Test
public void sendJsonAuthnResponseFromHub_shouldErrorWhenAValidationFailureOccurs() throws Exception {
String responseId = "my-request";
SessionId sessionId = SessionId.createNewSessionId();
URI nextLocationUri = URI.create("http://blah");
OutboundResponseFromHub authnResponseFromHub = anAuthnResponse().withInResponseTo(responseId).withIssuerId(HUB_ENTITY_ID).withTransactionIdaStatus(TransactionIdaStatus.Success).buildOutboundResponseFromHub();
AuthnResponseFromHubContainerDto invalidAuthnResponseFromHubContainerDto = new AuthnResponseFromHubContainerDto("something not valid", nextLocationUri, com.google.common.base.Optional.absent(), authnResponseFromHub.getId());
policyStubRule.anAuthnResponseFromHubToRp(sessionId, invalidAuthnResponseFromHubContainerDto);
javax.ws.rs.core.Response response = getResponseFromSamlProxy(Urls.SamlProxyUrls.SEND_RESPONSE_FROM_HUB_API_RESOURCE, sessionId);
assertThat(response.getStatus()).isEqualTo(500);
}
use of uk.gov.ida.common.SessionId in project verify-hub by alphagov.
the class SamlMessageSenderApiResourceTest method sendUnsignedJsonAuthnResponseFromHub_shouldRespondWithNextLocation.
@Test
public void sendUnsignedJsonAuthnResponseFromHub_shouldRespondWithNextLocation() throws Exception {
SessionId sessionId = SessionId.createNewSessionId();
URI nextLocationUri = URI.create("http://blah");
String requestId = UUID.randomUUID().toString();
Function<OutboundResponseFromHub, String> outboundResponseFromHubToStringTransformer = new HubTransformersFactory().getOutboundResponseFromHubToStringTransformer(new HardCodedKeyStore(HUB_ENTITY_ID), getKeyStore(), new IdpHardCodedEntityToEncryptForLocator(), SIGNATURE_ALGORITHM, DIGEST_ALGORITHM);
OutboundResponseFromHub authnResponseFromHub = anAuthnResponse().withInResponseTo(requestId).withIssuerId(HUB_ENTITY_ID).withTransactionIdaStatus(TransactionIdaStatus.Success).buildOutboundResponseFromHub();
String samlString = outboundResponseFromHubToStringTransformer.apply(authnResponseFromHub);
AuthnResponseFromHubContainerDto authnResponseFromHubContainerDto = new AuthnResponseFromHubContainerDto(samlString, nextLocationUri, com.google.common.base.Optional.absent(), authnResponseFromHub.getId());
policyStubRule.anAuthnResponseFromHubToRp(sessionId, authnResponseFromHubContainerDto);
javax.ws.rs.core.Response response = getResponseFromSamlProxy(Urls.SamlProxyUrls.SEND_RESPONSE_FROM_HUB_API_RESOURCE, sessionId);
assertThat(response.readEntity(SamlMessageSenderHandler.SamlMessage.class).getPostEndpoint()).isEqualTo(nextLocationUri.toASCIIString());
}
use of uk.gov.ida.common.SessionId in project verify-hub by alphagov.
the class CountryAuthnResponseTranslatorResourceTest method createAuthnResponseSignedByKeyPair.
private SamlAuthnResponseTranslatorDto createAuthnResponseSignedByKeyPair(String publicKey, String privateKey) throws Exception {
SessionId sessionId = SessionId.createNewSessionId();
String samlResponse = authnResponseFactory.aSamlResponseFromCountry("a-request", samlEngineAppRule.getCountryMetadataUri(), publicKey, privateKey, DESTINATION, SIGNATURE_ALGORITHM, DIGEST_ALGORITHM, EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES256_GCM, EidasAuthnContext.EIDAS_LOA_SUBSTANTIAL, DESTINATION, samlEngineAppRule.getCountryMetadataUri());
return new SamlAuthnResponseTranslatorDto(samlResponse, sessionId, "127.0.0.1", matchingServiceEntityId);
}
use of uk.gov.ida.common.SessionId in project verify-hub by alphagov.
the class CountryMetadataConsumerTest method shouldServeCountryMetadata.
@Test
public void shouldServeCountryMetadata() throws Exception {
// Given
SessionId sessionId = SessionId.createNewSessionId();
policyStubRule.receiveAuthnResponseFromCountry(sessionId.toString(), LEVEL_2);
String response = authnResponseFactory.aSamlResponseFromIdp("a-request", countryMetadata.getCountryMetadataUri(), idpSigningCert, idpSigningKey, "", SIGNATURE_ALGORITHM, DIGEST_ALGORITHM);
// When
ResponseActionDto post = postSAML(new SamlRequestDto(response, sessionId.getSessionId(), "127.0.0.1")).readEntity(ResponseActionDto.class);
// Then
assertThat(post.getSessionId()).isEqualTo(sessionId);
assertThat(post.getLoaAchieved()).isEqualTo(LEVEL_2);
}
Aggregations