Search in sources :

Example 6 with Cycle3AttributeRequestData

use of uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData in project verify-hub by alphagov.

the class AbstractAwaitingCycle3DataStateController method getCycle3AttributeRequestData.

public Cycle3AttributeRequestData getCycle3AttributeRequestData() {
    final String entityId = state.getRequestIssuerEntityId();
    final MatchingProcess matchingProcessDto = transactionsConfigProxy.getMatchingProcess(entityId);
    final String attributeName = matchingProcessDto.getAttributeName().get();
    return new Cycle3AttributeRequestData(attributeName, entityId);
}
Also used : MatchingProcess(uk.gov.ida.hub.policy.domain.MatchingProcess) Cycle3AttributeRequestData(uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData)

Example 7 with Cycle3AttributeRequestData

use of uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData in project verify-hub by alphagov.

the class Cycle3ServiceTest method shouldSendEidasRequestToMatchingServiceViaAttributeQueryServiceAndUpdateSessionStateWhenSuccessfulResponseIsReceived.

@Test
public void shouldSendEidasRequestToMatchingServiceViaAttributeQueryServiceAndUpdateSessionStateWhenSuccessfulResponseIsReceived() {
    final EidasAttributeQueryRequestDto eidasAttributeQueryRequestDto = EidasAttributeQueryRequestDtoBuilder.anEidasAttributeQueryRequestDto().build();
    final Cycle3AttributeRequestData attributeRequestData = new Cycle3AttributeRequestData("attribute-name", "issuer-id");
    final SessionId eidasSessionId = SessionIdBuilder.aSessionId().build();
    when(eidasAwaitingCycle3DataStateController.getCycle3AttributeRequestData()).thenReturn(attributeRequestData);
    when(sessionRepository.getStateController(eidasSessionId, AbstractAwaitingCycle3DataState.class)).thenReturn(eidasAwaitingCycle3DataStateController);
    when(eidasAwaitingCycle3DataStateController.createAttributeQuery(Matchers.any(Cycle3Dataset.class))).thenReturn(eidasAttributeQueryRequestDto);
    service.sendCycle3MatchingRequest(eidasSessionId, cycle3UserInput);
    verify(eidasAwaitingCycle3DataStateController).createAttributeQuery(Matchers.any(Cycle3Dataset.class));
    verify(attributeQueryService).sendAttributeQueryRequest(eidasSessionId, eidasAttributeQueryRequestDto);
    verify(eidasAwaitingCycle3DataStateController).handleCycle3DataSubmitted("principal-ip-address-as-seen-by-hub");
}
Also used : Cycle3Dataset(uk.gov.ida.hub.policy.domain.Cycle3Dataset) Cycle3AttributeRequestData(uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData) SessionId(uk.gov.ida.hub.policy.domain.SessionId) EidasAttributeQueryRequestDto(uk.gov.ida.hub.policy.contracts.EidasAttributeQueryRequestDto) Test(org.junit.Test)

Example 8 with Cycle3AttributeRequestData

use of uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData in project verify-hub by alphagov.

the class Cycle3DataResourceTest method shouldGetCycle3AttributeRequestDataFromConfiguration.

@Test
public void shouldGetCycle3AttributeRequestDataFromConfiguration() throws JsonProcessingException {
    // Given
    SessionId sessionId = SessionIdBuilder.aSessionId().build();
    String rpEntityId = new Cycle3DTO(sessionId).getRequestIssuerId();
    Response sessionCreatedResponse = createSessionInAwaitingCycle3DataState(sessionId);
    assertThat(sessionCreatedResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    final MatchingProcessDto cycle3Attribute = new MatchingProcessDto(Optional.of("TUFTY_CLUB_CARD"));
    configStub.setUpStubForEnteringAwaitingCycle3DataState(rpEntityId, cycle3Attribute);
    samlSoapProxyProxyStub.setUpStubForSendHubMatchingServiceRequest(sessionId);
    // When
    Cycle3AttributeRequestData actualResponse = getCycle3Data(sessionId);
    // Then
    Cycle3AttributeRequestData expectedResponse = aCycle3AttributeRequestData().withAttributeName(cycle3Attribute.getAttributeName().get()).withRequestIssuerId(rpEntityId).build();
    assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse);
}
Also used : Response(javax.ws.rs.core.Response) Cycle3DTO(uk.gov.ida.integrationtest.hub.policy.rest.Cycle3DTO) MatchingProcessDto(uk.gov.ida.hub.policy.domain.MatchingProcessDto) Cycle3AttributeRequestData(uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData) Cycle3AttributeRequestDataBuilder.aCycle3AttributeRequestData(uk.gov.ida.hub.policy.builder.domain.Cycle3AttributeRequestDataBuilder.aCycle3AttributeRequestData) SessionId(uk.gov.ida.hub.policy.domain.SessionId) Test(org.junit.Test)

Example 9 with Cycle3AttributeRequestData

use of uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData in project verify-hub by alphagov.

the class MatchingServiceResourcesIntegrationTest method getCycle3AttributeRequestData_shouldReturnExpectedAttributeData.

@Test
public void getCycle3AttributeRequestData_shouldReturnExpectedAttributeData() throws Exception {
    final SessionId sessionId = aSessionIsCreated();
    anIdpIsSelectedForRegistration(sessionId, idpEntityId);
    anIdpAuthnRequestWasGenerated(sessionId);
    anAuthnResponseFromIdpWasReceivedAndMatchingRequestSent(sessionId);
    final String cycle3Attribute = aNoMatchResponseWasReceivedFromTheMSAForCycle01_withCycle3Enabled(sessionId);
    URI uri = UriBuilder.fromPath(Urls.PolicyUrls.CYCLE_3_REQUEST_RESOURCE).build(sessionId);
    Response response = getResponse(policy.uri(uri.toASCIIString()));
    assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    final Cycle3AttributeRequestData attributeData = response.readEntity(Cycle3AttributeRequestData.class);
    assertThat(attributeData.getAttributeName()).isEqualTo(cycle3Attribute);
    assertThat(attributeData.getRequestIssuerId()).isEqualTo(rpEntityId);
    assertThat(getSessionStateName(sessionId)).isEqualTo(AwaitingCycle3DataState.class.getName());
}
Also used : Response(javax.ws.rs.core.Response) AwaitingCycle3DataState(uk.gov.ida.hub.policy.domain.state.AwaitingCycle3DataState) Cycle3AttributeRequestData(uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData) SessionId(uk.gov.ida.hub.policy.domain.SessionId) URI(java.net.URI) Test(org.junit.Test)

Aggregations

Cycle3AttributeRequestData (uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData)9 Test (org.junit.Test)8 SessionId (uk.gov.ida.hub.policy.domain.SessionId)5 Response (javax.ws.rs.core.Response)3 Cycle3AttributeRequestDataBuilder.aCycle3AttributeRequestData (uk.gov.ida.hub.policy.builder.domain.Cycle3AttributeRequestDataBuilder.aCycle3AttributeRequestData)2 EidasAttributeQueryRequestDto (uk.gov.ida.hub.policy.contracts.EidasAttributeQueryRequestDto)2 Cycle3Dataset (uk.gov.ida.hub.policy.domain.Cycle3Dataset)2 MatchingProcess (uk.gov.ida.hub.policy.domain.MatchingProcess)2 MatchingProcessDto (uk.gov.ida.hub.policy.domain.MatchingProcessDto)2 URI (java.net.URI)1 AttributeQueryRequestDto (uk.gov.ida.hub.policy.contracts.AttributeQueryRequestDto)1 AwaitingCycle3DataState (uk.gov.ida.hub.policy.domain.state.AwaitingCycle3DataState)1 Cycle3DTO (uk.gov.ida.integrationtest.hub.policy.rest.Cycle3DTO)1 EidasCycle3DTO (uk.gov.ida.integrationtest.hub.policy.rest.EidasCycle3DTO)1