From 273a1676ee7f4c3415305d41325ccfb59a7e0f2f Mon Sep 17 00:00:00 2001 From: Thea Bautista Date: Mon, 18 Nov 2024 14:47:52 +0000 Subject: [PATCH 1/6] PYIC-7701: combine given + family check coi functions into one --- .../library/service/UserIdentityService.java | 42 +-- .../service/UserIdentityServiceTest.java | 333 +++++------------- 2 files changed, 106 insertions(+), 269 deletions(-) diff --git a/libs/user-identity-service/src/main/java/uk/gov/di/ipv/core/library/service/UserIdentityService.java b/libs/user-identity-service/src/main/java/uk/gov/di/ipv/core/library/service/UserIdentityService.java index 634e30ce4c..7ce86a3c46 100644 --- a/libs/user-identity-service/src/main/java/uk/gov/di/ipv/core/library/service/UserIdentityService.java +++ b/libs/user-identity-service/src/main/java/uk/gov/di/ipv/core/library/service/UserIdentityService.java @@ -179,40 +179,30 @@ public boolean areVcsCorrelated(List vcs) return true; } - public boolean areGivenNamesAndDobCorrelated(List vcs) + public boolean areNamesAndDobCorrelated(List vcs) throws HttpResponseExceptionWithErrorBody { var successfulVcs = getSuccessfulVcs(vcs); - if (!checkNamesForCorrelation( - getNameProperty( - getIdentityClaimsForNameCorrelation(successfulVcs), - NamePart.NamePartType.GIVEN_NAME))) { - LOGGER.error(LogHelper.buildErrorMessage(ErrorResponse.FAILED_NAME_CORRELATION)); - return false; - } + var areGivenNamesCorrelated = + checkNamesForCorrelation( + getNameProperty( + getIdentityClaimsForNameCorrelation(successfulVcs), + NamePart.NamePartType.GIVEN_NAME)); - if (!checkBirthDateCorrelationInCredentials(successfulVcs)) { - LOGGER.error(LogHelper.buildErrorMessage(ErrorResponse.FAILED_BIRTHDATE_CORRELATION)); - return false; - } - return true; - } + var isFamilyNameCorrelated = + checkNamesForCorrelation( + getFamilyNameForCoiCheck( + getIdentityClaimsForNameCorrelation(successfulVcs))); - public boolean areFamilyNameAndDobCorrelatedForCoiCheck(List vcs) - throws HttpResponseExceptionWithErrorBody { - var successfulVcs = getSuccessfulVcs(vcs); - - if (!checkNamesForCorrelation( - getFamilyNameForCoiCheck(getIdentityClaimsForNameCorrelation(successfulVcs)))) { - LOGGER.error(LogHelper.buildErrorMessage(ErrorResponse.FAILED_NAME_CORRELATION)); + // Given names AND family name cannot both be changed + if (!areGivenNamesCorrelated && !isFamilyNameCorrelated) { return false; } - if (!checkBirthDateCorrelationInCredentials(successfulVcs)) { - LOGGER.error(LogHelper.buildErrorMessage(ErrorResponse.FAILED_BIRTHDATE_CORRELATION)); - return false; - } - return true; + var isBirthDateCorrelated = checkBirthDateCorrelationInCredentials(successfulVcs); + + return (areGivenNamesCorrelated && isBirthDateCorrelated) + || (isFamilyNameCorrelated && isBirthDateCorrelated); } private List getSuccessfulVcs(List vcs) { diff --git a/libs/user-identity-service/src/test/java/uk/gov/di/ipv/core/library/service/UserIdentityServiceTest.java b/libs/user-identity-service/src/test/java/uk/gov/di/ipv/core/library/service/UserIdentityServiceTest.java index 03f38c0d9c..2783ab6188 100644 --- a/libs/user-identity-service/src/test/java/uk/gov/di/ipv/core/library/service/UserIdentityServiceTest.java +++ b/libs/user-identity-service/src/test/java/uk/gov/di/ipv/core/library/service/UserIdentityServiceTest.java @@ -553,281 +553,148 @@ void areVCsCorrelatedReturnsFalseWhenExtraBirthDateInVc() throws Exception { } @Nested - class AreGivenNamesAndDobCorrelated { - @Test - void shouldReturnTrueForCorrelatedGivenNames() throws Exception { - // Arrange - var vcs = - List.of( - generateVerifiableCredential( - USER_ID_1, - ADDRESS, - createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), - generateVerifiableCredential( - USER_ID_1, - DCMAW, - createCredentialWithNameAndBirthDate( - "Jimbo", "Bones", "1000-01-01"))); + class AreNamesAndDobCorrelated { + private VerifiableCredential PASSPORT_VC_JIMBO_JONES_2000_01_01 = + generateVerifiableCredential( + USER_ID_1, + PASSPORT, + createCredentialWithNameAndBirthDate("Jimbo", "Jones", "2000-01-01")); + private VerifiableCredential PASSPORT_VC_JIMBO_SMITH_2000_01_01 = + generateVerifiableCredential( + USER_ID_1, + PASSPORT, + createCredentialWithNameAndBirthDate("Jimbo", "SMITH", "2000-01-01")); + private VerifiableCredential PASSPORT_VC_TIMMY_JONES_2000_01_01 = + generateVerifiableCredential( + USER_ID_1, + PASSPORT, + createCredentialWithNameAndBirthDate("Timmy", "Jones", "2000-01-01")); + private VerifiableCredential PASSPORT_VC_TIMMY_SMITH_2000_01_01 = + generateVerifiableCredential( + USER_ID_1, + PASSPORT, + createCredentialWithNameAndBirthDate("Timmy", "Smith", "2000-01-01")); + private VerifiableCredential PASSPORT_VC_JIMBO_JONES_2002_02_02 = + generateVerifiableCredential( + USER_ID_1, + PASSPORT, + createCredentialWithNameAndBirthDate("Timmy", "Smith", "2002-02-02")); + private VerifiableCredential PASSPORT_VC_JIMBO_JONATHON_JONES_2002_02_02 = + generateVerifiableCredential( + USER_ID_1, + PASSPORT, + createCredentialWithNameAndBirthDate( + "Timmy", "Jonathon", "Smith", "2002-02-02")); - // Act & Assert - assertTrue(userIdentityService.areGivenNamesAndDobCorrelated(vcs)); + @BeforeEach + void setup() { + when(mockConfigService.getParameter(COI_CHECK_FAMILY_NAME_CHARS)).thenReturn("5"); } @Test - void shouldReturnFalseIfGivenNamesDiffer() throws Exception { + void shouldReturnTrueForCorrelatedGivenNamesAndDobAndDifferentFamilyNames() + throws Exception { // Arrange var vcs = List.of( - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Dimbo", "Bones", "1000-01-01"))); + PASSPORT_VC_JIMBO_JONES_2000_01_01, + PASSPORT_VC_JIMBO_JONES_2000_01_01, + PASSPORT_VC_JIMBO_SMITH_2000_01_01); // Act & Assert - assertFalse(userIdentityService.areGivenNamesAndDobCorrelated(vcs)); + assertTrue(userIdentityService.areNamesAndDobCorrelated(vcs)); } @Test - void shouldReturnFalseIfExtraGivenName() throws Exception { + void shouldReturnTrueForCorrelatedFamilyNamesAndDobAndDifferentGivenNames() + throws Exception { // Arrange var vcs = List.of( - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Jimbo", "Dimbo", "Bones", "1000-01-01"))); + PASSPORT_VC_JIMBO_JONES_2000_01_01, + PASSPORT_VC_JIMBO_JONES_2000_01_01, + PASSPORT_VC_TIMMY_JONES_2000_01_01); // Act & Assert - assertFalse(userIdentityService.areGivenNamesAndDobCorrelated(vcs)); + assertTrue(userIdentityService.areNamesAndDobCorrelated(vcs)); } @Test - void shouldReturnFalseIfDobDiffers() throws Exception { + void shouldReturnTrueWhenFamilyNameShorterThanCheckChars() throws Exception { // Arrange + when(mockConfigService.getParameter(COI_CHECK_FAMILY_NAME_CHARS)).thenReturn("500"); var vcs = List.of( - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Jimbo", "Bones", "2000-01-01"))); + PASSPORT_VC_JIMBO_JONES_2000_01_01, + PASSPORT_VC_JIMBO_JONES_2000_01_01, + PASSPORT_VC_JIMBO_SMITH_2000_01_01); // Act & Assert - assertFalse(userIdentityService.areGivenNamesAndDobCorrelated(vcs)); - } - - @ParameterizedTest - @NullAndEmptySource - void shouldThrowIfMissingGivenName(String missingName) { - // Arrange - var vcs = - List.of( - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - missingName, "Bones", "1000-01-01"))); - - // Act - HttpResponseExceptionWithErrorBody thrownError = - assertThrows( - HttpResponseExceptionWithErrorBody.class, - () -> userIdentityService.areGivenNamesAndDobCorrelated(vcs)); - - // Assert - assertEquals(500, thrownError.getResponseCode()); - assertEquals(ErrorResponse.FAILED_NAME_CORRELATION, thrownError.getErrorResponse()); - } - - @ParameterizedTest - @NullAndEmptySource - void shouldThrowIfMissingDob(String missingDob) { - // Arrange - var vcs = - List.of( - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Jimbo", "Bones", missingDob))); - - // Act - HttpResponseExceptionWithErrorBody thrownError = - assertThrows( - HttpResponseExceptionWithErrorBody.class, - () -> userIdentityService.areGivenNamesAndDobCorrelated(vcs)); - - // Assert - assertEquals(500, thrownError.getResponseCode()); - assertEquals( - ErrorResponse.FAILED_BIRTHDATE_CORRELATION, thrownError.getErrorResponse()); - } - } - - @Nested - class AreFamilyNameAndDobCorrelated { - @BeforeEach - void setup() { - when(mockConfigService.getParameter(COI_CHECK_FAMILY_NAME_CHARS)).thenReturn("5"); + assertTrue(userIdentityService.areNamesAndDobCorrelated(vcs)); } @Test - void shouldReturnTrueForCorrelatedFamilyNames() throws Exception { + void shouldReturnFalseIfGivenNamesAndFamilyNamesBothDiffer() throws Exception { // Arrange var vcs = List.of( - generateVerifiableCredential( - USER_ID_1, - ADDRESS, - createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), - generateVerifiableCredential( - USER_ID_1, - DCMAW, - createCredentialWithNameAndBirthDate( - "Dimbo", "Jones", "1000-01-01"))); + PASSPORT_VC_JIMBO_JONES_2000_01_01, + PASSPORT_VC_JIMBO_JONES_2000_01_01, + PASSPORT_VC_TIMMY_SMITH_2000_01_01); // Act & Assert - assertTrue(userIdentityService.areFamilyNameAndDobCorrelatedForCoiCheck(vcs)); + assertFalse(userIdentityService.areNamesAndDobCorrelated(vcs)); } @Test - void shouldReturnTrueWhenFamilyNameShorterThanCheckChars() throws Exception { + void shouldReturnFalseIfExtraGivenName() throws Exception { // Arrange - when(mockConfigService.getParameter(COI_CHECK_FAMILY_NAME_CHARS)).thenReturn("500"); var vcs = List.of( - generateVerifiableCredential( - USER_ID_1, - ADDRESS, - createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), - generateVerifiableCredential( - USER_ID_1, - DCMAW, - createCredentialWithNameAndBirthDate( - "Dimbo", "Jones", "1000-01-01"))); + PASSPORT_VC_JIMBO_JONES_2000_01_01, + PASSPORT_VC_JIMBO_JONES_2000_01_01, + PASSPORT_VC_JIMBO_JONATHON_JONES_2002_02_02); // Act & Assert - assertTrue(userIdentityService.areFamilyNameAndDobCorrelatedForCoiCheck(vcs)); + assertFalse(userIdentityService.areNamesAndDobCorrelated(vcs)); } @Test - void shouldReturnFalseIfFamilyNameDiffers() throws Exception { + void shouldReturnFalseIfDobDiffers() throws Exception { // Arrange var vcs = List.of( - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Dimbo", "Bones", "1000-01-01"))); + PASSPORT_VC_JIMBO_JONES_2000_01_01, + PASSPORT_VC_JIMBO_JONES_2000_01_01, + PASSPORT_VC_JIMBO_JONES_2002_02_02); // Act & Assert - assertFalse(userIdentityService.areFamilyNameAndDobCorrelatedForCoiCheck(vcs)); + assertFalse(userIdentityService.areNamesAndDobCorrelated(vcs)); } - @Test - void shouldReturnFalseIfDobDiffers() throws Exception { + @ParameterizedTest + @NullAndEmptySource + void shouldThrowIfMissingGivenName(String missingName) { // Arrange var vcs = List.of( + PASSPORT_VC_JIMBO_JONES_2000_01_01, + PASSPORT_VC_JIMBO_JONES_2000_01_01, generateVerifiableCredential( USER_ID_1, PASSPORT, createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Dimbo", "Jones", "2000-01-01"))); + missingName, "Jones", "1000-01-01"))); - // Act & Assert - assertFalse(userIdentityService.areFamilyNameAndDobCorrelatedForCoiCheck(vcs)); + // Act + HttpResponseExceptionWithErrorBody thrownError = + assertThrows( + HttpResponseExceptionWithErrorBody.class, + () -> userIdentityService.areNamesAndDobCorrelated(vcs)); + + // Assert + assertEquals(500, thrownError.getResponseCode()); + assertEquals(ErrorResponse.FAILED_NAME_CORRELATION, thrownError.getErrorResponse()); } @MockitoSettings(strictness = LENIENT) @@ -837,16 +704,8 @@ void shouldThrowIfMissingFamilyName(String missingName) { // Arrange var vcs = List.of( - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), + PASSPORT_VC_JIMBO_JONES_2000_01_01, + PASSPORT_VC_JIMBO_JONES_2000_01_01, generateVerifiableCredential( USER_ID_1, PASSPORT, @@ -857,9 +716,7 @@ void shouldThrowIfMissingFamilyName(String missingName) { HttpResponseExceptionWithErrorBody thrownError = assertThrows( HttpResponseExceptionWithErrorBody.class, - () -> - userIdentityService.areFamilyNameAndDobCorrelatedForCoiCheck( - vcs)); + () -> userIdentityService.areNamesAndDobCorrelated(vcs)); // Assert assertEquals(500, thrownError.getResponseCode()); @@ -872,29 +729,19 @@ void shouldThrowIfMissingDob(String missingDob) { // Arrange var vcs = List.of( + PASSPORT_VC_JIMBO_JONES_2000_01_01, + PASSPORT_VC_JIMBO_JONES_2000_01_01, generateVerifiableCredential( USER_ID_1, PASSPORT, createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Jimbo", "Jones", "1000-01-01")), - generateVerifiableCredential( - USER_ID_1, - PASSPORT, - createCredentialWithNameAndBirthDate( - "Dimbo", "Jones", missingDob))); + "Jimbo", "Jones", missingDob))); // Act HttpResponseExceptionWithErrorBody thrownError = assertThrows( HttpResponseExceptionWithErrorBody.class, - () -> - userIdentityService.areFamilyNameAndDobCorrelatedForCoiCheck( - vcs)); + () -> userIdentityService.areNamesAndDobCorrelated(vcs)); // Assert assertEquals(500, thrownError.getResponseCode()); From 1aab46fba8a186aa2a3acd69d110a25100465cfa Mon Sep 17 00:00:00 2001 From: Thea Bautista Date: Mon, 18 Nov 2024 14:48:34 +0000 Subject: [PATCH 2/6] PYIC-7701: use single coi check for family + given name change in CheckCoiHandler --- .../di/ipv/core/checkcoi/CheckCoiHandler.java | 6 +- .../core/checkcoi/CheckCoiHandlerTest.java | 59 ++++++++++--------- .../ipv/core/library/enums/CoiCheckType.java | 3 +- .../library/helpers/RequestHelperTest.java | 6 +- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/lambdas/check-coi/src/main/java/uk/gov/di/ipv/core/checkcoi/CheckCoiHandler.java b/lambdas/check-coi/src/main/java/uk/gov/di/ipv/core/checkcoi/CheckCoiHandler.java index ab7bdbef0b..3808194301 100644 --- a/lambdas/check-coi/src/main/java/uk/gov/di/ipv/core/checkcoi/CheckCoiHandler.java +++ b/lambdas/check-coi/src/main/java/uk/gov/di/ipv/core/checkcoi/CheckCoiHandler.java @@ -146,10 +146,8 @@ public Map handleRequest(ProcessRequest request, Context context var combinedCredentials = Stream.concat(oldVcs.stream(), sessionVcs.stream()).toList(); var successfulCheck = switch (checkType) { - case GIVEN_NAMES_AND_DOB -> userIdentityService - .areGivenNamesAndDobCorrelated(combinedCredentials); - case FAMILY_NAME_AND_DOB -> userIdentityService - .areFamilyNameAndDobCorrelatedForCoiCheck(combinedCredentials); + case GIVEN_OR_FAMILY_NAME_AND_DOB -> userIdentityService + .areNamesAndDobCorrelated(combinedCredentials); case FULL_NAME_AND_DOB -> userIdentityService.areVcsCorrelated( combinedCredentials); }; diff --git a/lambdas/check-coi/src/test/java/uk/gov/di/ipv/core/checkcoi/CheckCoiHandlerTest.java b/lambdas/check-coi/src/test/java/uk/gov/di/ipv/core/checkcoi/CheckCoiHandlerTest.java index 120fc5940e..ae2ed03759 100644 --- a/lambdas/check-coi/src/test/java/uk/gov/di/ipv/core/checkcoi/CheckCoiHandlerTest.java +++ b/lambdas/check-coi/src/test/java/uk/gov/di/ipv/core/checkcoi/CheckCoiHandlerTest.java @@ -71,9 +71,8 @@ import static uk.gov.di.ipv.core.library.domain.ErrorResponse.MISSING_CHECK_TYPE; import static uk.gov.di.ipv.core.library.domain.ErrorResponse.MISSING_IPV_SESSION_ID; import static uk.gov.di.ipv.core.library.domain.ErrorResponse.UNKNOWN_CHECK_TYPE; -import static uk.gov.di.ipv.core.library.enums.CoiCheckType.FAMILY_NAME_AND_DOB; import static uk.gov.di.ipv.core.library.enums.CoiCheckType.FULL_NAME_AND_DOB; -import static uk.gov.di.ipv.core.library.enums.CoiCheckType.GIVEN_NAMES_AND_DOB; +import static uk.gov.di.ipv.core.library.enums.CoiCheckType.GIVEN_OR_FAMILY_NAME_AND_DOB; import static uk.gov.di.ipv.core.library.fixtures.VcFixtures.M1A_ADDRESS_VC; import static uk.gov.di.ipv.core.library.fixtures.VcFixtures.M1A_EXPERIAN_FRAUD_VC; import static uk.gov.di.ipv.core.library.helpers.vocab.NameGenerator.NamePartGenerator.createNamePart; @@ -147,7 +146,7 @@ private Optional getMockIdentityClaim() { class SuccessfulChecks { @Test void shouldReturnPassedForSuccessfulGivenNamesAndDobCheck() throws Exception { - when(mockUserIdentityService.areGivenNamesAndDobCorrelated( + when(mockUserIdentityService.areNamesAndDobCorrelated( List.of(M1A_ADDRESS_VC, M1A_EXPERIAN_FRAUD_VC))) .thenReturn(true); when(mockClientSessionItem.getScopeClaims()) @@ -156,7 +155,8 @@ void shouldReturnPassedForSuccessfulGivenNamesAndDobCheck() throws Exception { var request = ProcessRequest.processRequestBuilder() .ipvSessionId(IPV_SESSION_ID) - .lambdaInput(Map.of("checkType", GIVEN_NAMES_AND_DOB.name())) + .lambdaInput( + Map.of("checkType", GIVEN_OR_FAMILY_NAME_AND_DOB.name())) .build(); var responseMap = checkCoiHandler.handleRequest(request, mockContext); @@ -169,13 +169,13 @@ void shouldReturnPassedForSuccessfulGivenNamesAndDobCheck() throws Exception { AuditEventTypes.IPV_CONTINUITY_OF_IDENTITY_CHECK_START, auditEventsCaptured.get(0).getEventName()); assertEquals( - new AuditExtensionCoiCheck(GIVEN_NAMES_AND_DOB, null), + new AuditExtensionCoiCheck(GIVEN_OR_FAMILY_NAME_AND_DOB, null), auditEventsCaptured.get(0).getExtensions()); assertEquals( AuditEventTypes.IPV_CONTINUITY_OF_IDENTITY_CHECK_END, auditEventsCaptured.get(1).getEventName()); assertEquals( - new AuditExtensionCoiCheck(GIVEN_NAMES_AND_DOB, true), + new AuditExtensionCoiCheck(GIVEN_OR_FAMILY_NAME_AND_DOB, true), auditEventsCaptured.get(1).getExtensions()); var restrictedAuditData = @@ -189,7 +189,7 @@ void shouldReturnPassedForSuccessfulGivenNamesAndDobCheck() throws Exception { @Test void shouldReturnPassedForSuccessfulFamilyNameAndDobCheck() throws Exception { - when(mockUserIdentityService.areFamilyNameAndDobCorrelatedForCoiCheck( + when(mockUserIdentityService.areNamesAndDobCorrelated( List.of(M1A_ADDRESS_VC, M1A_EXPERIAN_FRAUD_VC))) .thenReturn(true); when(mockClientSessionItem.getScopeClaims()) @@ -198,7 +198,8 @@ void shouldReturnPassedForSuccessfulFamilyNameAndDobCheck() throws Exception { var request = ProcessRequest.processRequestBuilder() .ipvSessionId(IPV_SESSION_ID) - .lambdaInput(Map.of("checkType", FAMILY_NAME_AND_DOB.name())) + .lambdaInput( + Map.of("checkType", GIVEN_OR_FAMILY_NAME_AND_DOB.name())) .build(); var responseMap = checkCoiHandler.handleRequest(request, mockContext); @@ -211,13 +212,13 @@ void shouldReturnPassedForSuccessfulFamilyNameAndDobCheck() throws Exception { AuditEventTypes.IPV_CONTINUITY_OF_IDENTITY_CHECK_START, auditEventsCaptured.get(0).getEventName()); assertEquals( - new AuditExtensionCoiCheck(FAMILY_NAME_AND_DOB, null), + new AuditExtensionCoiCheck(GIVEN_OR_FAMILY_NAME_AND_DOB, null), auditEventsCaptured.get(0).getExtensions()); assertEquals( AuditEventTypes.IPV_CONTINUITY_OF_IDENTITY_CHECK_END, auditEventsCaptured.get(1).getEventName()); assertEquals( - new AuditExtensionCoiCheck(FAMILY_NAME_AND_DOB, true), + new AuditExtensionCoiCheck(GIVEN_OR_FAMILY_NAME_AND_DOB, true), auditEventsCaptured.get(1).getExtensions()); var restrictedAuditData = getRestrictedAuditDataNodeFromEvent(auditEventsCaptured.get(1)); @@ -421,7 +422,7 @@ void shouldSendOnlyDeviceInformationInRestrictedDataIfNoIdentityClaimsFound() class FailedChecks { @Test void shouldReturnFailedForFailedGivenNamesAndDobCheck() throws Exception { - when(mockUserIdentityService.areGivenNamesAndDobCorrelated( + when(mockUserIdentityService.areNamesAndDobCorrelated( List.of(M1A_ADDRESS_VC, M1A_EXPERIAN_FRAUD_VC))) .thenReturn(false); when(mockClientSessionItem.getScopeClaims()) @@ -430,7 +431,8 @@ void shouldReturnFailedForFailedGivenNamesAndDobCheck() throws Exception { var request = ProcessRequest.processRequestBuilder() .ipvSessionId(IPV_SESSION_ID) - .lambdaInput(Map.of("checkType", GIVEN_NAMES_AND_DOB.name())) + .lambdaInput( + Map.of("checkType", GIVEN_OR_FAMILY_NAME_AND_DOB.name())) .build(); var responseMap = checkCoiHandler.handleRequest(request, mockContext); @@ -443,13 +445,13 @@ void shouldReturnFailedForFailedGivenNamesAndDobCheck() throws Exception { AuditEventTypes.IPV_CONTINUITY_OF_IDENTITY_CHECK_START, auditEventsCaptured.get(0).getEventName()); assertEquals( - new AuditExtensionCoiCheck(GIVEN_NAMES_AND_DOB, null), + new AuditExtensionCoiCheck(GIVEN_OR_FAMILY_NAME_AND_DOB, null), auditEventsCaptured.get(0).getExtensions()); assertEquals( AuditEventTypes.IPV_CONTINUITY_OF_IDENTITY_CHECK_END, auditEventsCaptured.get(1).getEventName()); assertEquals( - new AuditExtensionCoiCheck(GIVEN_NAMES_AND_DOB, false), + new AuditExtensionCoiCheck(GIVEN_OR_FAMILY_NAME_AND_DOB, false), auditEventsCaptured.get(1).getExtensions()); var restrictedAuditData = @@ -463,7 +465,7 @@ void shouldReturnFailedForFailedGivenNamesAndDobCheck() throws Exception { @Test void shouldReturnFailedForFailedFamilyNameAndDobCheck() throws Exception { - when(mockUserIdentityService.areFamilyNameAndDobCorrelatedForCoiCheck( + when(mockUserIdentityService.areNamesAndDobCorrelated( List.of(M1A_ADDRESS_VC, M1A_EXPERIAN_FRAUD_VC))) .thenReturn(false); when(mockClientSessionItem.getScopeClaims()) @@ -472,7 +474,8 @@ void shouldReturnFailedForFailedFamilyNameAndDobCheck() throws Exception { var request = ProcessRequest.processRequestBuilder() .ipvSessionId(IPV_SESSION_ID) - .lambdaInput(Map.of("checkType", FAMILY_NAME_AND_DOB.name())) + .lambdaInput( + Map.of("checkType", GIVEN_OR_FAMILY_NAME_AND_DOB.name())) .deviceInformation(DEVICE_INFORMATION) .build(); @@ -486,13 +489,13 @@ void shouldReturnFailedForFailedFamilyNameAndDobCheck() throws Exception { AuditEventTypes.IPV_CONTINUITY_OF_IDENTITY_CHECK_START, auditEventsCaptured.get(0).getEventName()); assertEquals( - new AuditExtensionCoiCheck(FAMILY_NAME_AND_DOB, null), + new AuditExtensionCoiCheck(GIVEN_OR_FAMILY_NAME_AND_DOB, null), auditEventsCaptured.get(0).getExtensions()); assertEquals( AuditEventTypes.IPV_CONTINUITY_OF_IDENTITY_CHECK_END, auditEventsCaptured.get(1).getEventName()); assertEquals( - new AuditExtensionCoiCheck(FAMILY_NAME_AND_DOB, false), + new AuditExtensionCoiCheck(GIVEN_OR_FAMILY_NAME_AND_DOB, false), auditEventsCaptured.get(1).getExtensions()); } @@ -577,7 +580,7 @@ void shouldReturnErrorIfCheckTypeNotInRequest() { @Test void shouldReturnErrorIfFamilyNameCorrelationCheckThrowsHttpResponseException() throws Exception { - when(mockUserIdentityService.areFamilyNameAndDobCorrelatedForCoiCheck( + when(mockUserIdentityService.areNamesAndDobCorrelated( List.of(M1A_ADDRESS_VC, M1A_EXPERIAN_FRAUD_VC))) .thenThrow( new HttpResponseExceptionWithErrorBody( @@ -586,7 +589,7 @@ void shouldReturnErrorIfFamilyNameCorrelationCheckThrowsHttpResponseException() var request = ProcessRequest.processRequestBuilder() .ipvSessionId(IPV_SESSION_ID) - .lambdaInput(Map.of("checkType", FAMILY_NAME_AND_DOB.name())) + .lambdaInput(Map.of("checkType", GIVEN_OR_FAMILY_NAME_AND_DOB.name())) .build(); var responseMap = checkCoiHandler.handleRequest(request, mockContext); @@ -600,14 +603,14 @@ void shouldReturnErrorIfFamilyNameCorrelationCheckThrowsHttpResponseException() AuditEventTypes.IPV_CONTINUITY_OF_IDENTITY_CHECK_START, auditEventsCaptured.get(0).getEventName()); assertEquals( - new AuditExtensionCoiCheck(CoiCheckType.FAMILY_NAME_AND_DOB, null), + new AuditExtensionCoiCheck(CoiCheckType.GIVEN_OR_FAMILY_NAME_AND_DOB, null), auditEventsCaptured.get(0).getExtensions()); } @Test void shouldReturnErrorIfGivenNameCorrelationCheckThrowsHttpResponseException() throws Exception { - when(mockUserIdentityService.areGivenNamesAndDobCorrelated( + when(mockUserIdentityService.areNamesAndDobCorrelated( List.of(M1A_ADDRESS_VC, M1A_EXPERIAN_FRAUD_VC))) .thenThrow( new HttpResponseExceptionWithErrorBody( @@ -616,7 +619,7 @@ void shouldReturnErrorIfGivenNameCorrelationCheckThrowsHttpResponseException() var request = ProcessRequest.processRequestBuilder() .ipvSessionId(IPV_SESSION_ID) - .lambdaInput(Map.of("checkType", GIVEN_NAMES_AND_DOB.name())) + .lambdaInput(Map.of("checkType", GIVEN_OR_FAMILY_NAME_AND_DOB.name())) .build(); var responseMap = checkCoiHandler.handleRequest(request, mockContext); @@ -630,7 +633,7 @@ void shouldReturnErrorIfGivenNameCorrelationCheckThrowsHttpResponseException() AuditEventTypes.IPV_CONTINUITY_OF_IDENTITY_CHECK_START, auditEventsCaptured.get(0).getEventName()); assertEquals( - new AuditExtensionCoiCheck(CoiCheckType.GIVEN_NAMES_AND_DOB, null), + new AuditExtensionCoiCheck(CoiCheckType.GIVEN_OR_FAMILY_NAME_AND_DOB, null), auditEventsCaptured.get(0).getExtensions()); } @@ -709,7 +712,7 @@ void shouldReturnErrorIfUnknownCheckType() { @Test void shouldReturnIfFindIdentityClaimThrowsHttpResponseException() throws Exception { - when(mockUserIdentityService.areGivenNamesAndDobCorrelated( + when(mockUserIdentityService.areNamesAndDobCorrelated( List.of(M1A_ADDRESS_VC, M1A_EXPERIAN_FRAUD_VC))) .thenReturn(true); when(mockUserIdentityService.findIdentityClaim(any())) @@ -720,7 +723,7 @@ void shouldReturnIfFindIdentityClaimThrowsHttpResponseException() throws Excepti var request = ProcessRequest.processRequestBuilder() .ipvSessionId(IPV_SESSION_ID) - .lambdaInput(Map.of("checkType", GIVEN_NAMES_AND_DOB.name())) + .lambdaInput(Map.of("checkType", GIVEN_OR_FAMILY_NAME_AND_DOB.name())) .build(); var responseMap = checkCoiHandler.handleRequest(request, mockContext); @@ -734,14 +737,14 @@ void shouldReturnIfFindIdentityClaimThrowsHttpResponseException() throws Excepti @Test void shouldLogRuntimeExceptionsAndRethrow() throws Exception { // Arrange - when(mockUserIdentityService.areGivenNamesAndDobCorrelated( + when(mockUserIdentityService.areNamesAndDobCorrelated( List.of(M1A_ADDRESS_VC, M1A_EXPERIAN_FRAUD_VC))) .thenThrow(new RuntimeException("Test error")); var request = ProcessRequest.processRequestBuilder() .ipvSessionId(IPV_SESSION_ID) - .lambdaInput(Map.of("checkType", GIVEN_NAMES_AND_DOB.name())) + .lambdaInput(Map.of("checkType", GIVEN_OR_FAMILY_NAME_AND_DOB.name())) .build(); var logCollector = LogCollector.getLogCollectorFor(CheckCoiHandler.class); diff --git a/libs/common-services/src/main/java/uk/gov/di/ipv/core/library/enums/CoiCheckType.java b/libs/common-services/src/main/java/uk/gov/di/ipv/core/library/enums/CoiCheckType.java index c18f6a3497..014f671f83 100644 --- a/libs/common-services/src/main/java/uk/gov/di/ipv/core/library/enums/CoiCheckType.java +++ b/libs/common-services/src/main/java/uk/gov/di/ipv/core/library/enums/CoiCheckType.java @@ -4,7 +4,6 @@ @ExcludeFromGeneratedCoverageReport public enum CoiCheckType { - GIVEN_NAMES_AND_DOB, - FAMILY_NAME_AND_DOB, FULL_NAME_AND_DOB, + GIVEN_OR_FAMILY_NAME_AND_DOB } diff --git a/libs/common-services/src/test/java/uk/gov/di/ipv/core/library/helpers/RequestHelperTest.java b/libs/common-services/src/test/java/uk/gov/di/ipv/core/library/helpers/RequestHelperTest.java index c642224398..b8f2cbb6c0 100644 --- a/libs/common-services/src/test/java/uk/gov/di/ipv/core/library/helpers/RequestHelperTest.java +++ b/libs/common-services/src/test/java/uk/gov/di/ipv/core/library/helpers/RequestHelperTest.java @@ -30,7 +30,7 @@ import static uk.gov.di.ipv.core.library.domain.Cri.DCMAW; import static uk.gov.di.ipv.core.library.domain.ErrorResponse.MISSING_CHECK_TYPE; import static uk.gov.di.ipv.core.library.domain.ErrorResponse.MISSING_RESET_TYPE; -import static uk.gov.di.ipv.core.library.enums.CoiCheckType.GIVEN_NAMES_AND_DOB; +import static uk.gov.di.ipv.core.library.enums.CoiCheckType.GIVEN_OR_FAMILY_NAME_AND_DOB; import static uk.gov.di.ipv.core.library.enums.SessionCredentialsResetType.NAME_ONLY_CHANGE; import static uk.gov.di.ipv.core.library.helpers.RequestHelper.ENCODED_DEVICE_INFORMATION_HEADER; import static uk.gov.di.ipv.core.library.helpers.RequestHelper.FEATURE_SET_HEADER; @@ -511,10 +511,10 @@ void getIdentityTypeShouldThrowIfInvalid() { void getCoiCheckTypeShouldReturnCoiCheckType() throws Exception { ProcessRequest request = ProcessRequest.processRequestBuilder() - .lambdaInput(Map.of("checkType", GIVEN_NAMES_AND_DOB.name())) + .lambdaInput(Map.of("checkType", GIVEN_OR_FAMILY_NAME_AND_DOB.name())) .build(); - assertEquals(GIVEN_NAMES_AND_DOB, RequestHelper.getCoiCheckType(request)); + assertEquals(GIVEN_OR_FAMILY_NAME_AND_DOB, RequestHelper.getCoiCheckType(request)); } @Test From f6e82648926f7a505f3671d4d540699d9be218a0 Mon Sep 17 00:00:00 2001 From: Thea Bautista Date: Mon, 18 Nov 2024 15:56:20 +0000 Subject: [PATCH 3/6] PYIC-7701: update journey maps to combine update given + family routes --- .../journey-maps/repeat-fraud-check.yaml | 8 +- .../journey-maps/reuse-existing-identity.yaml | 8 +- .../journey-maps/update-name.yaml | 354 +++--------------- 3 files changed, 64 insertions(+), 306 deletions(-) diff --git a/lambdas/process-journey-event/src/main/resources/statemachine/journey-maps/repeat-fraud-check.yaml b/lambdas/process-journey-event/src/main/resources/statemachine/journey-maps/repeat-fraud-check.yaml index ab50695d59..09d0095883 100644 --- a/lambdas/process-journey-event/src/main/resources/statemachine/journey-maps/repeat-fraud-check.yaml +++ b/lambdas/process-journey-event/src/main/resources/statemachine/journey-maps/repeat-fraud-check.yaml @@ -71,7 +71,7 @@ states: updateSupported: true given-names-only: targetJourney: UPDATE_NAME - targetState: GIVEN_ONLY_AFTER_RFC_START + targetState: NAMES_ONLY_AFTER_RFC_START auditEvents: - IPV_USER_DETAILS_UPDATE_START - IPV_USER_DETAILS_UPDATE_SELECTED @@ -80,7 +80,7 @@ states: updateSupported: true family-name-only: targetJourney: UPDATE_NAME - targetState: FAMILY_ONLY_AFTER_RFC_START + targetState: NAMES_ONLY_AFTER_RFC_START auditEvents: - IPV_USER_DETAILS_UPDATE_START - IPV_USER_DETAILS_UPDATE_SELECTED @@ -89,7 +89,7 @@ states: updateSupported: true given-names-and-address: targetJourney: UPDATE_NAME - targetState: GIVEN_WITH_ADDRESS_AFTER_RFC_START + targetState: NAMES_WITH_ADDRESS_AFTER_RFC_START auditEvents: - IPV_USER_DETAILS_UPDATE_START - IPV_USER_DETAILS_UPDATE_SELECTED @@ -98,7 +98,7 @@ states: updateSupported: true family-name-and-address: targetJourney: UPDATE_NAME - targetState: FAMILY_WITH_ADDRESS_AFTER_RFC_START + targetState: NAMES_WITH_ADDRESS_AFTER_RFC_START auditEvents: - IPV_USER_DETAILS_UPDATE_START - IPV_USER_DETAILS_UPDATE_SELECTED diff --git a/lambdas/process-journey-event/src/main/resources/statemachine/journey-maps/reuse-existing-identity.yaml b/lambdas/process-journey-event/src/main/resources/statemachine/journey-maps/reuse-existing-identity.yaml index 4e78f8dc2d..3aba17c57d 100644 --- a/lambdas/process-journey-event/src/main/resources/statemachine/journey-maps/reuse-existing-identity.yaml +++ b/lambdas/process-journey-event/src/main/resources/statemachine/journey-maps/reuse-existing-identity.yaml @@ -130,7 +130,7 @@ states: updateSupported: true given-names-only: targetJourney: UPDATE_NAME - targetState: GIVEN_ONLY_AFTER_REUSE_START + targetState: NAMES_ONLY_AFTER_REUSE_START auditEvents: - IPV_USER_DETAILS_UPDATE_SELECTED auditContext: @@ -138,7 +138,7 @@ states: updateSupported: true family-name-only: targetJourney: UPDATE_NAME - targetState: FAMILY_ONLY_AFTER_REUSE_START + targetState: NAMES_ONLY_AFTER_REUSE_START auditEvents: - IPV_USER_DETAILS_UPDATE_SELECTED auditContext: @@ -146,7 +146,7 @@ states: updateSupported: true given-names-and-address: targetJourney: UPDATE_NAME - targetState: GIVEN_WITH_ADDRESS_AFTER_REUSE_START + targetState: NAMES_WITH_ADDRESS_AFTER_REUSE_START auditEvents: - IPV_USER_DETAILS_UPDATE_SELECTED auditContext: @@ -154,7 +154,7 @@ states: updateSupported: true family-name-and-address: targetJourney: UPDATE_NAME - targetState: FAMILY_WITH_ADDRESS_AFTER_REUSE_START + targetState: NAMES_WITH_ADDRESS_AFTER_REUSE_START auditEvents: - IPV_USER_DETAILS_UPDATE_SELECTED auditContext: diff --git a/lambdas/process-journey-event/src/main/resources/statemachine/journey-maps/update-name.yaml b/lambdas/process-journey-event/src/main/resources/statemachine/journey-maps/update-name.yaml index 1f8a887279..7e01a6e20c 100644 --- a/lambdas/process-journey-event/src/main/resources/statemachine/journey-maps/update-name.yaml +++ b/lambdas/process-journey-event/src/main/resources/statemachine/journey-maps/update-name.yaml @@ -7,45 +7,25 @@ description: >- states: # Entry points - GIVEN_ONLY_AFTER_REUSE_START: + NAMES_ONLY_AFTER_REUSE_START: events: next: - targetState: GIVEN_ONLY_AFTER_REUSE + targetState: NAMES_ONLY_AFTER_REUSE - GIVEN_ONLY_AFTER_RFC_START: + NAMES_ONLY_AFTER_RFC_START: events: next: - targetState: GIVEN_ONLY_AFTER_RFC + targetState: NAMES_ONLY_AFTER_RFC - FAMILY_ONLY_AFTER_REUSE_START: + NAMES_WITH_ADDRESS_AFTER_REUSE_START: events: next: - targetState: FAMILY_ONLY_AFTER_REUSE + targetState: NAMES_WITH_ADDRESS_AFTER_REUSE - FAMILY_ONLY_AFTER_RFC_START: + NAMES_WITH_ADDRESS_AFTER_RFC_START: events: next: - targetState: FAMILY_ONLY_AFTER_RFC - - GIVEN_WITH_ADDRESS_AFTER_REUSE_START: - events: - next: - targetState: GIVEN_WITH_ADDRESS_AFTER_REUSE - - GIVEN_WITH_ADDRESS_AFTER_RFC_START: - events: - next: - targetState: GIVEN_WITH_ADDRESS_AFTER_RFC - - FAMILY_WITH_ADDRESS_AFTER_REUSE_START: - events: - next: - targetState: FAMILY_WITH_ADDRESS_AFTER_REUSE - - FAMILY_WITH_ADDRESS_AFTER_RFC_START: - events: - next: - targetState: FAMILY_WITH_ADDRESS_AFTER_RFC + targetState: NAMES_WITH_ADDRESS_AFTER_RFC # Parent States @@ -106,69 +86,21 @@ states: # Journey States - # WITHOUT ADDRESS + # WITHOUT ADDRESS - GIVEN_ONLY_AFTER_REUSE: + NAMES_ONLY_AFTER_REUSE: response: type: page pageId: page-update-name events: update-name: - targetState: RESET_IDENTITY_GIVEN_ONLY + targetState: RESET_IDENTITY_NAMES_ONLY end: targetState: RETURN_TO_RP auditEvents: - IPV_USER_DETAILS_UPDATE_ABORTED - GIVEN_ONLY_AFTER_RFC: - response: - type: page - pageId: page-update-name - context: repeatFraudCheck - events: - update-name: - targetState: RESET_IDENTITY_GIVEN_ONLY - end: - targetState: RETURN_TO_RP - auditEvents: - - IPV_USER_DETAILS_UPDATE_ABORTED - back: - targetJourney: REPEAT_FRAUD_CHECK - targetState: START - auditEvents: - - IPV_USER_DETAILS_UPDATE_ABORTED - - FAMILY_ONLY_AFTER_REUSE: - response: - type: page - pageId: page-update-name - events: - update-name: - targetState: RESET_IDENTITY_FAMILY_ONLY - end: - targetState: RETURN_TO_RP - auditEvents: - - IPV_USER_DETAILS_UPDATE_ABORTED - - FAMILY_ONLY_AFTER_RFC: - response: - type: page - pageId: page-update-name - context: repeatFraudCheck - events: - update-name: - targetState: RESET_IDENTITY_FAMILY_ONLY - end: - targetState: RETURN_TO_RP - auditEvents: - - IPV_USER_DETAILS_UPDATE_ABORTED - back: - targetJourney: REPEAT_FRAUD_CHECK - targetState: START - auditEvents: - - IPV_USER_DETAILS_UPDATE_ABORTED - - RESET_IDENTITY_GIVEN_ONLY: + RESET_IDENTITY_NAMES_ONLY: response: type: process lambda: reset-session-identity @@ -176,166 +108,79 @@ states: resetType: NAME_ONLY_CHANGE events: next: - targetState: APP_DOC_CHECK_GIVEN_ONLY + targetState: APP_DOC_CHECK_NAMES_ONLY checkFeatureFlag: strategicAppEnabled: - targetState: STRATEGIC_APP_TRIAGE_GIVEN_ONLY + targetState: STRATEGIC_APP_TRIAGE_NAMES_ONLY targetEntryEvent: appTriage - STRATEGIC_APP_TRIAGE_GIVEN_ONLY: - nestedJourney: STRATEGIC_APP_TRIAGE - exitEvents: - next: - targetState: POST_APP_DOC_CHECK_GIVEN_ONLY - sessionError: - targetJourney: TECHNICAL_ERROR - targetState: ERROR - anotherWay: - targetJourney: FAILED - targetState: FAILED_UPDATE_DETAILS - - RESET_IDENTITY_FAMILY_ONLY: - response: - type: process - lambda: reset-session-identity - lambdaInput: - resetType: NAME_ONLY_CHANGE - events: - next: - targetState: APP_DOC_CHECK_FAMILY_ONLY - checkFeatureFlag: - strategicAppEnabled: - targetState: STRATEGIC_APP_TRIAGE_FAMILY_ONLY - targetEntryEvent: appTriage - - STRATEGIC_APP_TRIAGE_FAMILY_ONLY: - nestedJourney: STRATEGIC_APP_TRIAGE - exitEvents: - next: - targetState: POST_APP_DOC_CHECK_FAMILY_ONLY - sessionError: - targetJourney: TECHNICAL_ERROR - targetState: ERROR - anotherWay: - targetJourney: FAILED - targetState: FAILED_UPDATE_DETAILS - - APP_DOC_CHECK_GIVEN_ONLY: + APP_DOC_CHECK_NAMES_ONLY: nestedJourney: APP_DOC_CHECK exitEvents: next: - targetState: POST_APP_DOC_CHECK_GIVEN_ONLY + targetState: POST_APP_DOC_CHECK_NAMES_ONLY incomplete: targetJourney: FAILED targetState: FAILED_UPDATE_DETAILS incomplete-invalid-dl: - targetState: PROVE_IDENTITY_ANOTHER_WAY_AFTER_APP_DOC_CHECK_GIVEN_ONLY + targetState: PROVE_IDENTITY_ANOTHER_WAY_AFTER_APP_DOC_CHECK_NAMES_ONLY alternate-doc-invalid-dl: targetJourney: FAILED targetState: FAILED_CONFIRM_DETAILS_INVALID_ID - PROVE_IDENTITY_ANOTHER_WAY_AFTER_APP_DOC_CHECK_GIVEN_ONLY: + PROVE_IDENTITY_ANOTHER_WAY_AFTER_APP_DOC_CHECK_NAMES_ONLY: response: type: page pageId: prove-identity-another-way context: noF2f events: anotherTypePhotoId: - targetState: APP_DOC_CHECK_GIVEN_ONLY + targetState: APP_DOC_CHECK_NAMES_ONLY targetEntryEvent: next returnToRp: targetState: RETURN_TO_RP - APP_DOC_CHECK_FAMILY_ONLY: - nestedJourney: APP_DOC_CHECK + STRATEGIC_APP_TRIAGE_NAMES_ONLY: + nestedJourney: STRATEGIC_APP_TRIAGE exitEvents: next: - targetState: POST_APP_DOC_CHECK_FAMILY_ONLY - incomplete: + targetState: POST_APP_DOC_CHECK_NAMES_ONLY + sessionError: + targetJourney: TECHNICAL_ERROR + targetState: ERROR + anotherWay: targetJourney: FAILED targetState: FAILED_UPDATE_DETAILS - incomplete-invalid-dl: - targetState: PROVE_IDENTITY_ANOTHER_WAY_AFTER_APP_DOC_CHECK_FAMILY_ONLY - alternate-doc-invalid-dl: - targetJourney: FAILED - targetState: FAILED_CONFIRM_DETAILS_INVALID_ID - - PROVE_IDENTITY_ANOTHER_WAY_AFTER_APP_DOC_CHECK_FAMILY_ONLY: - response: - type: page - pageId: prove-identity-another-way - context: noF2f - events: - anotherTypePhotoId: - targetState: APP_DOC_CHECK_FAMILY_ONLY - targetEntryEvent: next - returnToRp: - targetState: RETURN_TO_RP - POST_APP_DOC_CHECK_GIVEN_ONLY: + POST_APP_DOC_CHECK_NAMES_ONLY: response: type: page pageId: page-dcmaw-success context: coiNoAddress events: next: - targetState: FRAUD_CHECK_GIVEN_ONLY + targetState: FRAUD_CHECK_NAMES_ONLY - POST_APP_DOC_CHECK_FAMILY_ONLY: - response: - type: page - pageId: page-dcmaw-success - context: coiNoAddress - events: - next: - targetState: FRAUD_CHECK_FAMILY_ONLY - - FRAUD_CHECK_GIVEN_ONLY: + FRAUD_CHECK_NAMES_ONLY: response: type: cri criId: fraud parent: CRI_STATE events: next: - targetState: CHECK_COI_GIVEN + targetState: CHECK_COI_NAMES enhanced-verification: targetJourney: FAILED targetState: FAILED_CONFIRM_DETAILS - FRAUD_CHECK_FAMILY_ONLY: - response: - type: cri - criId: fraud - parent: CRI_STATE - events: - next: - targetState: CHECK_COI_FAMILY - enhanced-verification: - targetJourney: FAILED - targetState: FAILED_CONFIRM_DETAILS - - # WITH ADDRESS - - GIVEN_WITH_ADDRESS_AFTER_REUSE: - response: - type: page - pageId: page-update-name - events: - update-name: - targetState: RESET_IDENTITY_GIVEN_WITH_ADDRESS - end: - targetState: RETURN_TO_RP - auditEvents: - - IPV_USER_DETAILS_UPDATE_ABORTED - - GIVEN_WITH_ADDRESS_AFTER_RFC: + NAMES_ONLY_AFTER_RFC: response: type: page pageId: page-update-name context: repeatFraudCheck events: update-name: - targetState: RESET_IDENTITY_GIVEN_WITH_ADDRESS + targetState: RESET_IDENTITY_NAMES_ONLY end: targetState: RETURN_TO_RP auditEvents: @@ -346,26 +191,28 @@ states: auditEvents: - IPV_USER_DETAILS_UPDATE_ABORTED - FAMILY_WITH_ADDRESS_AFTER_REUSE: + # WITH ADDRESS + + NAMES_WITH_ADDRESS_AFTER_REUSE: response: type: page pageId: page-update-name events: update-name: - targetState: RESET_IDENTITY_FAMILY_WITH_ADDRESS + targetState: RESET_IDENTITY_NAMES_WITH_ADDRESS end: targetState: RETURN_TO_RP auditEvents: - IPV_USER_DETAILS_UPDATE_ABORTED - FAMILY_WITH_ADDRESS_AFTER_RFC: + NAMES_WITH_ADDRESS_AFTER_RFC: response: type: page pageId: page-update-name context: repeatFraudCheck events: update-name: - targetState: RESET_IDENTITY_FAMILY_WITH_ADDRESS + targetState: RESET_IDENTITY_NAMES_WITH_ADDRESS end: targetState: RETURN_TO_RP auditEvents: @@ -376,33 +223,7 @@ states: auditEvents: - IPV_USER_DETAILS_UPDATE_ABORTED - RESET_IDENTITY_GIVEN_WITH_ADDRESS: - response: - type: process - lambda: reset-session-identity - lambdaInput: - resetType: ALL - events: - next: - targetState: APP_DOC_CHECK_GIVEN_WITH_ADDRESS - checkFeatureFlag: - strategicAppEnabled: - targetState: STRATEGIC_APP_TRIAGE_GIVEN_WITH_ADDRESS - targetEntryEvent: appTriage - - STRATEGIC_APP_TRIAGE_GIVEN_WITH_ADDRESS: - nestedJourney: STRATEGIC_APP_TRIAGE - exitEvents: - next: - targetState: POST_APP_DOC_CHECK_GIVEN_WITH_ADDRESS - sessionError: - targetJourney: TECHNICAL_ERROR - targetState: ERROR - anotherWay: - targetJourney: FAILED - targetState: FAILED_UPDATE_DETAILS - - RESET_IDENTITY_FAMILY_WITH_ADDRESS: + RESET_IDENTITY_NAMES_WITH_ADDRESS: response: type: process lambda: reset-session-identity @@ -410,17 +231,17 @@ states: resetType: ALL events: next: - targetState: APP_DOC_CHECK_FAMILY_WITH_ADDRESS + targetState: APP_DOC_CHECK_NAMES_WITH_ADDRESS checkFeatureFlag: strategicAppEnabled: - targetState: STRATEGIC_APP_TRIAGE_FAMILY_WITH_ADDRESS + targetState: STRATEGIC_APP_TRIAGE_NAMES_WITH_ADDRESS targetEntryEvent: appTriage - STRATEGIC_APP_TRIAGE_FAMILY_WITH_ADDRESS: + STRATEGIC_APP_TRIAGE_NAMES_WITH_ADDRESS: nestedJourney: STRATEGIC_APP_TRIAGE exitEvents: next: - targetState: POST_APP_DOC_CHECK_FAMILY_WITH_ADDRESS + targetState: POST_APP_DOC_CHECK_NAMES_WITH_ADDRESS sessionError: targetJourney: TECHNICAL_ERROR targetState: ERROR @@ -428,126 +249,62 @@ states: targetJourney: FAILED targetState: FAILED_UPDATE_DETAILS - APP_DOC_CHECK_GIVEN_WITH_ADDRESS: + APP_DOC_CHECK_NAMES_WITH_ADDRESS: nestedJourney: APP_DOC_CHECK exitEvents: next: - targetState: POST_APP_DOC_CHECK_GIVEN_WITH_ADDRESS + targetState: POST_APP_DOC_CHECK_NAMES_WITH_ADDRESS incomplete: targetJourney: FAILED targetState: FAILED_UPDATE_DETAILS incomplete-invalid-dl: - targetState: PROVE_IDENTITY_ANOTHER_WAY_AFTER_APP_DOC_CHECK_GIVEN_WITH_ADDRESS + targetState: PROVE_IDENTITY_ANOTHER_WAY_AFTER_APP_DOC_CHECK_NAMES_WITH_ADDRESS alternate-doc-invalid-dl: targetJourney: FAILED targetState: FAILED_CONFIRM_DETAILS_INVALID_ID - PROVE_IDENTITY_ANOTHER_WAY_AFTER_APP_DOC_CHECK_GIVEN_WITH_ADDRESS: + PROVE_IDENTITY_ANOTHER_WAY_AFTER_APP_DOC_CHECK_NAMES_WITH_ADDRESS: response: type: page pageId: prove-identity-another-way context: noF2f events: anotherTypePhotoId: - targetState: APP_DOC_CHECK_GIVEN_WITH_ADDRESS + targetState: APP_DOC_CHECK_NAMES_WITH_ADDRESS targetEntryEvent: next returnToRp: targetState: RETURN_TO_RP - APP_DOC_CHECK_FAMILY_WITH_ADDRESS: - nestedJourney: APP_DOC_CHECK - exitEvents: - next: - targetState: POST_APP_DOC_CHECK_FAMILY_WITH_ADDRESS - incomplete: - targetJourney: FAILED - targetState: FAILED_UPDATE_DETAILS - incomplete-invalid-dl: - targetState: PROVE_IDENTITY_ANOTHER_WAY_AFTER_APP_DOC_CHECK_FAMILY_WITH_ADDRESS - alternate-doc-invalid-dl: - targetJourney: FAILED - targetState: FAILED_CONFIRM_DETAILS_INVALID_ID - - PROVE_IDENTITY_ANOTHER_WAY_AFTER_APP_DOC_CHECK_FAMILY_WITH_ADDRESS: - response: - type: page - pageId: prove-identity-another-way - context: noF2f - events: - anotherTypePhotoId: - targetState: APP_DOC_CHECK_FAMILY_WITH_ADDRESS - targetEntryEvent: next - returnToRp: - targetState: RETURN_TO_RP - - POST_APP_DOC_CHECK_GIVEN_WITH_ADDRESS: - response: - type: page - pageId: page-dcmaw-success - context: coiAddress - events: - next: - targetState: ADDRESS_AND_FRAUD_GIVEN - checkFeatureFlag: - internationalAddressEnabled: - targetState: ADDRESS_AND_FRAUD_GIVEN - targetEntryEvent: internationalUser - - POST_APP_DOC_CHECK_FAMILY_WITH_ADDRESS: + POST_APP_DOC_CHECK_NAMES_WITH_ADDRESS: response: type: page pageId: page-dcmaw-success context: coiAddress events: next: - targetState: ADDRESS_AND_FRAUD_FAMILY + targetState: ADDRESS_AND_FRAUD checkFeatureFlag: internationalAddressEnabled: - targetState: ADDRESS_AND_FRAUD_FAMILY + targetState: ADDRESS_AND_FRAUD targetEntryEvent: internationalUser - ADDRESS_AND_FRAUD_GIVEN: + ADDRESS_AND_FRAUD: nestedJourney: ADDRESS_AND_FRAUD exitEvents: next: - targetState: CHECK_COI_GIVEN - enhanced-verification: - targetJourney: FAILED - targetState: FAILED_CONFIRM_DETAILS - - ADDRESS_AND_FRAUD_FAMILY: - nestedJourney: ADDRESS_AND_FRAUD - exitEvents: - next: - targetState: CHECK_COI_FAMILY + targetState: CHECK_COI_NAMES enhanced-verification: targetJourney: FAILED targetState: FAILED_CONFIRM_DETAILS # SHARED STATES - CHECK_COI_GIVEN: - response: - type: process - lambda: check-coi - lambdaInput: - checkType: FAMILY_NAME_AND_DOB - events: - coi-check-passed: - targetState: EVALUATE_GPG45_SCORES - coi-check-failed: - targetJourney: FAILED - targetState: FAILED_CONFIRM_DETAILS - error: - targetJourney: TECHNICAL_ERROR - targetState: ERROR - - CHECK_COI_FAMILY: + CHECK_COI_NAMES: response: type: process lambda: check-coi lambdaInput: - checkType: GIVEN_NAMES_AND_DOB + checkType: GIVEN_OR_FAMILY_NAME_AND_DOB events: coi-check-passed: targetState: EVALUATE_GPG45_SCORES @@ -571,6 +328,7 @@ states: vcs-not-correlated: targetJourney: FAILED targetState: FAILED_CONFIRM_DETAILS + STORE_IDENTITY_BEFORE_SUCCESS: response: type: process From f8db48bef4f4ca9be55e5e3cf790d67f9a84a050 Mon Sep 17 00:00:00 2001 From: Thea Bautista Date: Mon, 18 Nov 2024 16:10:31 +0000 Subject: [PATCH 4/6] PYIC-7701: update api tests --- .../p2-repeat-fraud-check-failure.feature | 4 +- .../p2-reuse-update-details.feature | 45 +++++-------------- 2 files changed, 13 insertions(+), 36 deletions(-) diff --git a/api-tests/features/repeat-fraud-check/p2-repeat-fraud-check-failure.feature b/api-tests/features/repeat-fraud-check/p2-repeat-fraud-check-failure.feature index 55cdfca578..2b70915a71 100644 --- a/api-tests/features/repeat-fraud-check/p2-repeat-fraud-check-failure.feature +++ b/api-tests/features/repeat-fraud-check/p2-repeat-fraud-check-failure.feature @@ -79,11 +79,11 @@ Feature: Repeat fraud check failures Then I get a 'pyi-no-match' page response Scenario: Failed COI check - When I submit 'kenneth-changed-family-name-driving-permit-valid' details to the CRI stub + When I submit 'alice-passport-valid' details to the CRI stub Then I get a 'page-dcmaw-success' page response with context 'coiNoAddress' When I submit a 'next' event Then I get a 'fraud' CRI response - When I submit 'kenneth-changed-family-name-score-2' details to the CRI stub + When I submit 'alice-score-2' details to the CRI stub Then I get a 'sorry-could-not-confirm-details' page response with context 'existingIdentityInvalid' When I submit a 'returnToRp' event Then I get an OAuth response diff --git a/api-tests/features/reuse-update-details/p2-reuse-update-details.feature b/api-tests/features/reuse-update-details/p2-reuse-update-details.feature index f2a9776176..1452e3a8ff 100644 --- a/api-tests/features/reuse-update-details/p2-reuse-update-details.feature +++ b/api-tests/features/reuse-update-details/p2-reuse-update-details.feature @@ -12,52 +12,29 @@ Feature: Identity reuse update details When I submit a 'update-details' event Then I get a 'update-details' page response - Scenario: Given Name Change Failure - When I submit a 'given-names-only' event + Scenario Outline: Successful name change - name change but user updates name instead + When I submit a '' event Then I get a 'page-update-name' page response When I submit a 'update-name' event Then I get a 'dcmaw' CRI response - When I submit 'kenneth-changed-family-name-driving-permit-valid' details to the CRI stub - Then I get a 'page-dcmaw-success' page response with context 'coiNoAddress' - When I submit a 'next' event - Then I get a 'fraud' CRI response - When I submit 'kenneth-changed-family-name-score-2' details to the CRI stub - Then I get a 'sorry-could-not-confirm-details' page response with context 'existingIdentityValid' - And an 'IPV_USER_DETAILS_UPDATE_END' audit event was recorded [local only] - - Scenario: Given Name Change - When I submit a 'given-names-only' event - Then I get a 'page-update-name' page response - When I submit a 'update-name' event - Then I get a 'dcmaw' CRI response - When I submit 'kenneth-changed-given-name-driving-permit-valid' details to the CRI stub + When I submit '
' details to the CRI stub Then I get a 'page-dcmaw-success' page response with context 'coiNoAddress' When I submit a 'next' event Then I get a 'fraud' CRI response - When I submit 'kenneth-changed-given-name-score-2' details to the CRI stub + When I submit '' details to the CRI stub Then I get a 'page-ipv-success' page response When I submit a 'next' event Then I get an OAuth response When I use the OAuth response to get my identity Then I get a 'P2' identity - And my identity 'GivenName' is 'Ken' + And my identity 'GivenName' is '' + And my identity 'FamilyName' is '' + And an 'IPV_USER_DETAILS_UPDATE_END' audit event was recorded [local only] - Scenario: Family Name Change - When I submit a 'family-name-only' event - Then I get a 'page-update-name' page response - When I submit a 'update-name' event - Then I get a 'dcmaw' CRI response - When I submit 'kenneth-changed-family-name-driving-permit-valid' details to the CRI stub - Then I get a 'page-dcmaw-success' page response with context 'coiNoAddress' - When I submit a 'next' event - Then I get a 'fraud' CRI response - When I submit 'kenneth-changed-family-name-score-2' details to the CRI stub - Then I get a 'page-ipv-success' page response - When I submit a 'next' event - Then I get an OAuth response - When I use the OAuth response to get my identity - Then I get a 'P2' identity - And my identity 'FamilyName' is 'Smith' + Examples: + | selected-name-change | actual-name-change | details | fraud-details | expected-given-name | expected-family-name | + | given-names-only | family | kenneth-changed-family-name-driving-permit-valid | kenneth-changed-family-name-score-2 | Kenneth | Smith | + | family-name-only | given | kenneth-changed-given-name-driving-permit-valid | kenneth-changed-given-name-score-2 | Ken | Decerqueira | Scenario: Address Change When I submit a 'address-only' event From d4e06c3eff28547deded69bcf7d58736874e0381 Mon Sep 17 00:00:00 2001 From: Thea Bautista Date: Mon, 18 Nov 2024 16:24:54 +0000 Subject: [PATCH 5/6] PYIC-7701: cut down rfc + reuse coi api tests a bit more --- .../p2-repeat-fraud-check.feature | 22 ------------------- .../p2-reuse-update-details.feature | 12 ---------- 2 files changed, 34 deletions(-) diff --git a/api-tests/features/repeat-fraud-check/p2-repeat-fraud-check.feature b/api-tests/features/repeat-fraud-check/p2-repeat-fraud-check.feature index 1c5556e6b8..5b4e026f21 100644 --- a/api-tests/features/repeat-fraud-check/p2-repeat-fraud-check.feature +++ b/api-tests/features/repeat-fraud-check/p2-repeat-fraud-check.feature @@ -50,16 +50,6 @@ Feature: Repeat fraud check journeys Then I get a 'dcmaw' CRI response When I submit 'kenneth-changed-family-name-driving-permit-valid' details to the CRI stub Then I get a 'page-dcmaw-success' page response with context 'coiNoAddress' - When I submit a 'next' event - Then I get a 'fraud' CRI response - When I submit 'kenneth-changed-family-name-score-2' details to the CRI stub - Then I get a 'page-ipv-success' page response - When I submit a 'next' event - Then I get an OAuth response - When I use the OAuth response to get my identity - Then I get a 'P2' identity - And my identity 'GivenName' is 'Kenneth' - And my identity 'FamilyName' is 'Smith' Scenario: Fraud 6 Months Expiry + Address Update # Repeat fraud check with update address @@ -105,18 +95,6 @@ Feature: Repeat fraud check journeys Then I get a 'dcmaw' CRI response When I submit 'kenneth-changed-given-name-driving-permit-valid' details to the CRI stub Then I get a 'page-dcmaw-success' page response with context 'coiAddress' - When I submit a 'next' event - Then I get a 'address' CRI response - When I submit 'kenneth-changed' details to the CRI stub - Then I get a 'fraud' CRI response - When I submit 'kenneth-changed-given-name-score-2' details to the CRI stub - Then I get a 'page-ipv-success' page response - When I submit a 'next' event - Then I get an OAuth response - When I use the OAuth response to get my identity - Then I get a 'P2' identity - And my identity 'GivenName' is 'Ken' - And my address 'streetName' is 'King Road' Scenario: Unsupported Changes # Repeat fraud check with various unsupported events and back navigation diff --git a/api-tests/features/reuse-update-details/p2-reuse-update-details.feature b/api-tests/features/reuse-update-details/p2-reuse-update-details.feature index 1452e3a8ff..b3cd6077cb 100644 --- a/api-tests/features/reuse-update-details/p2-reuse-update-details.feature +++ b/api-tests/features/reuse-update-details/p2-reuse-update-details.feature @@ -76,18 +76,6 @@ Feature: Identity reuse update details Then I get a 'dcmaw' CRI response When I submit 'kenneth-changed-given-name-driving-permit-valid' details to the CRI stub Then I get a 'page-dcmaw-success' page response with context 'coiAddress' - When I submit a 'next' event - Then I get a 'address' CRI response - When I submit 'kenneth-changed' details to the CRI stub - Then I get a 'fraud' CRI response - When I submit 'kenneth-changed-given-name-score-2' details to the CRI stub - Then I get a 'page-ipv-success' page response - When I submit a 'next' event - Then I get an OAuth response - When I use the OAuth response to get my identity - Then I get a 'P2' identity - And my identity 'GivenName' is 'Ken' - And my address 'streetName' is 'King Road' Scenario: Unsupported Changes When I submit a 'dob' event From a25de84d0ecdc1a81e01a399ccd06445c3239251 Mon Sep 17 00:00:00 2001 From: Thea Bautista Date: Mon, 18 Nov 2024 16:52:30 +0000 Subject: [PATCH 6/6] PYIC-7701: fix sonar errors --- .../core/checkcoi/CheckCoiHandlerTest.java | 77 +------------------ .../service/UserIdentityServiceTest.java | 60 +++++---------- 2 files changed, 20 insertions(+), 117 deletions(-) diff --git a/lambdas/check-coi/src/test/java/uk/gov/di/ipv/core/checkcoi/CheckCoiHandlerTest.java b/lambdas/check-coi/src/test/java/uk/gov/di/ipv/core/checkcoi/CheckCoiHandlerTest.java index ae2ed03759..05166bc078 100644 --- a/lambdas/check-coi/src/test/java/uk/gov/di/ipv/core/checkcoi/CheckCoiHandlerTest.java +++ b/lambdas/check-coi/src/test/java/uk/gov/di/ipv/core/checkcoi/CheckCoiHandlerTest.java @@ -145,7 +145,7 @@ private Optional getMockIdentityClaim() { @DisplayName("Successful checks") class SuccessfulChecks { @Test - void shouldReturnPassedForSuccessfulGivenNamesAndDobCheck() throws Exception { + void shouldReturnPassedForSuccessfulNamesAndDobCheck() throws Exception { when(mockUserIdentityService.areNamesAndDobCorrelated( List.of(M1A_ADDRESS_VC, M1A_EXPERIAN_FRAUD_VC))) .thenReturn(true); @@ -187,48 +187,6 @@ void shouldReturnPassedForSuccessfulGivenNamesAndDobCheck() throws Exception { assertTrue(restrictedAuditData.has("device_information")); } - @Test - void shouldReturnPassedForSuccessfulFamilyNameAndDobCheck() throws Exception { - when(mockUserIdentityService.areNamesAndDobCorrelated( - List.of(M1A_ADDRESS_VC, M1A_EXPERIAN_FRAUD_VC))) - .thenReturn(true); - when(mockClientSessionItem.getScopeClaims()) - .thenReturn(List.of(ScopeConstants.OPENID)); - - var request = - ProcessRequest.processRequestBuilder() - .ipvSessionId(IPV_SESSION_ID) - .lambdaInput( - Map.of("checkType", GIVEN_OR_FAMILY_NAME_AND_DOB.name())) - .build(); - - var responseMap = checkCoiHandler.handleRequest(request, mockContext); - - assertEquals(JOURNEY_COI_CHECK_PASSED_PATH, responseMap.get("journey")); - verify(mockAuditService, times(2)).sendAuditEvent(auditEventCaptor.capture()); - var auditEventsCaptured = auditEventCaptor.getAllValues(); - - assertEquals( - AuditEventTypes.IPV_CONTINUITY_OF_IDENTITY_CHECK_START, - auditEventsCaptured.get(0).getEventName()); - assertEquals( - new AuditExtensionCoiCheck(GIVEN_OR_FAMILY_NAME_AND_DOB, null), - auditEventsCaptured.get(0).getExtensions()); - assertEquals( - AuditEventTypes.IPV_CONTINUITY_OF_IDENTITY_CHECK_END, - auditEventsCaptured.get(1).getEventName()); - assertEquals( - new AuditExtensionCoiCheck(GIVEN_OR_FAMILY_NAME_AND_DOB, true), - auditEventsCaptured.get(1).getExtensions()); - var restrictedAuditData = - getRestrictedAuditDataNodeFromEvent(auditEventsCaptured.get(1)); - assertTrue(restrictedAuditData.has("newName")); - assertTrue(restrictedAuditData.has("oldName")); - assertTrue(restrictedAuditData.has("newBirthDate")); - assertTrue(restrictedAuditData.has("oldBirthDate")); - assertTrue(restrictedAuditData.has("device_information")); - } - @Test void shouldReturnPassedForSuccessfulFullNameAndDobCheck() throws Exception { when(mockUserIdentityService.areVcsCorrelated( @@ -578,38 +536,7 @@ void shouldReturnErrorIfCheckTypeNotInRequest() { } @Test - void shouldReturnErrorIfFamilyNameCorrelationCheckThrowsHttpResponseException() - throws Exception { - when(mockUserIdentityService.areNamesAndDobCorrelated( - List.of(M1A_ADDRESS_VC, M1A_EXPERIAN_FRAUD_VC))) - .thenThrow( - new HttpResponseExceptionWithErrorBody( - SC_SERVER_ERROR, FAILED_NAME_CORRELATION)); - - var request = - ProcessRequest.processRequestBuilder() - .ipvSessionId(IPV_SESSION_ID) - .lambdaInput(Map.of("checkType", GIVEN_OR_FAMILY_NAME_AND_DOB.name())) - .build(); - - var responseMap = checkCoiHandler.handleRequest(request, mockContext); - - assertEquals(JOURNEY_ERROR_PATH, responseMap.get("journey")); - assertEquals(FAILED_NAME_CORRELATION.getMessage(), responseMap.get("message")); - verify(mockAuditService, times(1)).sendAuditEvent(auditEventCaptor.capture()); - var auditEventsCaptured = auditEventCaptor.getAllValues(); - - assertEquals( - AuditEventTypes.IPV_CONTINUITY_OF_IDENTITY_CHECK_START, - auditEventsCaptured.get(0).getEventName()); - assertEquals( - new AuditExtensionCoiCheck(CoiCheckType.GIVEN_OR_FAMILY_NAME_AND_DOB, null), - auditEventsCaptured.get(0).getExtensions()); - } - - @Test - void shouldReturnErrorIfGivenNameCorrelationCheckThrowsHttpResponseException() - throws Exception { + void shouldReturnErrorIfNameCorrelationCheckThrowsHttpResponseException() throws Exception { when(mockUserIdentityService.areNamesAndDobCorrelated( List.of(M1A_ADDRESS_VC, M1A_EXPERIAN_FRAUD_VC))) .thenThrow( diff --git a/libs/user-identity-service/src/test/java/uk/gov/di/ipv/core/library/service/UserIdentityServiceTest.java b/libs/user-identity-service/src/test/java/uk/gov/di/ipv/core/library/service/UserIdentityServiceTest.java index 2783ab6188..c2d39e1ed3 100644 --- a/libs/user-identity-service/src/test/java/uk/gov/di/ipv/core/library/service/UserIdentityServiceTest.java +++ b/libs/user-identity-service/src/test/java/uk/gov/di/ipv/core/library/service/UserIdentityServiceTest.java @@ -554,32 +554,32 @@ void areVCsCorrelatedReturnsFalseWhenExtraBirthDateInVc() throws Exception { @Nested class AreNamesAndDobCorrelated { - private VerifiableCredential PASSPORT_VC_JIMBO_JONES_2000_01_01 = + private VerifiableCredential jimboJones2000 = generateVerifiableCredential( USER_ID_1, PASSPORT, createCredentialWithNameAndBirthDate("Jimbo", "Jones", "2000-01-01")); - private VerifiableCredential PASSPORT_VC_JIMBO_SMITH_2000_01_01 = + private VerifiableCredential jimboSmith2000 = generateVerifiableCredential( USER_ID_1, PASSPORT, createCredentialWithNameAndBirthDate("Jimbo", "SMITH", "2000-01-01")); - private VerifiableCredential PASSPORT_VC_TIMMY_JONES_2000_01_01 = + private VerifiableCredential timmyJones2000 = generateVerifiableCredential( USER_ID_1, PASSPORT, createCredentialWithNameAndBirthDate("Timmy", "Jones", "2000-01-01")); - private VerifiableCredential PASSPORT_VC_TIMMY_SMITH_2000_01_01 = + private VerifiableCredential timmySmith2000 = generateVerifiableCredential( USER_ID_1, PASSPORT, createCredentialWithNameAndBirthDate("Timmy", "Smith", "2000-01-01")); - private VerifiableCredential PASSPORT_VC_JIMBO_JONES_2002_02_02 = + private VerifiableCredential jimboJones2002 = generateVerifiableCredential( USER_ID_1, PASSPORT, createCredentialWithNameAndBirthDate("Timmy", "Smith", "2002-02-02")); - private VerifiableCredential PASSPORT_VC_JIMBO_JONATHON_JONES_2002_02_02 = + private VerifiableCredential jimboJonathonJones2002 = generateVerifiableCredential( USER_ID_1, PASSPORT, @@ -595,11 +595,7 @@ void setup() { void shouldReturnTrueForCorrelatedGivenNamesAndDobAndDifferentFamilyNames() throws Exception { // Arrange - var vcs = - List.of( - PASSPORT_VC_JIMBO_JONES_2000_01_01, - PASSPORT_VC_JIMBO_JONES_2000_01_01, - PASSPORT_VC_JIMBO_SMITH_2000_01_01); + var vcs = List.of(jimboJones2000, jimboJones2000, jimboSmith2000); // Act & Assert assertTrue(userIdentityService.areNamesAndDobCorrelated(vcs)); @@ -609,11 +605,7 @@ void shouldReturnTrueForCorrelatedGivenNamesAndDobAndDifferentFamilyNames() void shouldReturnTrueForCorrelatedFamilyNamesAndDobAndDifferentGivenNames() throws Exception { // Arrange - var vcs = - List.of( - PASSPORT_VC_JIMBO_JONES_2000_01_01, - PASSPORT_VC_JIMBO_JONES_2000_01_01, - PASSPORT_VC_TIMMY_JONES_2000_01_01); + var vcs = List.of(jimboJones2000, jimboJones2000, timmyJones2000); // Act & Assert assertTrue(userIdentityService.areNamesAndDobCorrelated(vcs)); @@ -623,11 +615,7 @@ void shouldReturnTrueForCorrelatedFamilyNamesAndDobAndDifferentGivenNames() void shouldReturnTrueWhenFamilyNameShorterThanCheckChars() throws Exception { // Arrange when(mockConfigService.getParameter(COI_CHECK_FAMILY_NAME_CHARS)).thenReturn("500"); - var vcs = - List.of( - PASSPORT_VC_JIMBO_JONES_2000_01_01, - PASSPORT_VC_JIMBO_JONES_2000_01_01, - PASSPORT_VC_JIMBO_SMITH_2000_01_01); + var vcs = List.of(jimboJones2000, jimboJones2000, jimboSmith2000); // Act & Assert assertTrue(userIdentityService.areNamesAndDobCorrelated(vcs)); @@ -636,11 +624,7 @@ void shouldReturnTrueWhenFamilyNameShorterThanCheckChars() throws Exception { @Test void shouldReturnFalseIfGivenNamesAndFamilyNamesBothDiffer() throws Exception { // Arrange - var vcs = - List.of( - PASSPORT_VC_JIMBO_JONES_2000_01_01, - PASSPORT_VC_JIMBO_JONES_2000_01_01, - PASSPORT_VC_TIMMY_SMITH_2000_01_01); + var vcs = List.of(jimboJones2000, jimboJones2000, timmySmith2000); // Act & Assert assertFalse(userIdentityService.areNamesAndDobCorrelated(vcs)); @@ -649,11 +633,7 @@ void shouldReturnFalseIfGivenNamesAndFamilyNamesBothDiffer() throws Exception { @Test void shouldReturnFalseIfExtraGivenName() throws Exception { // Arrange - var vcs = - List.of( - PASSPORT_VC_JIMBO_JONES_2000_01_01, - PASSPORT_VC_JIMBO_JONES_2000_01_01, - PASSPORT_VC_JIMBO_JONATHON_JONES_2002_02_02); + var vcs = List.of(jimboJones2000, jimboJones2000, jimboJonathonJones2002); // Act & Assert assertFalse(userIdentityService.areNamesAndDobCorrelated(vcs)); @@ -662,11 +642,7 @@ void shouldReturnFalseIfExtraGivenName() throws Exception { @Test void shouldReturnFalseIfDobDiffers() throws Exception { // Arrange - var vcs = - List.of( - PASSPORT_VC_JIMBO_JONES_2000_01_01, - PASSPORT_VC_JIMBO_JONES_2000_01_01, - PASSPORT_VC_JIMBO_JONES_2002_02_02); + var vcs = List.of(jimboJones2000, jimboJones2000, jimboJones2002); // Act & Assert assertFalse(userIdentityService.areNamesAndDobCorrelated(vcs)); @@ -678,8 +654,8 @@ void shouldThrowIfMissingGivenName(String missingName) { // Arrange var vcs = List.of( - PASSPORT_VC_JIMBO_JONES_2000_01_01, - PASSPORT_VC_JIMBO_JONES_2000_01_01, + jimboJones2000, + jimboJones2000, generateVerifiableCredential( USER_ID_1, PASSPORT, @@ -704,8 +680,8 @@ void shouldThrowIfMissingFamilyName(String missingName) { // Arrange var vcs = List.of( - PASSPORT_VC_JIMBO_JONES_2000_01_01, - PASSPORT_VC_JIMBO_JONES_2000_01_01, + jimboJones2000, + jimboJones2000, generateVerifiableCredential( USER_ID_1, PASSPORT, @@ -729,8 +705,8 @@ void shouldThrowIfMissingDob(String missingDob) { // Arrange var vcs = List.of( - PASSPORT_VC_JIMBO_JONES_2000_01_01, - PASSPORT_VC_JIMBO_JONES_2000_01_01, + jimboJones2000, + jimboJones2000, generateVerifiableCredential( USER_ID_1, PASSPORT,