aboutsummaryrefslogtreecommitdiff
path: root/modules/authmodule-eIDAS-v2/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'modules/authmodule-eIDAS-v2/src/test/java')
-rw-r--r--modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java120
1 files changed, 117 insertions, 3 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 4cfba521..1ce48a2e 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
@@ -332,6 +332,110 @@ public class InitialSearchTaskTest {
}
/**
+ * Two matches by PersonalId found.
+ *
+ * <ul>
+ * <li>ZMR: one entry</li>
+ * <li>ERnP: one entry marked as ZMR kitt, but different bPK</li>
+ * </ul>
+ *
+ * @throws EidasSAuthenticationException
+ */
+ @Test
+ @DirtiesContext
+ public void multiPersonalIdMatch_Zmr_ErnpKitt() throws EidasSAuthenticationException {
+ Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE))
+ .thenReturn(new ZmrRegisterResult(Arrays.asList(randomRegisterResult(randomGivenName, randomBpk)), generateRandomProcessId()));
+
+ String newRandomBpk = randomAlphabetic(10);
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE))
+ .thenReturn(ernpRegisterResult(Arrays.asList(
+ new ErnpPersonRegisterResult(randomRegisterResult(randomGivenName, newRandomBpk), true))));
+
+ // execute task
+ TaskExecutionException exception = assertThrows(TaskExecutionException.class,
+ () -> task.execute(pendingReq, executionContext));
+
+ // validate state
+ assertTrue("Wrong exception", (exception.getOriginalException() instanceof WorkflowException));
+ assertTrue("Wrong flag 'manualFixNeeded'",
+ ((WorkflowException) exception.getOriginalException()).isRequiresManualFix());
+
+ }
+
+
+ /**
+ * Two matches by PersonalId found that are the same entity.
+ *
+ * <ul>
+ * <li>ZMR: one entry</li>
+ * <li>ERnP: one entry marked as ZMR kitt</li>
+ * </ul>
+ *
+ * @throws EidasSAuthenticationException
+ */
+ @Test
+ @DirtiesContext
+ @SneakyThrows
+ public void multiPersonalIdMatch_Zmr_ErnpKitt_Same_Enity() throws EidasSAuthenticationException {
+ Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE))
+ .thenReturn(new ZmrRegisterResult(Arrays.asList(
+ randomRegisterResult(randomGivenName, randomBpk)), generateRandomProcessId()));
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE))
+ .thenReturn(ernpRegisterResult(Arrays.asList(
+ new ErnpPersonRegisterResult(randomRegisterResult(randomGivenName, randomBpk), true))));
+
+ // execute test
+ task.execute(pendingReq, executionContext);
+
+ // validate state
+ checkMatchingSuccessState(pendingReq, randomBpk, randomFamilyName, randomGivenName, randomBirthDate, DE);
+
+ }
+
+ /**
+ * Single matche by PersonalId found in ERnP, but it's a ZMR KITT entry.
+ * <ul>
+ * <li>ZMR: empty</li>
+ * <li>ERnP: one entry marked as ZMR kitt</li>
+ * </ul>
+ *
+ * @throws EidasSAuthenticationException
+ */
+ @Test
+ @DirtiesContext
+ @SneakyThrows
+ public void singlePersonalIdMatch_ErnpKitt_UpdateRequird() throws EidasSAuthenticationException {
+ String oldGivenName = randomAlphabetic(10);
+ String placeOfBirth = randomAlphabetic(10);
+ RegisterResult firstErnpResult = randomRegisterResult(oldGivenName, randomBpk, placeOfBirth);
+
+ Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE))
+ .thenReturn(emptyZmrRegisterResult());
+ Mockito.when(zmrClient.searchCountrySpecific(any(), any(), any()))
+ .thenThrow(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()))
+ .thenReturn(zmrRegisterResult(firstErnpResult));
+
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE))
+ .thenReturn(ernpRegisterResult(Arrays.asList(
+ new ErnpPersonRegisterResult(firstErnpResult, true))));
+ Mockito.when(ernpClient.searchWithMds(any(), any(), any(), any()))
+ .thenThrow(new IllegalStateException("MDS search should not be neccessary"));
+ Mockito.when(ernpClient.update(any(), any()))
+ .thenThrow(new IllegalStateException("ERnP update should not be neccessary"));
+
+ // execute test
+ task.execute(pendingReq, executionContext);
+
+ // validate state
+ checkMatchingSuccessState(pendingReq, randomBpk, randomFamilyName, oldGivenName, randomBirthDate, DE);
+
+ }
+
+ /**
* Two matches by PersonalId
*
* @throws EidasSAuthenticationException
@@ -354,7 +458,7 @@ public class InitialSearchTaskTest {
((WorkflowException) exception.getOriginalException()).isRequiresManualFix());
}
-
+
/**
* Find to matches by PersonalId but they are the same person.
*/
@@ -817,11 +921,21 @@ public class InitialSearchTaskTest {
@NotNull
private ErnpRegisterResult ernpRegisterResult(List<RegisterResult> registerResult) {
- return new ErnpRegisterResult(registerResult.stream()
- .map(el -> new ErnpPersonRegisterResult(el, false))
+ return new ErnpRegisterResult(
+ registerResult.stream()
+ .map(el -> {
+ if (el instanceof ErnpPersonRegisterResult) {
+ return (ErnpPersonRegisterResult)el;
+
+ } else {
+ return new ErnpPersonRegisterResult(el, false);
+
+ }
+ })
.collect(Collectors.toList()));
}
+
@NotNull
private RegisterResult randomRegisterResult() {
return randomRegisterResult(randomGivenName, randomBpk);