diff options
author | Thomas <> | 2022-12-01 12:10:45 +0100 |
---|---|---|
committer | Thomas <> | 2022-12-01 12:10:45 +0100 |
commit | 1923066ca9db0eacb8c1776b657705ef9b173448 (patch) | |
tree | 13ab6d39849a5a1261e5fbd9aca321254a4506ad /modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas | |
parent | bb04051b8854d452a94df8488157e5234e1afea7 (diff) | |
download | National_eIDAS_Gateway-1923066ca9db0eacb8c1776b657705ef9b173448.tar.gz National_eIDAS_Gateway-1923066ca9db0eacb8c1776b657705ef9b173448.tar.bz2 National_eIDAS_Gateway-1923066ca9db0eacb8c1776b657705ef9b173448.zip |
feat(matching): add flag 'allowNewErnpEntryByUser' into intermediate matching-result
That flag disable a new ERnP entry by user decision
Diffstat (limited to 'modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas')
5 files changed, 126 insertions, 24 deletions
diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java index 305220cf..35560284 100644 --- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java +++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java @@ -334,7 +334,7 @@ public class AlternativeSearchTaskWithRegisterTest { // inject matching intermediate state RegisterStatusResults matchingState = new RegisterStatusResults( - new RegisterOperationStatus(new BigInteger(RandomStringUtils.randomNumeric(5))), + new RegisterOperationStatus(new BigInteger(RandomStringUtils.randomNumeric(5)), true), Arrays.asList(RegisterResult.builder() .bpk("") .givenName("XXXKlaus - Maria") @@ -454,7 +454,7 @@ public class AlternativeSearchTaskWithRegisterTest { // inject matching intermediate state RegisterStatusResults matchingState = new RegisterStatusResults( - new RegisterOperationStatus(new BigInteger(RandomStringUtils.randomNumeric(5))), + new RegisterOperationStatus(new BigInteger(RandomStringUtils.randomNumeric(5)), true), Arrays.asList(RegisterResult.builder() .bpk("UgeknNsc26lVuB7U/uYGVmWtnnA=") .givenName("XXXKlaus - Maria") @@ -550,7 +550,7 @@ public class AlternativeSearchTaskWithRegisterTest { // inject matching intermediate state RegisterStatusResults matchingState = new RegisterStatusResults( - new RegisterOperationStatus(new BigInteger(RandomStringUtils.randomNumeric(5))), + new RegisterOperationStatus(new BigInteger(RandomStringUtils.randomNumeric(5)), true), Arrays.asList(RegisterResult.builder() .bpk("UgeknNsc26lVuB7U/uYGVmWtnnA=") .givenName("XXXKlaus - Maria") @@ -651,7 +651,7 @@ public class AlternativeSearchTaskWithRegisterTest { // inject matching intermediate state RegisterStatusResults matchingState = new RegisterStatusResults( - new RegisterOperationStatus(new BigInteger(RandomStringUtils.randomNumeric(5))), + new RegisterOperationStatus(new BigInteger(RandomStringUtils.randomNumeric(5)), true), Arrays.asList(RegisterResult.builder() .bpk("UgeknNsc26lVuB7U/uYGVmWtnnA=") .givenName("XXXKlaus - Maria") @@ -714,7 +714,7 @@ public class AlternativeSearchTaskWithRegisterTest { // inject matching intermediate state RegisterStatusResults matchingState = new RegisterStatusResults( - new RegisterOperationStatus(new BigInteger(RandomStringUtils.randomNumeric(5))), + new RegisterOperationStatus(new BigInteger(RandomStringUtils.randomNumeric(5)), true), Arrays.asList(RegisterResult.builder() .bpk("UgeknNsc26lVuB7U/uYGVmWtnnA=") .givenName("XXXKlaus - Maria") @@ -793,7 +793,7 @@ public class AlternativeSearchTaskWithRegisterTest { // inject matching intermediate state RegisterStatusResults matchingState = new RegisterStatusResults( - new RegisterOperationStatus(new BigInteger(RandomStringUtils.randomNumeric(5))), + new RegisterOperationStatus(new BigInteger(RandomStringUtils.randomNumeric(5)), true), Arrays.asList(RegisterResult.builder() .bpk("UgeknNsc26lVuB7U/uYGVmWtnnA=") .givenName("XXXKlaus - Maria") diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java index ca78e156..20a1bb7f 100644 --- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java +++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java @@ -806,7 +806,7 @@ public class InitialSearchTaskTest { task.execute(pendingReq, executionContext); // validate state - checkIntermediateResult(1); + checkIntermediateResult(1, true); } @@ -837,7 +837,7 @@ public class InitialSearchTaskTest { task.execute(pendingReq, executionContext); // validate state - checkIntermediateResult(1); + checkIntermediateResult(1, true); } @@ -869,7 +869,7 @@ public class InitialSearchTaskTest { task.execute(pendingReq, executionContext); // validate state - checkIntermediateResult(2); + checkIntermediateResult(2, true); DetailedMatchtingStatistic entry = MatchingTaskUtils.getDetailedMatchingStatistic(pendingReq); assertNotNull("statisticLogEntry", entry); @@ -881,6 +881,94 @@ public class InitialSearchTaskTest { } /** + * Find matches with MDS search in ZMR and ERnP. + */ + @Test + @DirtiesContext + @SneakyThrows + public void resultByMdsSearch_ZmrAndClosedErnp() throws TaskExecutionException, EidasSAuthenticationException { + BigInteger zmrProcessId = generateRandomProcessId(); + Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE)) + .thenReturn(new ZmrRegisterResult(Collections.emptyList(), zmrProcessId)); + Mockito.when(zmrClient.searchWithMds(zmrProcessId, randomGivenName, randomFamilyName, randomBirthDate, DE)) + .thenReturn(zmrRegisterResult(randomRegisterResult(), zmrProcessId)); + Mockito.when(zmrClient.update(any(), any(), any())) + .thenThrow(new IllegalStateException("ZMR update should not be neccessary")); + + Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)).thenReturn( + closedErnpRegisterResult()); + Mockito.when(ernpClient.searchWithMds(randomGivenName, randomFamilyName, randomBirthDate, DE)) + .thenReturn(ernpRegisterResult(randomRegisterResult(RandomStringUtils.randomAlphanumeric(10)))); + Mockito.when(ernpClient.update(any(), any())) + .thenThrow(new IllegalStateException("ERnP update should not be neccessary")); + + + + // execute test + task.execute(pendingReq, executionContext); + + // validate state + checkIntermediateResult(2, false); + + DetailedMatchtingStatistic entry = MatchingTaskUtils.getDetailedMatchingStatistic(pendingReq); + assertNotNull("statisticLogEntry", entry); + assertEquals("ZMR", 0, entry.getPersonalIdResult().getZmrResults()); + assertEquals("ERnP", 0, entry.getPersonalIdResult().getErnpResults()); + assertEquals("ZMR", 1, entry.getMdsResult().getZmrResults()); + assertEquals("ERnP", 1, entry.getMdsResult().getErnpResults()); + + } + + /** + * Find matches with MDS search in ZMR and ERnP. + */ + @Test + @DirtiesContext + @SneakyThrows + public void resultByMdsSearch_ZmrAndClosedErnpCcSpecific() throws TaskExecutionException, EidasSAuthenticationException { + final AuthenticationResponse response = buildDummyAuthResponseDE(randomGivenName, randomFamilyName, + randomPersonalIdentifier_DE, randomBirthDate, randomPlaceOfBirth, randomBirthName); + TestRequestImpl pendingReq1 = new TestRequestImpl(); + pendingReq1.getSessionData(AuthProcessDataWrapper.class) + .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response); + + BigInteger zmrProcessId = generateRandomProcessId(); + Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE)) + .thenReturn(new ZmrRegisterResult(Collections.emptyList(), zmrProcessId)); + Mockito.when(zmrClient.searchCountrySpecific(any(),any(), eq(DE))) + .thenReturn(new ZmrRegisterResult(Collections.emptyList(), zmrProcessId)); + Mockito.when(zmrClient.searchWithMds(zmrProcessId, randomGivenName, randomFamilyName, randomBirthDate, DE)) + .thenReturn(zmrRegisterResult(randomRegisterResult(), zmrProcessId)); + Mockito.when(zmrClient.update(any(), any(), any())) + .thenThrow(new IllegalStateException("ZMR update should not be neccessary")); + + Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)).thenReturn( + emptyErnpRegisterResult()); + Mockito.when(ernpClient.searchCountrySpecific(any(), eq(DE))).thenReturn( + closedErnpRegisterResult()); + Mockito.when(ernpClient.searchWithMds(randomGivenName, randomFamilyName, randomBirthDate, DE)) + .thenReturn(ernpRegisterResult(randomRegisterResult(RandomStringUtils.randomAlphanumeric(10)))); + Mockito.when(ernpClient.update(any(), any())) + .thenThrow(new IllegalStateException("ERnP update should not be neccessary")); + + + + // execute test + task.execute(pendingReq1, executionContext); + + // validate state + checkIntermediateResult(pendingReq1, 2, false); + + DetailedMatchtingStatistic entry = MatchingTaskUtils.getDetailedMatchingStatistic(pendingReq1); + assertNotNull("statisticLogEntry", entry); + assertEquals("ZMR", 0, entry.getPersonalIdResult().getZmrResults()); + assertEquals("ERnP", 0, entry.getPersonalIdResult().getErnpResults()); + assertEquals("ZMR", 1, entry.getMdsResult().getZmrResults()); + assertEquals("ERnP", 1, entry.getMdsResult().getErnpResults()); + + } + + /** * resultByMdsSearch */ @Test @@ -905,7 +993,7 @@ public class InitialSearchTaskTest { task.execute(pendingReq, executionContext); // validate state - checkIntermediateResult(3); + checkIntermediateResult(3, true); } @@ -920,6 +1008,11 @@ public class InitialSearchTaskTest { } @NotNull + private ErnpRegisterResult closedErnpRegisterResult() { + return new ErnpRegisterResult(Collections.emptyList(), false); + } + + @NotNull private ZmrRegisterResult zmrRegisterResult(RegisterResult registerResult, BigInteger processId) { return new ZmrRegisterResult(Collections.singletonList(registerResult), processId); } @@ -1011,20 +1104,29 @@ public class InitialSearchTaskTest { } - private void checkIntermediateResult(int resultSize) { + private void checkIntermediateResult(TestRequestImpl pendingReq1, int resultSize, boolean allowNewErnp) { Boolean transitionGUI = (Boolean) executionContext.get(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK); Assert.assertTrue("Wrong transition", transitionGUI); Boolean transitionErnb = (Boolean) executionContext.get(Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK); Assert.assertNull("Wrong transition", transitionErnb); - assertNotNull("find no eIDAS inbut data", MatchingTaskUtils.getInitialEidasData(pendingReq)); + assertNotNull("find no eIDAS inbut data", MatchingTaskUtils.getInitialEidasData(pendingReq1)); assertNull("Find final matching data but no match sould be found", - MatchingTaskUtils.getFinalMatchingResult(pendingReq)); + MatchingTaskUtils.getFinalMatchingResult(pendingReq1)); - RegisterStatusResults result = MatchingTaskUtils.getIntermediateMatchingResult(pendingReq); + RegisterStatusResults result = MatchingTaskUtils.getIntermediateMatchingResult(pendingReq1); assertNotNull("Find no intermediate matching data", result); assertEquals("wrong intermediate result size", resultSize, result.getResultCount()); + assertNotNull("no operationStatus", result.getOperationStatus()); + assertEquals("newErnpEntryFlag", allowNewErnp, result.getOperationStatus().isAllowErnpEntryByUser()); + + + } + + private void checkIntermediateResult(int resultSize, boolean allowNewErnp) { + checkIntermediateResult(pendingReq, resultSize, allowNewErnp); + } @NotNull diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskRegisterTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskRegisterTest.java index 8d3959f4..a3e8ee9c 100644 --- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskRegisterTest.java +++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskRegisterTest.java @@ -240,7 +240,7 @@ public class ReceiveAustrianResidenceGuiResponseTaskRegisterTest { @NotNull private RegisterStatusResults buildEmptyResult() { - return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), + return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId(), true), Collections.emptyList(), Collections.emptyList()); } @@ -252,7 +252,7 @@ public class ReceiveAustrianResidenceGuiResponseTaskRegisterTest { @NotNull private RegisterStatusResults buildResultWithOneMatch(RegisterResult registerResult) { - return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), + return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId(), true), Collections.singletonList(registerResult), Collections.emptyList()); } @@ -260,7 +260,7 @@ public class ReceiveAustrianResidenceGuiResponseTaskRegisterTest { @NotNull private RegisterStatusResults buildResultWithTwoMatches() { List<RegisterResult> results = Lists.newArrayList(buildRandomRegisterResult(), buildRandomRegisterResult()); - return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), + return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId(), true), results, Collections.emptyList()); } diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskTest.java index 83284455..581dee0d 100644 --- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskTest.java +++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskTest.java @@ -237,7 +237,7 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { @NotNull private RegisterStatusResults buildEmptyResult() { - return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), + return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId(), true), Collections.emptyList(), Collections.emptyList()); } @@ -249,7 +249,7 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { @NotNull private RegisterStatusResults buildResultWithOneMatch(RegisterResult registerResult) { - return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), + return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId(), true), Collections.singletonList(registerResult), Collections.emptyList()); } @@ -257,7 +257,7 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { @NotNull private RegisterStatusResults buildResultWithTwoMatches() { List<RegisterResult> results = Lists.newArrayList(buildRandomRegisterResult(), buildRandomRegisterResult()); - return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), + return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId(), true), results, Collections.emptyList()); } diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseTaskTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseTaskTest.java index 034f06d1..9bb27100 100644 --- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseTaskTest.java +++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseTaskTest.java @@ -344,7 +344,7 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest { AuthProcessDataWrapper authProcessData = pendingReq.getSessionData(AuthProcessDataWrapper.class); SimpleEidasData eidData = createEidasDataMatchingToSamlResponse().build(); authProcessData.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, eidData); - RegisterStatusResults registerSearchResult = new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), + RegisterStatusResults registerSearchResult = new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId(), true), Collections.emptyList(), Collections.emptyList()); MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerSearchResult); @@ -426,7 +426,7 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest { @NotNull private RegisterStatusResults buildResultWithOneMatch() { - return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), + return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId(), true), Collections.singletonList(RegisterResult.builder() .bpk(BPK_FROM_ID_AUSTRIA) .pseudonym(Arrays.asList("bar")) @@ -456,10 +456,10 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest { .dateOfBirth("dateOfBirth") .build()); - return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), + return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId(), true), results, Collections.emptyList()); } - + private BigInteger generateRandomProcessId() { return new BigInteger(RandomStringUtils.randomNumeric(10)); |