diff options
author | Alexander Marsalek <amarsalek@iaik.tugraz.at> | 2020-12-15 23:07:53 +0100 |
---|---|---|
committer | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2021-01-15 14:17:36 +0100 |
commit | 41a2c873d585d00ee06cc95a5e30fe17f4bc85a9 (patch) | |
tree | 78b32d24f6c4709d7b55c594843370ccaa47cc87 /eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus | |
parent | b49ccd7d7ec1c0f0b560321b7e5559f18913ae7c (diff) | |
download | National_eIDAS_Gateway-41a2c873d585d00ee06cc95a5e30fe17f4bc85a9.tar.gz National_eIDAS_Gateway-41a2c873d585d00ee06cc95a5e30fe17f4bc85a9.tar.bz2 National_eIDAS_Gateway-41a2c873d585d00ee06cc95a5e30fe17f4bc85a9.zip |
added machting (3-4) + tests
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus')
-rw-r--r-- | eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java | 140 |
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 { |