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