aboutsummaryrefslogtreecommitdiff
path: root/eidas_modules/authmodule-eIDAS-v2/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/test/java')
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java140
1 files changed, 136 insertions, 4 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java
index 1b1bdeae..2614f9ba 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java
@@ -111,8 +111,8 @@ public class InitialSearchTaskFirstTest {
//Mock ZMR
ArrayList<RegisterResult> zmrResult = new ArrayList<>();
- zmrResult.add(new RegisterResult("de/st/max123", "Max", "Mustermann", "1111-01-01"));
- zmrResult.add(new RegisterResult("de/st/max123", "Maximilian", "Mustermann", "1111-01-01"));
+ zmrResult.add(new RegisterResult("bpkMax","de/st/max123", "Max", "Mustermann", "1111-01-01"));
+ zmrResult.add(new RegisterResult("bpkMax","de/st/max123", "Maximilian", "Mustermann", "1111-01-01"));
zmrClient = Mockito.mock(DummyZmrClient.class);
Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResult);//"de/st/max123"???
task.setZmrClient(zmrClient);
@@ -151,8 +151,8 @@ public class InitialSearchTaskFirstTest {
//Mock ernb
ArrayList<RegisterResult> ernbResult = new ArrayList<>();
- ernbResult.add(new RegisterResult("de/st/max123", "Max", "Mustermann", "1111-01-01"));
- ernbResult.add(new RegisterResult("de/st/max123", "Maximilian", "Mustermann", "1111-01-01"));
+ ernbResult.add(new RegisterResult("bpkMax","de/st/max123", "Max", "Mustermann", "1111-01-01"));
+ ernbResult.add(new RegisterResult("bpkMax","de/st/max123", "Maximilian", "Mustermann", "1111-01-01"));
ernbClient = Mockito.mock(DummyErnbClient.class);
Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResult);//"de/st/max123"???
@@ -170,6 +170,138 @@ public class InitialSearchTaskFirstTest {
}
}
+ @Test
+ @DirtiesContext
+ /**
+ * One match, but register update needed
+ */
+ public void testNode100a() throws Exception {
+
+ //Mock ZMR
+ ArrayList<RegisterResult> zmrResult = new ArrayList<>();
+ String randomBpk = RandomStringUtils.randomNumeric(6);
+ zmrResult.add(new RegisterResult(randomBpk,"de/st/max123", "Max_new", "Mustermann", "1111-01-01"));
+
+ zmrClient = Mockito.mock(DummyZmrClient.class);
+ Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResult);//"de/st/max123"???
+ task.setZmrClient(zmrClient);
+
+ //Mock ernb
+ ArrayList<RegisterResult> ernbResult = new ArrayList<>();
+
+ ernbClient = Mockito.mock(DummyErnbClient.class);
+ Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResult);//"de/st/max123"???
+ task.setErnbClient(ernbClient);
+
+ try {
+ task.execute(pendingReq, executionContext);
+ String bPk = (String)
+ pendingReq.getSessionData(AuthProcessDataWrapper.class).getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK);
+ Assert.assertTrue("Wrong bpk", bPk.equals(randomBpk));
+
+ } catch (final TaskExecutionException e) {
+ Assert.assertTrue("Wrong workflow, should not reach this point", false);
+ }
+ }
+
+ @Test
+ @DirtiesContext
+ /**
+ * One match, but register update needed
+ */
+ public void testNode100b() throws Exception {
+
+ //Mock ZMR
+ ArrayList<RegisterResult> zmrResult = new ArrayList<>();
+
+ zmrClient = Mockito.mock(DummyZmrClient.class);
+ Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResult);//"de/st/max123"???
+ task.setZmrClient(zmrClient);
+
+ //Mock ernb
+ ArrayList<RegisterResult> ernbResult = new ArrayList<>();
+ String randomBpk = RandomStringUtils.randomNumeric(6);
+ ernbResult.add(new RegisterResult(randomBpk,"de/st/max123", "Max_new", "Mustermann", "1111-01-01"));
+
+ ernbClient = Mockito.mock(DummyErnbClient.class);
+ Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResult);//"de/st/max123"???
+ task.setErnbClient(ernbClient);
+
+ try {
+ task.execute(pendingReq, executionContext);
+ String bPk = (String)
+ pendingReq.getSessionData(AuthProcessDataWrapper.class).getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK);
+ Assert.assertTrue("Wrong bpk", bPk.equals(randomBpk));
+
+ } catch (final TaskExecutionException e) {
+ Assert.assertTrue("Wrong workflow, should not reach this point", false);
+ }
+ }
+
+ @Test
+ @DirtiesContext
+ /**
+ * One match, no register update needed
+ */
+ public void testNode102a() throws Exception {
+
+ //Mock ZMR
+ ArrayList<RegisterResult> zmrResult = new ArrayList<>();
+ zmrClient = Mockito.mock(DummyZmrClient.class);
+ Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResult);//"de/st/max123"???
+ task.setZmrClient(zmrClient);
+
+ //Mock ernb
+ ArrayList<RegisterResult> ernbResult = new ArrayList<>();
+ ernbResult.add(new RegisterResult("bpkMax","de/st/max123", "Max", "Mustermann", "1111-01-01"));
+
+ ernbClient = Mockito.mock(DummyErnbClient.class);
+ Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResult);//"de/st/max123"???
+ task.setErnbClient(ernbClient);
+
+ try {
+ task.execute(pendingReq, executionContext);
+ String bPk = (String)
+ pendingReq.getSessionData(AuthProcessDataWrapper.class).getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK);
+ Assert.assertTrue("Wrong bpk", bPk.equals("bpkMax"));
+
+ } catch (final TaskExecutionException e) {
+ Assert.assertTrue("Wrong workflow, should not reach this point", false);
+ }
+ }
+
+ @Test
+ @DirtiesContext
+ /**
+ * One match, no register update needed
+ */
+ public void testNode102b() throws Exception {
+
+ //Mock ZMR
+ ArrayList<RegisterResult> zmrResult = new ArrayList<>();
+ zmrResult.add(new RegisterResult("bpkMax","de/st/max123", "Max", "Mustermann", "1111-01-01"));
+
+ zmrClient = Mockito.mock(DummyZmrClient.class);
+ Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResult);//"de/st/max123"???
+ task.setZmrClient(zmrClient);
+
+ //Mock ernb
+ ArrayList<RegisterResult> ernbResult = new ArrayList<>();
+
+ ernbClient = Mockito.mock(DummyErnbClient.class);
+ Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResult);//"de/st/max123"???
+ task.setErnbClient(ernbClient);
+
+ try {
+ task.execute(pendingReq, executionContext);
+ String bPk = (String)
+ pendingReq.getSessionData(AuthProcessDataWrapper.class).getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK);
+ Assert.assertTrue("Wrong bpk", bPk.equals("bpkMax"));
+
+ } catch (final TaskExecutionException e) {
+ Assert.assertTrue("Wrong workflow, should not reach this point", false);
+ }
+ }
@NotNull
private AuthenticationResponse buildDummyAuthResponse() throws URISyntaxException {