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);
}
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);
}
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");
}
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);
}
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);
}
Aggregations