diff options
author | Thomas <> | 2021-06-16 11:51:11 +0200 |
---|---|---|
committer | Thomas <> | 2021-06-16 11:51:11 +0200 |
commit | 249e3805da249afafe164ae7dc43884ba3777727 (patch) | |
tree | 4d2ffdbe5c5f944b5d58e2efd6fa2b91096d1a87 /eidas_modules/authmodule-eIDAS-v2/src/test/java | |
parent | 6e1a69773284177a0f6c7233c4bcdf7f4bd96681 (diff) | |
download | National_eIDAS_Gateway-249e3805da249afafe164ae7dc43884ba3777727.tar.gz National_eIDAS_Gateway-249e3805da249afafe164ae7dc43884ba3777727.tar.bz2 National_eIDAS_Gateway-249e3805da249afafe164ae7dc43884ba3777727.zip |
add ZMR update process into ZMRClient
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/test/java')
3 files changed, 54 insertions, 31 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java index bb732f1c..cca94188 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java @@ -80,7 +80,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.CountrySpecificD import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.GenericEidProcessor; 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.RegisterSearchResult; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterStatusResults; import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.InitialSearchTask; import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.MatchingTaskUtils; import at.gv.bmi.namespace.zmr_su.zmr._20040201.PersonSuchenRequest; @@ -196,6 +196,8 @@ public class InitialSearchTaskTest { new IllegalStateException("CountrySpecific search search should not be neccessary")); Mockito.when(zmrClient.searchWithMds(any(), any(), any(), any(), any())).thenThrow( new IllegalStateException("MDS search should not be neccessary")); + Mockito.when(zmrClient.update(any(), any(), any())).thenThrow( + new IllegalStateException("ZMR update should not be neccessary")); // execute test task.execute(pendingReq, executionContext); @@ -422,7 +424,9 @@ public class InitialSearchTaskTest { .build()), generateRandomProcessId())); Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE)).thenReturn(Collections.emptyList()); - + Mockito.when(zmrClient.update(any(), any(), any())).thenThrow( + new IllegalStateException("ZMR update should not be neccessary")); + // execute test task.execute(pendingReq, executionContext); @@ -443,20 +447,31 @@ public class InitialSearchTaskTest { .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response); BigInteger zmrProcessId = generateRandomProcessId(); + RegisterResult zmrResult = RegisterResult.builder() + .bpk(randomBpk) + .pseudonym(Arrays.asList(randomPsydonym)) + .givenName(randomGivenName) + .familyName(randomFamilyName) + .dateOfBirth(randomBirthDate) + .placeOfBirth(randomPlaceOfBirth) + .birthName(randomBirthName) + .build(); Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPsydonym, DE)).thenReturn( new ZmrRegisterResult(Collections.emptyList(), zmrProcessId)); Mockito.when(zmrClient.searchCountrySpecific(eq(zmrProcessId), any(PersonSuchenRequest.class), eq(DE))).thenReturn( - new ZmrRegisterResult(Collections.singletonList( - RegisterResult.builder() + new ZmrRegisterResult(Collections.singletonList(zmrResult) + ,zmrProcessId)); + Mockito.when(zmrClient.update(eq(zmrProcessId), eq(zmrResult) , any())).thenReturn( + new ZmrRegisterResult(Collections.singletonList(RegisterResult.builder() .bpk(randomBpk) - .pseudonym(Arrays.asList(randomPsydonym)) + .pseudonym(Arrays.asList(randomPsydonym, RandomStringUtils.randomAlphanumeric(10))) .givenName(randomGivenName) .familyName(randomFamilyName) .dateOfBirth(randomBirthDate) .placeOfBirth(randomPlaceOfBirth) .birthName(randomBirthName) - .build()) - ,zmrProcessId)); + .build()) + ,zmrProcessId)); Mockito.when(zmrClient.searchWithMds(any(), any(), any(), any(), any())).thenThrow( new IllegalStateException("MDS search should not be neccessary")); @@ -541,9 +556,12 @@ public class InitialSearchTaskTest { new ZmrRegisterResult(Collections.emptyList(), zmrProcessId)); Mockito.when(zmrClient.searchWithMds(zmrProcessId, randomGivenName, randomFamilyName, randomBirthDate, EE)).thenReturn( new ZmrRegisterResult(Collections.emptyList(), zmrProcessId)); + Mockito.when(zmrClient.update(any(), any(), any())).thenThrow( + new IllegalStateException("ZMR update should not be neccessary")); Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_EE)).thenReturn(Collections.emptyList()); + // execute task task.execute(pendingReq, executionContext); @@ -608,8 +626,6 @@ public class InitialSearchTaskTest { BigInteger zmrProcessId = generateRandomProcessId(); Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPsydonym, DE)).thenReturn( new ZmrRegisterResult(Collections.emptyList(), zmrProcessId)); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE)).thenReturn(Collections.emptyList()); - Mockito.when(zmrClient.searchWithMds(zmrProcessId, randomGivenName, randomFamilyName, randomBirthDate, DE)).thenReturn( new ZmrRegisterResult(Collections.singletonList(RegisterResult.builder() .bpk(randomBpk) @@ -619,7 +635,12 @@ public class InitialSearchTaskTest { .dateOfBirth(randomBirthDate) .build()), zmrProcessId)); - + Mockito.when(zmrClient.update(any(), any(), any())).thenThrow( + new IllegalStateException("ZMR update should not be neccessary")); + + Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE)).thenReturn(Collections.emptyList()); + + // execute test task.execute(pendingReq, executionContext); @@ -649,7 +670,9 @@ public class InitialSearchTaskTest { .dateOfBirth(randomBirthDate) .build()), zmrProcessId)); - + Mockito.when(zmrClient.update(any(), any(), any())).thenThrow( + new IllegalStateException("ZMR update should not be neccessary")); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomPersonalIdentifier_DE)).thenReturn(Collections.emptyList()); Mockito.when(ernpClient.searchWithMds(randomGivenName, randomFamilyName, randomBirthDate)).thenReturn( Arrays.asList( @@ -712,7 +735,7 @@ public class InitialSearchTaskTest { assertNull("Find final matching data but no match sould be found", MatchingTaskUtils.getFinalMatchingResult(pendingReq)); - RegisterSearchResult result = MatchingTaskUtils.getIntermediateMatchingResult(pendingReq); + RegisterStatusResults result = MatchingTaskUtils.getIntermediateMatchingResult(pendingReq); assertNotNull("Find no intermediate matching data", result); assertEquals("wrong intermediate result size", resultSize, result.getResultCount()); diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskTest.java index 77c49bb4..25a77cce 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskTest.java @@ -41,7 +41,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.ManualFixNecessaryException; 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.RegisterSearchResult; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterStatusResults; import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.ReceiveAustrianResidenceGuiResponseTask; import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.ReceiveAustrianResidenceGuiResponseTask.UserInput; import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.MatchingTaskUtils; @@ -99,7 +99,7 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { public void noRegisterResult() throws Exception { UserInput userInput = setupUserInput(); SimpleEidasData eidasData = setupEidasData(); - RegisterSearchResult registerSearchResult = buildEmptyResult(); + RegisterStatusResults registerSearchResult = buildEmptyResult(); mockRegisterSearch(userInput, registerSearchResult, eidasData); MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerSearchResult); @@ -112,7 +112,7 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { public void exactlyOneRegisterResult_Matching() throws Exception { UserInput userInput = setupUserInput(); SimpleEidasData eidasData = setupEidasData(); - RegisterSearchResult registerSearchResult = buildResultWithOneMatch(buildMatchingRegisterResult(eidasData)); + RegisterStatusResults registerSearchResult = buildResultWithOneMatch(buildMatchingRegisterResult(eidasData)); MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerSearchResult); mockRegisterSearch(userInput, registerSearchResult, eidasData); @@ -127,7 +127,7 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { public void exactlyOneRegisterResult_NotMatching() throws Exception { UserInput userInput = setupUserInput(); SimpleEidasData eidasData = setupEidasData(); - RegisterSearchResult registerSearchResult = buildResultWithOneMatch(buildNotMatchingRegisterResult(eidasData)); + RegisterStatusResults registerSearchResult = buildResultWithOneMatch(buildNotMatchingRegisterResult(eidasData)); MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerSearchResult); mockRegisterSearch(userInput, registerSearchResult, eidasData); @@ -140,7 +140,7 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { public void moreThanOneRegisterResult() throws Exception { UserInput userInput = setupUserInput(); SimpleEidasData eidasData = setupEidasData(); - RegisterSearchResult registerSearchResult = buildResultWithTwoMatches(); + RegisterStatusResults registerSearchResult = buildResultWithTwoMatches(); MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerSearchResult); mockRegisterSearch(userInput, registerSearchResult, eidasData); @@ -152,14 +152,14 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { assertNull("Transition To S16", executionContext.get(Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK)); } - private void mockRegisterSearch(UserInput userInput, RegisterSearchResult registerSearchResult, SimpleEidasData eidasData ) { + private void mockRegisterSearch(UserInput userInput, RegisterStatusResults registerSearchResult, SimpleEidasData eidasData ) { Mockito.when(registerSearchService.searchWithResidence(eq(registerSearchResult.getOperationStatus()), eq(eidasData), eq(userInput.getZipcode()), eq(userInput.getCity()), eq(userInput.getStreet()))).thenReturn(registerSearchResult); } @NotNull - private RegisterSearchResult buildEmptyResult() { - return new RegisterSearchResult(new RegisterOperationStatus(generateRandomProcessId()), + private RegisterStatusResults buildEmptyResult() { + return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), Collections.emptyList(), Collections.emptyList()); } @@ -170,16 +170,16 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest { } @NotNull - private RegisterSearchResult buildResultWithOneMatch(RegisterResult registerResult) { - return new RegisterSearchResult(new RegisterOperationStatus(generateRandomProcessId()), + private RegisterStatusResults buildResultWithOneMatch(RegisterResult registerResult) { + return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), Collections.singletonList(registerResult), Collections.emptyList()); } @NotNull - private RegisterSearchResult buildResultWithTwoMatches() { + private RegisterStatusResults buildResultWithTwoMatches() { List<RegisterResult> results = Lists.newArrayList(buildRandomRegisterResult(), buildRandomRegisterResult()); - return new RegisterSearchResult(new RegisterOperationStatus(generateRandomProcessId()), + return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), results, Collections.emptyList()); } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseTaskTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseTaskTest.java index 51077e96..b072b8b2 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseTaskTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseTaskTest.java @@ -54,7 +54,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.provider import at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.provider.IdAustriaClientAuthMetadataProvider; 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.RegisterSearchResult; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterStatusResults; import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.ReceiveMobilePhoneSignatureResponseTask; import at.asitplus.eidas.specific.modules.auth.eidas.v2.test.dummy.DummyOA; import at.asitplus.eidas.specific.modules.auth.eidas.v2.test.dummy.DummyPendingRequest; @@ -342,7 +342,7 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest { AuthProcessDataWrapper authProcessData = pendingReq.getSessionData(AuthProcessDataWrapper.class); SimpleEidasData eidData = createEidasDataMatchingToSamlResponse().build(); authProcessData.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, eidData); - RegisterSearchResult registerSearchResult = new RegisterSearchResult(new RegisterOperationStatus(generateRandomProcessId()), + RegisterStatusResults registerSearchResult = new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), Collections.emptyList(), Collections.emptyList()); MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerSearchResult); @@ -362,7 +362,7 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest { AuthProcessDataWrapper authProcessData = pendingReq.getSessionData(AuthProcessDataWrapper.class); SimpleEidasData eidData = createEidasDataMatchingToSamlResponse().build(); authProcessData.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, eidData); - RegisterSearchResult registerSearchResult = buildResultWithOneMatch(); + RegisterStatusResults registerSearchResult = buildResultWithOneMatch(); MatchingTaskUtils.storeIntermediateMatchingResult(pendingReq, registerSearchResult); task.execute(pendingReq, executionContext); @@ -403,8 +403,8 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest { } @NotNull - private RegisterSearchResult buildResultWithOneMatch() { - return new RegisterSearchResult(new RegisterOperationStatus(generateRandomProcessId()), + private RegisterStatusResults buildResultWithOneMatch() { + return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), Collections.singletonList(RegisterResult.builder() .bpk(BPK_FROM_ID_AUSTRIA) .pseudonym(Arrays.asList("bar")) @@ -417,7 +417,7 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest { } @NotNull - private RegisterSearchResult buildResultWithTwoMatches() { + private RegisterStatusResults buildResultWithTwoMatches() { List<RegisterResult> results = Lists.newArrayList( RegisterResult.builder() .bpk(BPK_FROM_ID_AUSTRIA) @@ -434,7 +434,7 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest { .dateOfBirth("dateOfBirth") .build()); - return new RegisterSearchResult(new RegisterOperationStatus(generateRandomProcessId()), + return new RegisterStatusResults(new RegisterOperationStatus(generateRandomProcessId()), results, Collections.emptyList()); } |