Search in sources :

Example 6 with SuccessFromIdp

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

the class IdpSelectedStateControllerTest method handleSuccessResponseFromIdp_shouldThrowExceptionWhenReturnedLOAIsUnsupportedByIdpConfig.

@Test(expected = StateProcessingValidationException.class)
public void handleSuccessResponseFromIdp_shouldThrowExceptionWhenReturnedLOAIsUnsupportedByIdpConfig() {
    PersistentId persistentId = aPersistentId().withNameId("idname").build();
    SuccessFromIdp successFromIdp = aSuccessFromIdp().withIssuerId(IDP_ENTITY_ID).withPersistentId(persistentId).withPrincipalIpAddressSeenByIdp(PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_IDP).withPrincipalIpAddressAsSeenByHub(PRINCIPAL_IP_ADDRESS_AS_SEEN_BY_HUB).withLevelOfAssurance(LevelOfAssurance.LEVEL_3).build();
    when(identityProvidersConfigProxy.getEnabledIdentityProviders(TRANSACTION_ENTITY_ID, controller.isRegistrationContext(), PROVIDED_LOA)).thenReturn(singletonList(IDP_ENTITY_ID));
    when(policyConfiguration.getMatchingServiceResponseWaitPeriod()).thenReturn(new org.joda.time.Duration(600L));
    when(identityProvidersConfigProxy.getIdpConfig(IDP_ENTITY_ID)).thenReturn(anIdpConfigDto().withLevelsOfAssurance(LEVELS_OF_ASSURANCE).build());
    controller.handleSuccessResponseFromIdp(successFromIdp);
}
Also used : SuccessFromIdp(uk.gov.ida.hub.policy.domain.SuccessFromIdp) SuccessFromIdpBuilder.aSuccessFromIdp(uk.gov.ida.hub.policy.builder.domain.SuccessFromIdpBuilder.aSuccessFromIdp) PersistentId(uk.gov.ida.hub.policy.domain.PersistentId) PersistentIdBuilder.aPersistentId(uk.gov.ida.hub.policy.builder.domain.PersistentIdBuilder.aPersistentId) Test(org.junit.Test)

Example 7 with SuccessFromIdp

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

the class AuthnResponseFromIdpServiceTest method verifyIdpStateControllerIsCalledWithRightDataOnSuccess.

private void verifyIdpStateControllerIsCalledWithRightDataOnSuccess(InboundResponseFromIdpDto successResponseFromIdp) {
    ArgumentCaptor<SuccessFromIdp> captor = ArgumentCaptor.forClass(SuccessFromIdp.class);
    PersistentId persistentId = PersistentIdBuilder.aPersistentId().withNameId(successResponseFromIdp.getPersistentId().get()).build();
    SuccessFromIdp expectedSuccessFromIdp = SuccessFromIdpBuilder.aSuccessFromIdp().withIssuerId(successResponseFromIdp.getIssuer()).withEncryptedMatchingDatasetAssertion(successResponseFromIdp.getEncryptedMatchingDatasetAssertion().get()).withAuthnStatementAssertion(successResponseFromIdp.getAuthnStatementAssertionBlob().get()).withPersistentId(persistentId).withLevelOfAssurance(successResponseFromIdp.getLevelOfAssurance().get()).withPrincipalIpAddressAsSeenByHub(samlAuthnResponseContainerDto.getPrincipalIPAddressAsSeenByHub()).withPrincipalIpAddressSeenByIdp(successResponseFromIdp.getPrincipalIpAddressAsSeenByIdp().get()).build();
    verify(idpSelectedStateController).handleSuccessResponseFromIdp(captor.capture());
    SuccessFromIdp actualSuccessFromIdp = captor.getValue();
    assertThat(actualSuccessFromIdp).isEqualToIgnoringGivenFields(expectedSuccessFromIdp, "persistentId");
    assertThat(actualSuccessFromIdp.getPersistentId().getNameId()).isEqualTo(persistentId.getNameId());
}
Also used : SuccessFromIdp(uk.gov.ida.hub.policy.domain.SuccessFromIdp) PersistentId(uk.gov.ida.hub.policy.domain.PersistentId)

Aggregations

SuccessFromIdp (uk.gov.ida.hub.policy.domain.SuccessFromIdp)7 PersistentId (uk.gov.ida.hub.policy.domain.PersistentId)6 Test (org.junit.Test)5 SuccessFromIdpBuilder.aSuccessFromIdp (uk.gov.ida.hub.policy.builder.domain.SuccessFromIdpBuilder.aSuccessFromIdp)5 PersistentIdBuilder.aPersistentId (uk.gov.ida.hub.policy.builder.domain.PersistentIdBuilder.aPersistentId)4 AttributeQueryRequestDto (uk.gov.ida.hub.policy.contracts.AttributeQueryRequestDto)1 LevelOfAssurance (uk.gov.ida.hub.policy.domain.LevelOfAssurance)1 Cycle0And1MatchRequestSentState (uk.gov.ida.hub.policy.domain.state.Cycle0And1MatchRequestSentState)1