Search in sources :

Example 1 with Cycle3AttributeRequestData

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

the class EidasAwaitingCycle3DataStateControllerTest method getCycle3AttributeRequestData.

@Test
public void getCycle3AttributeRequestData() {
    final MatchingProcess matchingProcess = new MatchingProcess(Optional.of(CYCLE_3_ATTRIBUTE_NAME));
    when(transactionsConfigProxy.getMatchingProcess(state.getRequestIssuerEntityId())).thenReturn(matchingProcess);
    final Cycle3AttributeRequestData expectedData = new Cycle3AttributeRequestData(CYCLE_3_ATTRIBUTE_NAME, state.getRequestIssuerEntityId());
    final Cycle3AttributeRequestData actualData = controller.getCycle3AttributeRequestData();
    assertThat(actualData).isEqualTo(expectedData);
}
Also used : MatchingProcess(uk.gov.ida.hub.policy.domain.MatchingProcess) Cycle3AttributeRequestData(uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData) Test(org.junit.Test)

Example 2 with Cycle3AttributeRequestData

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

the class EidasCycle3DataResourceTest method shouldGetCycle3AttributeRequestDataFromConfiguration.

@Test
public void shouldGetCycle3AttributeRequestDataFromConfiguration() throws JsonProcessingException {
    final SessionId sessionId = SessionIdBuilder.aSessionId().build();
    final String rpEntityId = new EidasCycle3DTO(sessionId).getRequestIssuerEntityId();
    final Response sessionCreatedResponse = createSessionInEidasAwaitingCycle3DataState(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);
    final Cycle3AttributeRequestData actualResponse = getCycle3Data(sessionId);
    final Cycle3AttributeRequestData expectedResponse = aCycle3AttributeRequestData().withAttributeName(cycle3Attribute.getAttributeName().get()).withRequestIssuerId(rpEntityId).build();
    assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse);
}
Also used : Response(javax.ws.rs.core.Response) MatchingProcessDto(uk.gov.ida.hub.policy.domain.MatchingProcessDto) EidasCycle3DTO(uk.gov.ida.integrationtest.hub.policy.rest.EidasCycle3DTO) 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 3 with Cycle3AttributeRequestData

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

the class Cycle3ServiceTest method shouldSendRequestToMatchingServiceViaAttributeQueryServiceAndUpdateSessionStateWhenSuccessfulResponseIsReceived.

@Test
public void shouldSendRequestToMatchingServiceViaAttributeQueryServiceAndUpdateSessionStateWhenSuccessfulResponseIsReceived() {
    // Given
    Cycle3AttributeRequestData attributeRequestData = new Cycle3AttributeRequestData("attribute-name", "issuer-id");
    stub(awaitingCycle3DataStateController.getCycle3AttributeRequestData()).toReturn(attributeRequestData);
    AttributeQueryRequestDto attributeQueryRequestDto = AttributeQueryRequestBuilder.anAttributeQueryRequest().build();
    stub(awaitingCycle3DataStateController.createAttributeQuery(Matchers.any(Cycle3Dataset.class))).toReturn(attributeQueryRequestDto);
    // When
    service.sendCycle3MatchingRequest(sessionId, cycle3UserInput);
    // Then
    verify(awaitingCycle3DataStateController).createAttributeQuery(Matchers.any(Cycle3Dataset.class));
    verify(attributeQueryService).sendAttributeQueryRequest(sessionId, attributeQueryRequestDto);
    verify(awaitingCycle3DataStateController).handleCycle3DataSubmitted("principal-ip-address-as-seen-by-hub");
}
Also used : Cycle3Dataset(uk.gov.ida.hub.policy.domain.Cycle3Dataset) AttributeQueryRequestDto(uk.gov.ida.hub.policy.contracts.AttributeQueryRequestDto) EidasAttributeQueryRequestDto(uk.gov.ida.hub.policy.contracts.EidasAttributeQueryRequestDto) Cycle3AttributeRequestData(uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData) Test(org.junit.Test)

Example 4 with Cycle3AttributeRequestData

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

the class Cycle3ServiceTest method shouldReturnCycle3AttributeRequestDataAfterReceivingCycle3AttributeRequestDataForEidasFlow.

@Test
public void shouldReturnCycle3AttributeRequestDataAfterReceivingCycle3AttributeRequestDataForEidasFlow() {
    SessionId eidasSessionId = SessionIdBuilder.aSessionId().build();
    when(sessionRepository.getStateController(eidasSessionId, AbstractAwaitingCycle3DataState.class)).thenReturn(eidasAwaitingCycle3DataStateController);
    when(eidasAwaitingCycle3DataStateController.getCycle3AttributeRequestData()).thenReturn(ATTRIBUTE_REQUEST_DATA);
    Cycle3AttributeRequestData result = service.getCycle3AttributeRequestData(eidasSessionId);
    assertThat(result).isEqualTo(ATTRIBUTE_REQUEST_DATA);
}
Also used : Cycle3AttributeRequestData(uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData) SessionId(uk.gov.ida.hub.policy.domain.SessionId) Test(org.junit.Test)

Example 5 with Cycle3AttributeRequestData

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

the class Cycle3ServiceTest method shouldReturnCycle3AttributeRequestDataAfterReceivingCycle3AttributeRequestDataForVerifyFlow.

@Test
public void shouldReturnCycle3AttributeRequestDataAfterReceivingCycle3AttributeRequestDataForVerifyFlow() {
    // Given
    stub(awaitingCycle3DataStateController.getCycle3AttributeRequestData()).toReturn(ATTRIBUTE_REQUEST_DATA);
    when(sessionRepository.sessionExists(sessionId)).thenReturn(true);
    when(sessionRepository.getTransactionSupportsEidas(sessionId)).thenReturn(false);
    // When
    Cycle3AttributeRequestData result = service.getCycle3AttributeRequestData(sessionId);
    // Then
    assertThat(result).isEqualTo(ATTRIBUTE_REQUEST_DATA);
}
Also used : Cycle3AttributeRequestData(uk.gov.ida.hub.policy.domain.Cycle3AttributeRequestData) 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