From c25f53f2ae3522f2cea1707b8869187013bba8e9 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Fri, 21 Oct 2022 20:54:25 +0200 Subject: test(matching): add some more validations for advanced statistic log --- .../tasks/AlternativeSearchTaskWithRegisterTest.java | 5 +++++ .../eidas/v2/test/tasks/InitialSearchTaskTest.java | 20 +++++++++++++++++--- .../ReceiveAustrianResidenceGuiResponseTaskTest.java | 9 +++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) (limited to 'modules/authmodule-eIDAS-v2/src/test') 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 176e95cb..25a8a5b5 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 @@ -60,6 +60,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasAttribute import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.WorkflowException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.CountrySpecificDetailSearchProcessor; import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.GenericEidProcessor; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.log.statistic.DetailedMatchtingStatistic; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.ICcSpecificEidProcessingService; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterOperationStatus; @@ -521,6 +522,10 @@ public class AlternativeSearchTaskWithRegisterTest { checkBasicRequestParameters(zmrReq.getAllValues().get(3), ZmrClientTest.PROCESS_TASK_SEARCH, new BigInteger("367100000000079"), "jUnit123456"); + DetailedMatchtingStatistic entry = MatchingTaskUtils.getDetailedMatchingStatistic(pendingReq); + assertNotNull("statisticLogEntry", entry); + assertEquals("use eIDAS count", 1, entry.getEidasLoginUsed()); + } @Test 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 1ce48a2e..6292a0e1 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 @@ -80,6 +80,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.WorkflowExcept import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.ZmrCommunicationException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.CountrySpecificDetailSearchProcessor; import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.GenericEidProcessor; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.log.statistic.DetailedMatchtingStatistic; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.ICcSpecificEidProcessingService; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterStatusResults; @@ -523,7 +524,12 @@ public class InitialSearchTaskTest { task.execute(pendingReq, executionContext); // validate state - checkMatchingSuccessState(pendingReq, randomBpk, randomFamilyName, randomGivenName, randomBirthDate, DE); + checkMatchingSuccessState(pendingReq, randomBpk, randomFamilyName, randomGivenName, randomBirthDate, DE); + DetailedMatchtingStatistic entry = MatchingTaskUtils.getDetailedMatchingStatistic(pendingReq); + assertNotNull("statisticLogEntry", entry); + assertEquals("ZMR", 1, entry.getPersonalIdResult().getZmrResults()); + assertEquals("ERnP", 0, entry.getPersonalIdResult().getErnpResults()); + } /** @@ -685,7 +691,7 @@ public class InitialSearchTaskTest { assertTrue("Wrong exception", (exception.getOriginalException() instanceof WorkflowException)); assertTrue("Wrong flag 'manualFixNeeded'", ((WorkflowException) exception.getOriginalException()).isRequiresManualFix()); - + } /** @@ -838,6 +844,7 @@ public class InitialSearchTaskTest { */ @Test @DirtiesContext + @SneakyThrows public void resultByMdsSearch_ZmrAndErnp() throws TaskExecutionException, EidasSAuthenticationException { BigInteger zmrProcessId = generateRandomProcessId(); Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE)) @@ -861,7 +868,14 @@ public class InitialSearchTaskTest { // validate state checkIntermediateResult(2); - + + 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()); + } /** 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 d7c0acc4..3bd86e63 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 @@ -35,6 +35,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.controller.AdresssucheCo import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MatchedPersonResult; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.log.statistic.DetailedMatchtingStatistic; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterOperationStatus; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterStatusResults; @@ -123,6 +124,10 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { assertEquals("failed reason", "module.eidasauth.matching.21", executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON)); assertNull("no final matching result", MatchingTaskUtils.getFinalMatchingResult(pendingReq)); + DetailedMatchtingStatistic entry = MatchingTaskUtils.getDetailedMatchingStatistic(pendingReq); + assertNotNull("statisticLogEntry", entry); + assertEquals("registerSearchCount", 0, entry.getAddressSearchUsed()); + } @Test @@ -142,6 +147,10 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { assertEquals("failed reason", "module.eidasauth.matching.22", executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED_REASON)); assertNull("no final matching result", MatchingTaskUtils.getFinalMatchingResult(pendingReq)); + DetailedMatchtingStatistic entry = MatchingTaskUtils.getDetailedMatchingStatistic(pendingReq); + assertNotNull("statisticLogEntry", entry); + assertEquals("registerSearchCount", 1, entry.getAddressSearchUsed()); + } @Test -- cgit v1.2.3