Skip to content

Commit

Permalink
Merge pull request #2072 from govuk-one-login/pyic-5097
Browse files Browse the repository at this point in the history
PYIC-5097: Add routing for DWP KBV CRI stub
  • Loading branch information
AmritSidhu authored Jun 27, 2024
2 parents f346a24 + 0185214 commit adb0224
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public class CriCheckingService {
private static final JourneyResponse JOURNEY_TEMPORARILY_UNAVAILABLE =
new JourneyResponse(JOURNEY_TEMPORARILY_UNAVAILABLE_PATH);
private static final JourneyResponse JOURNEY_ERROR = new JourneyResponse(JOURNEY_ERROR_PATH);
private static final JourneyResponse JOURNEY_INVALID_REQUEST =
new JourneyResponse(JourneyUris.JOURNEY_INVALID_REQUEST_PATH);

private static final List<String> ALLOWED_OAUTH_ERROR_CODES =
Arrays.asList(
OAuth2Error.INVALID_REQUEST_CODE,
Expand Down Expand Up @@ -137,6 +140,7 @@ public JourneyResponse handleCallbackError(
return (switch (errorCode) {
case OAuth2Error.ACCESS_DENIED_CODE -> JOURNEY_ACCESS_DENIED;
case OAuth2Error.TEMPORARILY_UNAVAILABLE_CODE -> JOURNEY_TEMPORARILY_UNAVAILABLE;
case OAuth2Error.INVALID_REQUEST_CODE -> JOURNEY_INVALID_REQUEST;
default -> JOURNEY_ERROR;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import static uk.gov.di.ipv.core.library.journeyuris.JourneyUris.JOURNEY_ERROR_PATH;
import static uk.gov.di.ipv.core.library.journeyuris.JourneyUris.JOURNEY_FAIL_WITH_CI_PATH;
import static uk.gov.di.ipv.core.library.journeyuris.JourneyUris.JOURNEY_FAIL_WITH_NO_CI_PATH;
import static uk.gov.di.ipv.core.library.journeyuris.JourneyUris.JOURNEY_INVALID_REQUEST_PATH;
import static uk.gov.di.ipv.core.library.journeyuris.JourneyUris.JOURNEY_NEXT_PATH;
import static uk.gov.di.ipv.core.library.journeyuris.JourneyUris.JOURNEY_TEMPORARILY_UNAVAILABLE_PATH;
import static uk.gov.di.ipv.core.library.journeyuris.JourneyUris.JOURNEY_VCS_NOT_CORRELATED;
Expand Down Expand Up @@ -130,6 +131,28 @@ void handleCallbackErrorShouldReturnJourneyAccessDeniedIfInCallbackRequest()
assertEquals(new JourneyResponse(JOURNEY_ACCESS_DENIED_PATH), journeyResponse);
}

@Test
void handleCallbackErrorShouldReturnJourneyInvalidRequestIfInCallbackRequest()
throws SqsException {
// Arrange
var callbackRequest =
CriCallbackRequest.builder()
.credentialIssuerId(TEST_CRI_ID)
.error(OAuth2Error.INVALID_REQUEST_CODE)
.errorDescription(TEST_ERROR_DESCRIPTION)
.build();
var clientOauthSessionItem = ClientOAuthSessionItem.builder().build();
when(mockConfigService.getSsmParameter(ConfigurationVariable.COMPONENT_ID))
.thenReturn(TEST_COMPONENT_ID);

// Act
var journeyResponse =
criCheckingService.handleCallbackError(callbackRequest, clientOauthSessionItem);

// Assert
assertEquals(new JourneyResponse(JOURNEY_INVALID_REQUEST_PATH), journeyResponse);
}

@Test
void handleCallbackErrorShouldReturnJourneyTemporarilyAvailableIfInCallbackRequest()
throws SqsException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ states:
access-denied:
targetJourney: FAILED
targetState: FAILED
invalid-request:
targetJourney: FAILED
targetState: FAILED
enhanced-verification:
targetJourney: FAILED
targetState: FAILED
Expand Down Expand Up @@ -507,15 +510,21 @@ states:
nestedJourney: ADDRESS_AND_FRAUD
exitEvents:
next:
targetState: CRI_NINO_J6
targetState: CRI_DWP_KBV_J7
checkIfDisabled:
hmrcKbv:
targetState: PRE_EXPERIAN_KBV_TRANSITION_PAGE
dwpKbv:
targetState: CRI_NINO_J6
checkIfDisabled:
hmrcKbv:
targetState: PRE_EXPERIAN_KBV_TRANSITION_PAGE
enhanced-verification:
targetState: CRI_NINO_J6
targetState: CRI_DWP_KBV_J7
checkIfDisabled:
hmrcKbv:
targetState: PRE_EXPERIAN_KBV_TRANSITION_PAGE
dwpKbv:
targetState: CRI_NINO_J6
checkIfDisabled:
hmrcKbv:
targetState: PRE_EXPERIAN_KBV_TRANSITION_PAGE

# Driving licence journey (J3)
CRI_DRIVING_LICENCE_J3:
Expand Down Expand Up @@ -569,10 +578,13 @@ states:
scoreThreshold: 2
events:
met:
targetState: CRI_NINO_J6
targetState: CRI_DWP_KBV_J7
checkIfDisabled:
hmrcKbv:
targetState: PRE_EXPERIAN_KBV_TRANSITION_PAGE
dwpKbv:
targetState: CRI_NINO_J6
checkIfDisabled:
hmrcKbv:
targetState: PRE_EXPERIAN_KBV_TRANSITION_PAGE
unmet:
targetJourney: FAILED
targetState: FAILED
Expand Down Expand Up @@ -663,6 +675,59 @@ states:
auditContext:
mitigationType: enhanced-verification

# DWP KBV journey (J7)
CRI_DWP_KBV_J7:
response:
type: cri
criId: dwpKbv
parent: CRI_STATE
events:
next:
targetState: EVALUATE_GPG45_SCORES
invalid-request:
targetState: PRE_EXPERIAN_KBV_TRANSITION_PAGE
access-denied:
targetState: PRE_EXPERIAN_KBV_TRANSITION_PAGE
enhanced-verification:
targetState: MITIGATION_02_OPTIONS_WITH_F2F
auditEvents:
- IPV_MITIGATION_START
auditContext:
mitigationType: enhanced-verification
checkIfDisabled:
f2f:
targetState: MITIGATION_02_OPTIONS
auditEvents:
- IPV_MITIGATION_START
auditContext:
mitigationType: enhanced-verification

CRI_DWP_KBV_M2B:
response:
type: cri
criId: dwpKbv
parent: CRI_STATE
events:
next:
targetState: EVALUATE_GPG45_SCORES
invalid-request:
targetState: PRE_EXPERIAN_KBV_TRANSITION_PAGE_M2B
access-denied:
targetState: PRE_EXPERIAN_KBV_TRANSITION_PAGE_M2B
enhanced-verification:
targetState: MITIGATION_02_OPTIONS_WITH_F2F_M2B
auditEvents:
- IPV_MITIGATION_START
auditContext:
mitigationType: enhanced-verification
checkIfDisabled:
f2f:
targetState: MITIGATION_02_OPTIONS
auditEvents:
- IPV_MITIGATION_START
auditContext:
mitigationType: enhanced-verification

# No photo id journey (M2B)
CRI_CLAIMED_IDENTITY_M2B:
response:
Expand Down Expand Up @@ -711,15 +776,21 @@ states:
nestedJourney: ADDRESS_AND_FRAUD
exitEvents:
next:
targetState: CRI_HMRC_KBV_M2B
targetState: CRI_DWP_KBV_M2B
checkIfDisabled:
hmrcKbv:
targetState: PRE_EXPERIAN_KBV_TRANSITION_PAGE_M2B
dwpKbv:
targetState: CRI_HMRC_KBV_M2B
checkIfDisabled:
hmrcKbv:
targetState: PRE_EXPERIAN_KBV_TRANSITION_PAGE_M2B
enhanced-verification:
targetState: CRI_HMRC_KBV_M2B
targetState: CRI_DWP_KBV_M2B
checkIfDisabled:
hmrcKbv:
targetState: PRE_EXPERIAN_KBV_TRANSITION_PAGE_M2B
dwpKbv:
targetState: CRI_HMRC_KBV_M2B
checkIfDisabled:
hmrcKbv:
targetState: PRE_EXPERIAN_KBV_TRANSITION_PAGE_M2B

PRE_EXPERIAN_KBV_TRANSITION_PAGE_M2B:
response:
Expand Down Expand Up @@ -1118,10 +1189,13 @@ states:
nestedJourney: ADDRESS_AND_FRAUD
exitEvents:
next:
targetState: MITIGATION_PP_CRI_NINO
targetState: MITIGATION_CRI_DWP_KBV
checkIfDisabled:
hmrcKbv:
targetState: MITIGATION_PRE_EXPERIAN_KBV_TRANSITION_PAGE
dwpKbv:
targetState: MITIGATION_PP_CRI_NINO
checkIfDisabled:
hmrcKbv:
targetState: MITIGATION_PRE_EXPERIAN_KBV_TRANSITION_PAGE
enhanced-verification:
targetJourney: FAILED
targetState: FAILED
Expand Down Expand Up @@ -1203,10 +1277,13 @@ states:
scoreThreshold: 2
events:
met:
targetState: MITIGATION_PP_CRI_NINO
targetState: MITIGATION_CRI_DWP_KBV
checkIfDisabled:
hmrcKbv:
targetState: MITIGATION_PRE_EXPERIAN_KBV_TRANSITION_PAGE
dwpKbv:
targetState: MITIGATION_PP_CRI_NINO
checkIfDisabled:
hmrcKbv:
targetState: MITIGATION_PRE_EXPERIAN_KBV_TRANSITION_PAGE
unmet:
targetJourney: FAILED
targetState: FAILED
Expand Down Expand Up @@ -1260,6 +1337,22 @@ states:
targetJourney: FAILED
targetState: FAILED

MITIGATION_CRI_DWP_KBV:
response:
type: cri
criId: dwpKbv
parent: CRI_STATE
events:
next:
targetState: EVALUATE_GPG45_SCORES
invalid-request:
targetState: MITIGATION_PRE_EXPERIAN_KBV_TRANSITION_PAGE
access-denied:
targetState: MITIGATION_PRE_EXPERIAN_KBV_TRANSITION_PAGE
enhanced-verification:
targetJourney: FAILED
targetState: FAILED

F2F_FAILED_MITIGATION_PAGE:
response:
type: page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ states:
access-denied:
targetJourney: FAILED
targetState: FAILED_CONFIRM_DETAILS
invalid-request:
targetJourney: FAILED
targetState: FAILED_CONFIRM_DETAILS
enhanced-verification:
targetJourney: FAILED
targetState: FAILED_CONFIRM_DETAILS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ states:
access-denied:
targetJourney: FAILED
targetState: FAILED
invalid-request:
targetJourney: FAILED
targetState: FAILED
enhanced-verification:
targetJourney: FAILED
targetState: FAILED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ states:
access-denied:
targetJourney: FAILED
targetState: FAILED_CONFIRM_DETAILS
invalid-request:
targetJourney: FAILED
targetState: FAILED_CONFIRM_DETAILS
enhanced-verification:
targetJourney: FAILED
targetState: FAILED_CONFIRM_DETAILS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ states:
access-denied:
targetJourney: FAILED
targetState: FAILED_CONFIRM_DETAILS
invalid-request:
targetJourney: FAILED
targetState: FAILED_CONFIRM_DETAILS
enhanced-verification:
targetJourney: FAILED
targetState: FAILED_CONFIRM_DETAILS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ private JourneyUris() {
"/journey/temporarily-unavailable";
public static final String JOURNEY_UNMET_PATH = "/journey/unmet";
public static final String JOURNEY_VCS_NOT_CORRELATED = "/journey/vcs-not-correlated";
public static final String JOURNEY_INVALID_REQUEST_PATH = "/journey/invalid-request";
}

0 comments on commit adb0224

Please sign in to comment.