From 1edc816481ac7ee2cbdecbd64f44f367d25fc3bd Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Tue, 11 Oct 2022 14:09:07 +0200 Subject: feat(matching): clearing in case of ZMR and ERnP result contains the same person In case of KITT between ERnP and ZMR entries it's possible to get the same entity in both results. Remove ERnP result if ZMR results contains a person with same bPK. --- .../eidas/v2/test/tasks/InitialSearchTaskTest.java | 28 +++++++++++++++++++--- 1 file changed, 25 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/InitialSearchTaskTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java index eef31a02..c9b7b1ac 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 @@ -97,6 +97,7 @@ import eu.eidas.auth.commons.attribute.ImmutableAttributeMap; import eu.eidas.auth.commons.attribute.PersonType; import eu.eidas.auth.commons.light.impl.LightRequest; import eu.eidas.auth.commons.protocol.impl.AuthenticationResponse; +import lombok.SneakyThrows; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { @@ -339,7 +340,7 @@ public class InitialSearchTaskTest { Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE)) .thenReturn(zmrRegisterResult(randomRegisterResult())); Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)) - .thenReturn(ernpRegisterResult(randomRegisterResult())); + .thenReturn(ernpRegisterResult(randomRegisterResult(RandomStringUtils.randomAlphanumeric(10)))); // execute task TaskExecutionException exception = assertThrows(TaskExecutionException.class, @@ -352,6 +353,27 @@ public class InitialSearchTaskTest { } + /** + * Find to matches by PersonalId but they are the same person. + */ + @Test + @DirtiesContext + @SneakyThrows + public void samePersonFromZmrAndErnp() { + RegisterResult registerResult = randomRegisterResult(); + Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE)) + .thenReturn(zmrRegisterResult(registerResult)); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)) + .thenReturn(ernpRegisterResult(registerResult)); + + // execute test + task.execute(pendingReq, executionContext); + + // validate state + checkMatchingSuccessState(pendingReq, randomBpk, randomFamilyName, randomGivenName, randomBirthDate, DE); + + } + /** * One match by PersonalId, no register update needed */ @@ -545,7 +567,7 @@ public class InitialSearchTaskTest { Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)) .thenReturn(emptyErnpRegisterResult()); Mockito.when(ernpClient.searchCountrySpecific(any(), eq(DE))) - .thenReturn(ernpRegisterResult(randomRegisterResult())); + .thenReturn(ernpRegisterResult(randomRegisterResult(RandomStringUtils.randomAlphanumeric(10)))); Mockito.when(ernpClient.update(any(), any())) .thenThrow(new IllegalStateException("ERnP update should not be neccessary")); @@ -722,7 +744,7 @@ public class InitialSearchTaskTest { Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE)).thenReturn( emptyErnpRegisterResult()); Mockito.when(ernpClient.searchWithMds(randomGivenName, randomFamilyName, randomBirthDate, DE)) - .thenReturn(ernpRegisterResult(randomRegisterResult())); + .thenReturn(ernpRegisterResult(randomRegisterResult(RandomStringUtils.randomAlphanumeric(10)))); Mockito.when(ernpClient.update(any(), any())) .thenThrow(new IllegalStateException("ERnP update should not be neccessary")); -- cgit v1.2.3