aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java83
1 files changed, 75 insertions, 8 deletions
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 18d76264..6d0e7c31 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
@@ -45,6 +45,7 @@ import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.namespace.QName;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.jetbrains.annotations.NotNull;
import org.junit.AfterClass;
@@ -84,6 +85,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.ICcSpecificEidPr
import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService;
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.test.clients.ErnpRestClientTest;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.test.clients.ZmrClientTest;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.MatchingTaskUtils;
import at.gv.bmi.namespace.zmr_su.base._20040201.RequestType;
@@ -180,11 +182,6 @@ public class InitialSearchTaskWithRegistersTest {
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpReq, httpResp));
pendingReq = new TestRequestImpl();
-
-
- mockWebServer.enqueue(new MockResponse().setResponseCode(200)
- .setBody("{}")
- .setHeader("Content-Type", "application/json;charset=utf-8"));
}
@@ -218,6 +215,10 @@ public class InitialSearchTaskWithRegistersTest {
//do not make an update because, MDS update is not allowed and no other data has been changed
.thenThrow(new RuntimeException("This request is not needed any more"));
+ mockWebServer.enqueue(new MockResponse().setResponseCode(200)
+ .setBody("{}")
+ .setHeader("Content-Type", "application/json;charset=utf-8"));
+
// execute test
task.execute(pendingReq, executionContext);
@@ -266,6 +267,9 @@ public class InitialSearchTaskWithRegistersTest {
//do make an update because, MDS DOES NOT change, but additional attribute was available
.thenReturn(loadResponseFromFile("/data/zmr/seq_3-6_kitt_update_resp.xml"));
+ mockWebServer.enqueue(new MockResponse().setResponseCode(200)
+ .setBody("{}")
+ .setHeader("Content-Type", "application/json;charset=utf-8"));
// execute test
task.execute(pendingReq, executionContext);
@@ -321,6 +325,58 @@ public class InitialSearchTaskWithRegistersTest {
}
+ /**
+ * Find single person in ZMR by country specifics.
+ */
+ @Test
+ @DirtiesContext
+ public void singlePersonFindWithCountySpecifics_Ernp() throws Exception {
+ //inject eIDAS data
+ pendingReq.getSessionData(AuthProcessDataWrapper.class).setGenericDataToSession(
+ Constants.DATA_FULL_EIDAS_RESPONSE,
+ buildDummyAuthResponse("vdqZZIaA", "mRjMKAQc",
+ "DE/AT/nj1m79jm9z", "1996-01-01",
+ null, "VRNCAylF", "miEklFHC"));
+
+ final ArgumentCaptor<RequestType> zmrReq = ArgumentCaptor.forClass(RequestType.class);
+ BigInteger processId = new BigInteger("367100000000079");
+
+ // inject response
+ when(zmrMock.service(zmrReq.capture(), any()))
+ .thenReturn(loadResponseFromFile("/data/zmr/empty_zmr_result.xml")) //personalId search
+ .thenReturn(loadResponseFromFile("/data/zmr/empty_zmr_result.xml")) //CC specific search
+ .thenThrow(new RuntimeException("This request is not needed any more"));
+
+ mockWebServer.enqueue(new MockResponse().setResponseCode(200) //personalId search
+ .setBody("{}")
+ .setHeader("Content-Type", "application/json;charset=utf-8"));
+ mockWebServer.enqueue(new MockResponse().setResponseCode(200) //CC specific search
+ .setBody(IOUtils.toString(
+ ErnpRestClientTest.class.getResourceAsStream("/data/ernp/2_search_with_cc_specific_resp.json"), "UTF-8"))
+ .setHeader("Content-Type", "application/json;charset=utf-8"));
+ mockWebServer.enqueue(new MockResponse().setResponseCode(200) //KITT search
+ .setBody(IOUtils.toString(
+ ErnpRestClientTest.class.getResourceAsStream("/data/ernp/2_kitt_search_latest_resp.json"), "UTF-8"))
+ .setHeader("Content-Type", "application/json;charset=utf-8"));
+ mockWebServer.enqueue(new MockResponse().setResponseCode(200) //KITT update
+ .setBody(IOUtils.toString(
+ ErnpRestClientTest.class.getResourceAsStream("/data/ernp/2_kitt_update_resp.json"), "UTF-8"))
+ .setHeader("Content-Type", "application/json;charset=utf-8"));
+
+ // execute test
+ task.execute(pendingReq, executionContext);
+
+ // validate state
+ checkMatchingSuccessState(pendingReq, "TBGoMlirU881e2jMGETa9WLx1+A=", "mRjMKAQc",
+ "vdqZZIaA", "1996-01-01", DE);
+
+ // validate request
+ assertEquals("wrong number of req.", 2, zmrReq.getAllValues().size());
+ checkBasicRequestParameters(zmrReq.getAllValues().get(0), ZmrClientTest.PROCESS_TASK_SEARCH, null, "jUnit123456");
+ checkBasicRequestParameters(zmrReq.getAllValues().get(1), ZmrClientTest.PROCESS_TASK_SEARCH, processId, "jUnit123456");
+
+ }
+
/**
* Find single person in ZMR by country specifics.
@@ -346,6 +402,10 @@ 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)
+ .setBody("{}")
+ .setHeader("Content-Type", "application/json;charset=utf-8"));
+
mockWebServer.enqueue(new MockResponse().setResponseCode(200) //CC specific search
.setBody("{}")
.setHeader("Content-Type", "application/json;charset=utf-8"));
@@ -389,7 +449,10 @@ public class InitialSearchTaskWithRegistersTest {
//CC-specific will be ignored because CC is DE but BirthName and PlaceOfBirth is 'null'
.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)
+ .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"));
@@ -432,11 +495,15 @@ public class InitialSearchTaskWithRegistersTest {
.thenThrow(new RuntimeException("This request is not needed any more"));
+ mockWebServer.enqueue(new MockResponse().setResponseCode(200)
+ .setBody("{}")
+ .setHeader("Content-Type", "application/json;charset=utf-8"));
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("{}")
+ .setBody(IOUtils.toString(
+ ErnpRestClientTest.class.getResourceAsStream("/data/ernp/3_search_with_mds_resp.json"), "UTF-8"))
.setHeader("Content-Type", "application/json;charset=utf-8"));
@@ -444,7 +511,7 @@ public class InitialSearchTaskWithRegistersTest {
task.execute(pendingReq, executionContext);
// validate state
- checkIntermediateResult(2);
+ checkIntermediateResult(3);
// validate request
assertEquals("wrong number of req.", 3, zmrReq.getAllValues().size());