Search in sources :

Example 1 with Cycle3UserInput

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

the class Cycle3DataResourceTest method should_ReturnSuccessWhenDataSubmitted.

@Test
public void should_ReturnSuccessWhenDataSubmitted() throws JsonProcessingException {
    // Given
    SessionId sessionId = SessionIdBuilder.aSessionId().build();
    String rpEntityId = new Cycle3DTO(sessionId).getRequestIssuerId();
    String msaEntityId = new Cycle3DTO(sessionId).getMatchingServiceEntityId();
    Response sessionCreatedResponse = createSessionInAwaitingCycle3DataState(sessionId);
    assertThat(sessionCreatedResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    final Cycle3UserInput cycle3UserInput = new Cycle3UserInput("test-value", "principal-ip-address-seen-by-hub");
    samlEngineStub.setupStubForAttributeQueryRequest(AttributeQueryContainerDtoBuilder.anAttributeQueryContainerDto().build());
    configStub.setUpStubForMatchingServiceRequest(rpEntityId, msaEntityId);
    final MatchingProcessDto cycle3Attribute = new MatchingProcessDto(Optional.of("TUFTY_CLUB_CARD"));
    configStub.setUpStubForEnteringAwaitingCycle3DataState(rpEntityId, cycle3Attribute);
    samlSoapProxyProxyStub.setUpStubForSendHubMatchingServiceRequest(sessionId);
    // When
    postCycle3Data(sessionId, cycle3UserInput);
    // Then
    assertThat(getSessionStateName(sessionId)).isEqualTo(Cycle3MatchRequestSentState.class.getName());
}
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) Cycle3UserInput(uk.gov.ida.hub.policy.domain.Cycle3UserInput) Cycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState) SessionId(uk.gov.ida.hub.policy.domain.SessionId) Test(org.junit.Test)

Example 2 with Cycle3UserInput

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

the class MatchingServiceResourcesIntegrationTest method aCycle3AttributeHasBeenSentToPolicyFromTheUser.

private void aCycle3AttributeHasBeenSentToPolicyFromTheUser(SessionId sessionId, String cycle3Attribute) {
    Cycle3UserInput cycle3UserInput = new Cycle3UserInput(cycle3Attribute, "principalIpAsSeenByHub");
    URI uri = UriBuilder.fromPath(Urls.PolicyUrls.CYCLE_3_SUBMIT_RESOURCE).build(sessionId);
    postResponse(policy.uri(uri.toASCIIString()), cycle3UserInput);
}
Also used : Cycle3UserInput(uk.gov.ida.hub.policy.domain.Cycle3UserInput) URI(java.net.URI)

Example 3 with Cycle3UserInput

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

the class Cycle3ServiceTest method setup.

@Before
public void setup() {
    sessionId = SessionIdBuilder.aSessionId().build();
    cycle3UserInput = new Cycle3UserInput("test-value", "principal-ip-address-as-seen-by-hub");
    service = new Cycle3Service(sessionRepository, attributeQueryService);
    when(sessionRepository.getStateController(sessionId, AwaitingCycle3DataState.class)).thenReturn(awaitingCycle3DataStateController);
    when(sessionRepository.getStateController(sessionId, AbstractAwaitingCycle3DataState.class)).thenReturn(awaitingCycle3DataStateController);
}
Also used : Cycle3UserInput(uk.gov.ida.hub.policy.domain.Cycle3UserInput) Before(org.junit.Before)

Example 4 with Cycle3UserInput

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

the class EidasCycle3DataResourceTest method shouldReturnSuccessWhenDataSubmitted.

@Test
public void shouldReturnSuccessWhenDataSubmitted() throws JsonProcessingException {
    final SessionId sessionId = SessionIdBuilder.aSessionId().build();
    final String rpEntityId = new EidasCycle3DTO(sessionId).getRequestIssuerEntityId();
    final String msaEntityId = new EidasCycle3DTO(sessionId).getMatchingServiceAdapterEntityId();
    final Response sessionCreatedResponse = createSessionInEidasAwaitingCycle3DataState(sessionId);
    assertThat(sessionCreatedResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    final Cycle3UserInput cycle3UserInput = new Cycle3UserInput("test-value", "principal-ip-address-seen-by-hub");
    samlEngineStub.setupStubForEidasAttributeQueryRequestGeneration(AttributeQueryContainerDtoBuilder.anAttributeQueryContainerDto().build());
    configStub.setUpStubForMatchingServiceRequest(rpEntityId, msaEntityId);
    final MatchingProcessDto cycle3Attribute = new MatchingProcessDto(Optional.of("TUFTY_CLUB_CARD"));
    configStub.setUpStubForEnteringAwaitingCycle3DataState(rpEntityId, cycle3Attribute);
    samlSoapProxyProxyStub.setUpStubForSendHubMatchingServiceRequest(sessionId);
    postCycle3Data(sessionId, cycle3UserInput);
    assertThat(getSessionStateName(sessionId)).isEqualTo(EidasCycle3MatchRequestSentState.class.getName());
}
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) Cycle3UserInput(uk.gov.ida.hub.policy.domain.Cycle3UserInput) EidasCycle3MatchRequestSentState(uk.gov.ida.hub.policy.domain.state.EidasCycle3MatchRequestSentState) SessionId(uk.gov.ida.hub.policy.domain.SessionId) Test(org.junit.Test)

Aggregations

Cycle3UserInput (uk.gov.ida.hub.policy.domain.Cycle3UserInput)4 Response (javax.ws.rs.core.Response)2 Test (org.junit.Test)2 MatchingProcessDto (uk.gov.ida.hub.policy.domain.MatchingProcessDto)2 SessionId (uk.gov.ida.hub.policy.domain.SessionId)2 URI (java.net.URI)1 Before (org.junit.Before)1 Cycle3MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle3MatchRequestSentState)1 EidasCycle3MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.EidasCycle3MatchRequestSentState)1 Cycle3DTO (uk.gov.ida.integrationtest.hub.policy.rest.Cycle3DTO)1 EidasCycle3DTO (uk.gov.ida.integrationtest.hub.policy.rest.EidasCycle3DTO)1