use of uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto in project verify-hub by alphagov.
the class SamlMessageReceiverApiResourceTest method shouldErrorWhenRelayStateIsMoreThanEightyCharacters.
@Test
public void shouldErrorWhenRelayStateIsMoreThanEightyCharacters() throws Exception {
String longRelayState = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
SamlRequestDto authnRequestWrapper = createAuthnRequest(TEST_RP, longRelayState, TEST_PUBLIC_CERT, TEST_PRIVATE_KEY);
Response clientResponse = postSAML(authnRequestWrapper, Urls.SamlProxyUrls.SAML2_SSO_RECEIVER_API_ROOT);
assertError(clientResponse, ExceptionType.INVALID_SAML);
}
use of uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto 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);
}
use of uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto in project verify-hub by alphagov.
the class MetadataConsumerTests method shouldAllowRequestsWhenMetadataIsAvailableAndValid.
@Test
public void shouldAllowRequestsWhenMetadataIsAvailableAndValid() 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(TestEntityIds.STUB_IDP_ONE, STUB_IDP_PUBLIC_PRIMARY_CERT, STUB_IDP_PUBLIC_PRIMARY_PRIVATE_KEY, "", SIGNATURE_ALGORITHM, DIGEST_ALGORITHM);
ResponseActionDto post = postSAML(new SamlRequestDto(response, sessionId.getSessionId(), "127.0.0.1")).readEntity(ResponseActionDto.class);
assertThat(post.getSessionId()).isEqualTo(sessionId);
assertThat(post.getLoaAchieved()).isEqualTo(LEVEL_2);
}
use of uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto in project verify-hub by alphagov.
the class SamlMessageReceiverApiResourceEidasDisabledTest method responsePost_shouldRespondWith404_whenEidasIsDisabled.
@Test
public void responsePost_shouldRespondWith404_whenEidasIsDisabled() throws Exception {
String sessionId = UUID.randomUUID().toString();
policyStubRule.receiveAuthnResponseFromIdp(sessionId, LevelOfAssurance.LEVEL_2);
final String samlResponse = authnResponseFactory.aSamlResponseFromIdp(STUB_IDP_ONE, STUB_IDP_PUBLIC_PRIMARY_CERT, STUB_IDP_PUBLIC_PRIMARY_PRIVATE_KEY, Endpoints.SSO_RESPONSE_ENDPOINT, SIGNATURE_ALGORITHM, DIGEST_ALGORITHM);
SamlRequestDto authnResponse = new SamlRequestDto(samlResponse, sessionId, "127.0.0.1");
final Response response = postSAML(authnResponse, Urls.SamlProxyUrls.EIDAS_SAML2_SSO_RECEIVER_API_RESOURCE);
assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NOT_FOUND);
}
use of uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto in project verify-hub by alphagov.
the class SamlMessageReceiverApiResourceTest method shouldReturnBadRequestAndShouldAuditWhenSendingAnAuthnRequestFromAnIncorectIssuer.
@Test
public void shouldReturnBadRequestAndShouldAuditWhenSendingAnAuthnRequestFromAnIncorectIssuer() throws Exception {
SamlRequestDto authnRequest = createAuthnRequest(STUB_IDP_ONE, "relayState", TEST_PUBLIC_CERT, TEST_PRIVATE_KEY);
configStubRule.setupStubForNonExistentSigningCertificates(STUB_IDP_ONE);
eventSinkStubRule.register(Urls.HubSupportUrls.HUB_SUPPORT_EVENT_SINK_RESOURCE, Response.Status.OK.getStatusCode());
assertThat(eventSinkStubRule.getCountOfRequestsTo(Urls.HubSupportUrls.HUB_SUPPORT_EVENT_SINK_RESOURCE)).isEqualTo(0);
Response clientResponse = postSAML(authnRequest, Urls.SamlProxyUrls.SAML2_SSO_RECEIVER_API_ROOT);
assertThat(clientResponse.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
assertThat(eventSinkStubRule.getCountOfRequestsTo(Urls.HubSupportUrls.HUB_SUPPORT_EVENT_SINK_RESOURCE)).isEqualTo(1);
}
Aggregations