Search in sources :

Example 1 with RequestForErrorResponseFromHubDto

use of uk.gov.ida.hub.samlengine.contracts.RequestForErrorResponseFromHubDto in project verify-hub by alphagov.

the class RpErrorResponseGeneratorResourceTest method shouldGenerateAnErrorResponseForAnRp.

@Test
public void shouldGenerateAnErrorResponseForAnRp() throws JsonProcessingException {
    RequestForErrorResponseFromHubDto requestForErrorResponseFromHubDto = aRequestForErrorResponseFromHubDto().build();
    configStub.signResponsesAndUseSamlStandard(requestForErrorResponseFromHubDto.getAuthnRequestIssuerEntityId());
    final URI uri = samlEngineAppRule.getUri(Urls.SamlEngineUrls.GENERATE_RP_ERROR_RESPONSE_RESOURCE);
    Response rpAuthnResponse = post(requestForErrorResponseFromHubDto, uri);
    assertThat(rpAuthnResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    SamlMessageDto samlMessageDto = rpAuthnResponse.readEntity(SamlMessageDto.class);
    assertThat(samlMessageDto.getSamlMessage()).isNotNull();
}
Also used : Response(javax.ws.rs.core.Response) SamlMessageDto(uk.gov.ida.hub.samlengine.domain.SamlMessageDto) RequestForErrorResponseFromHubDtoBuilder.aRequestForErrorResponseFromHubDto(uk.gov.ida.integrationtest.hub.samlengine.builders.RequestForErrorResponseFromHubDtoBuilder.aRequestForErrorResponseFromHubDto) RequestForErrorResponseFromHubDto(uk.gov.ida.hub.samlengine.contracts.RequestForErrorResponseFromHubDto) URI(java.net.URI) Test(org.junit.Test)

Example 2 with RequestForErrorResponseFromHubDto

use of uk.gov.ida.hub.samlengine.contracts.RequestForErrorResponseFromHubDto in project verify-hub by alphagov.

the class RpErrorResponseGeneratorResourceTest method shouldReturnAnErrorResponseGivenBadInput.

@Test
public void shouldReturnAnErrorResponseGivenBadInput() throws JsonProcessingException {
    RequestForErrorResponseFromHubDto requestForErrorResponseFromHubDto = aRequestForErrorResponseFromHubDto().withStatus(null).build();
    configStub.signResponsesAndUseSamlStandard(requestForErrorResponseFromHubDto.getAuthnRequestIssuerEntityId());
    final URI uri = samlEngineAppRule.getUri(Urls.SamlEngineUrls.GENERATE_RP_ERROR_RESPONSE_RESOURCE);
    Response rpAuthnResponse = post(requestForErrorResponseFromHubDto, uri);
    assertThat(rpAuthnResponse.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
    ErrorStatusDto errorStatusDto = rpAuthnResponse.readEntity(ErrorStatusDto.class);
    assertThat(errorStatusDto.getExceptionType()).isEqualTo(ExceptionType.INVALID_INPUT);
}
Also used : Response(javax.ws.rs.core.Response) ErrorStatusDto(uk.gov.ida.common.ErrorStatusDto) RequestForErrorResponseFromHubDtoBuilder.aRequestForErrorResponseFromHubDto(uk.gov.ida.integrationtest.hub.samlengine.builders.RequestForErrorResponseFromHubDtoBuilder.aRequestForErrorResponseFromHubDto) RequestForErrorResponseFromHubDto(uk.gov.ida.hub.samlengine.contracts.RequestForErrorResponseFromHubDto) URI(java.net.URI) Test(org.junit.Test)

Aggregations

URI (java.net.URI)2 Response (javax.ws.rs.core.Response)2 Test (org.junit.Test)2 RequestForErrorResponseFromHubDto (uk.gov.ida.hub.samlengine.contracts.RequestForErrorResponseFromHubDto)2 RequestForErrorResponseFromHubDtoBuilder.aRequestForErrorResponseFromHubDto (uk.gov.ida.integrationtest.hub.samlengine.builders.RequestForErrorResponseFromHubDtoBuilder.aRequestForErrorResponseFromHubDto)2 ErrorStatusDto (uk.gov.ida.common.ErrorStatusDto)1 SamlMessageDto (uk.gov.ida.hub.samlengine.domain.SamlMessageDto)1