aboutsummaryrefslogtreecommitdiff
path: root/eidas_modules/authmodule-eIDAS-v2
diff options
context:
space:
mode:
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2')
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java142
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java16
2 files changed, 151 insertions, 7 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 d6d49370..b3ba8a9d 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
@@ -208,8 +208,7 @@ public class InitialSearchTaskTest {
}
/**
- * TODO: include again if ERnP update is implementet. Maybe we can update MDS based on ERnP.
- * <p>
+ *
* One match, but register update needed.
*
* @throws EidasSAuthenticationException
@@ -343,11 +342,11 @@ public class InitialSearchTaskTest {
public void singlePersonalIdMatchNoUpdate_Ernp() throws Exception {
Mockito.when(zmrClient.searchWithPersonIdentifier(null, randomPseudonym, DE))
.thenReturn(emptyZmrRegisterResult());
- Mockito.when(zmrClient.update(any(), any(), any()))
- .thenThrow(new IllegalStateException("ZMR update should not be neccessary"));
-
Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE))
- .thenReturn(ernpRegisterResult(randomRegisterResult()));
+ .thenReturn(ernpRegisterResult(randomRegisterResult()));
+
+ Mockito.when(zmrClient.update(any(), any(), any()))
+ .thenThrow(new IllegalStateException("ZMR update should not be neccessary"));
Mockito.when(ernpClient.update(any(), any()))
.thenThrow(new IllegalStateException("ERnP update should not be neccessary"));
@@ -368,8 +367,11 @@ public class InitialSearchTaskTest {
.thenReturn(zmrRegisterResult(randomRegisterResult()));
Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE))
.thenReturn(emptyErnpRegisterResult());
+
Mockito.when(zmrClient.update(any(), any(), any()))
.thenThrow(new IllegalStateException("ZMR update 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);
@@ -420,7 +422,15 @@ public class InitialSearchTaskTest {
Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE))
.thenReturn(emptyErnpRegisterResult());
-
+ Mockito.when(ernpClient.searchCountrySpecific(any(), eq(DE)))
+ .thenReturn(emptyErnpRegisterResult());
+ Mockito.when(ernpClient.searchWithMds(any(), any(), any(), eq(DE)))
+ .thenThrow(new IllegalStateException("ERnP MDS search should not be neccessary"));
+ Mockito.when(ernpClient.update(any(), any()))
+ .thenThrow(new IllegalStateException("ERnP update should not be neccessary"));
+ Mockito.when(ernpClient.add(any()))
+ .thenThrow(new IllegalStateException("ERnP add-entity should not be neccessary"));
+
// execute test
task.execute(pendingReq1, executionContext);
@@ -470,6 +480,10 @@ public class InitialSearchTaskTest {
Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE))
.thenReturn(emptyErnpRegisterResult());
+ Mockito.when(ernpClient.searchCountrySpecific(any(), eq(DE)))
+ .thenReturn(emptyErnpRegisterResult());
+ Mockito.when(ernpClient.update(any(), any()))
+ .thenThrow(new IllegalStateException("ERnP update should not be neccessary"));
// execute task
TaskExecutionException exception = assertThrows(TaskExecutionException.class,
@@ -483,6 +497,89 @@ public class InitialSearchTaskTest {
}
/**
+ * Multiple matches found in ZMR and ERnP by country specifics.
+ */
+ @Test
+ @DirtiesContext
+ public void multiplePersonFindWithCountySpecifics_ZmrAndErnp() throws Exception {
+ 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));
+ RegisterResult randomResult1 = RegisterResult.builder()
+ .bpk(randomBpk)
+ .pseudonym(Collections.singletonList(randomPseudonym))
+ .givenName(randomGivenName)
+ .familyName(randomFamilyName)
+ .dateOfBirth(randomBirthDate)
+ .placeOfBirth(randomPlaceOfBirth)
+ .birthName(randomBirthName)
+ .build();
+ Mockito.when(zmrClient.searchCountrySpecific(eq(zmrProcessId), any(PersonSuchenRequest.class), eq(DE)))
+ .thenReturn(new ZmrRegisterResult(Arrays.asList(randomResult1), zmrProcessId));
+
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE))
+ .thenReturn(emptyErnpRegisterResult());
+ Mockito.when(ernpClient.searchCountrySpecific(any(), eq(DE)))
+ .thenReturn(ernpRegisterResult(randomRegisterResult()));
+ Mockito.when(ernpClient.update(any(), any()))
+ .thenThrow(new IllegalStateException("ERnP update should not be neccessary"));
+
+ // execute task
+ TaskExecutionException exception = assertThrows(TaskExecutionException.class,
+ () -> task.execute(pendingReq1, executionContext));
+
+ // validate state
+ assertTrue("Wrong exception", (exception.getOriginalException() instanceof WorkflowException));
+ assertTrue("Wrong flag 'manualFixNeeded'",
+ ((WorkflowException) exception.getOriginalException()).isRequiresManualFix());
+
+ }
+
+ /**
+ * Multiple matches found in ERnP by country specifics.
+ */
+ @Test
+ @DirtiesContext
+ public void multiplePersonFindWithCountySpecifics_Ernp() throws Exception {
+ 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(eq(zmrProcessId), any(PersonSuchenRequest.class), eq(DE)))
+ .thenReturn(new ZmrRegisterResult(Arrays.asList(), zmrProcessId));
+
+ Mockito.when(ernpClient.searchWithPersonIdentifier(randomPseudonym, DE))
+ .thenReturn(emptyErnpRegisterResult());
+ Mockito.when(ernpClient.searchCountrySpecific(any(), eq(DE)))
+ .thenReturn(ernpRegisterResult(Arrays.asList(randomRegisterResult(), randomRegisterResult())));
+ Mockito.when(ernpClient.update(any(), any()))
+ .thenThrow(new IllegalStateException("ERnP update should not be neccessary"));
+
+ // execute task
+ TaskExecutionException exception = assertThrows(TaskExecutionException.class,
+ () -> task.execute(pendingReq1, executionContext));
+
+ // validate state
+ assertTrue("Wrong exception", (exception.getOriginalException() instanceof WorkflowException));
+ assertTrue("Wrong flag 'manualFixNeeded'",
+ ((WorkflowException) exception.getOriginalException()).isRequiresManualFix());
+
+ }
+
+ /**
* NO match found in ZMR and ErnP with Initial and MDS search
*
* @throws EidasSAuthenticationException
@@ -591,6 +688,37 @@ public class InitialSearchTaskTest {
}
/**
+ * Find matches with MDS search in ZMR and ERnP.
+ */
+ @Test
+ @DirtiesContext
+ public void resultByMdsSearch_ZmrAndErnp() 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(
+ emptyErnpRegisterResult());
+ Mockito.when(ernpClient.searchWithMds(randomGivenName, randomFamilyName, randomBirthDate, DE))
+ .thenReturn(ernpRegisterResult(randomRegisterResult()));
+ 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);
+
+ }
+
+ /**
* resultByMdsSearch
*/
@Test
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java
index 565efe09..0e95f718 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java
@@ -283,6 +283,11 @@ public class InitialSearchTaskWithRegistersTest {
.thenReturn(loadResponseFromFile("/data/zmr/seq_1-6_kitt_update_resp.xml")) //KITT update
.thenThrow(new RuntimeException("This request is not needed any more"));
+ mockWebServer.enqueue(new MockResponse().setResponseCode(200) //CC specific search
+ .setBody("{}")
+ .setHeader("Content-Type", "application/json;charset=utf-8"));
+
+
// execute test
task.execute(pendingReq, executionContext);
@@ -322,6 +327,9 @@ public class InitialSearchTaskWithRegistersTest {
.thenReturn(loadResponseFromFile("/data/zmr/seq_1-2_search_with_mds_resp.xml")) //MDS specific search
.thenThrow(new RuntimeException("This request is not needed any more"));
+ mockWebServer.enqueue(new MockResponse().setResponseCode(200) //MDS specific search
+ .setBody("{}")
+ .setHeader("Content-Type", "application/json;charset=utf-8"));
// execute test
task.execute(pendingReq, executionContext);
@@ -361,6 +369,14 @@ public class InitialSearchTaskWithRegistersTest {
.thenThrow(new RuntimeException("This request is not needed any more"));
+ mockWebServer.enqueue(new MockResponse().setResponseCode(200) //CC specific search
+ .setBody("{}")
+ .setHeader("Content-Type", "application/json;charset=utf-8"));
+ mockWebServer.enqueue(new MockResponse().setResponseCode(200) //MDS specific search
+ .setBody("{}")
+ .setHeader("Content-Type", "application/json;charset=utf-8"));
+
+
// execute test
task.execute(pendingReq, executionContext);