diff options
Diffstat (limited to 'modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java')
-rw-r--r-- | modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java | 118 |
1 files changed, 110 insertions, 8 deletions
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 |