diff options
author | Alexander Marsalek <amarsalek@iaik.tugraz.at> | 2020-12-16 17:32:43 +0100 |
---|---|---|
committer | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2021-01-15 14:18:45 +0100 |
commit | 20b28fa85e5fc24868b22fa769e87f1dcacf205a (patch) | |
tree | b951b8f2b6ed294241763041668f8a78e7bcc128 /eidas_modules/authmodule-eIDAS-v2/src | |
parent | 69c5f2715fa545554867d9022952b05dc003e186 (diff) | |
download | National_eIDAS_Gateway-20b28fa85e5fc24868b22fa769e87f1dcacf205a.tar.gz National_eIDAS_Gateway-20b28fa85e5fc24868b22fa769e87f1dcacf205a.tar.bz2 National_eIDAS_Gateway-20b28fa85e5fc24868b22fa769e87f1dcacf205a.zip |
2 more tests (bean mocking still missing)
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src')
-rw-r--r-- | eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java | 85 |
1 files changed, 84 insertions, 1 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 924a180d..5c75d1e4 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 @@ -22,8 +22,10 @@ import eu.eidas.auth.commons.protocol.impl.AuthenticationResponse; import lombok.val; import org.apache.commons.lang3.RandomStringUtils; import org.jetbrains.annotations.NotNull; +import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; @@ -39,7 +41,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import org.junit.Assert; + import javax.xml.namespace.QName; import java.io.IOException; import java.net.URI; @@ -303,6 +305,87 @@ public class InitialSearchTaskFirstTest { } } + @Ignore + @Test + @DirtiesContext + /** + * One match found in ZMR and ErnB with detail search + */ + public void testNode103() throws Exception { + + //Mock ZMR initial search + ArrayList<RegisterResult> zmrResultInitial = new ArrayList<>(); + zmrClient = Mockito.mock(DummyZmrClient.class); + Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResultInitial); + ArrayList<RegisterResult> zmrResultSpecific = new ArrayList<>(); + //String bpk, String pseudonym, String givenName, String familyName, String dateOfBirth, + // String placeOfBirth, String birthName, String taxNumber, PostalAddressType address + zmrResultSpecific.add(new RegisterResult("bpkMax","de/st/max1234", "Max", "Mustermann", "1111-01-01", null, null, + "tax123", null)); + + Mockito.when(zmrClient.searchItSpecific("tax123")).thenReturn(zmrResultSpecific); + task.setZmrClient(zmrClient); + + //Mock ernb initial search + ArrayList<RegisterResult> ernbResultInitial = new ArrayList<>(); + ernbClient = Mockito.mock(DummyErnbClient.class); + Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResultInitial);//"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); + } + } + + @Ignore + @Test + @DirtiesContext + /** + * Multiple matches found in ZMR and ErnB with detail search + */ + public void testNode104() throws Exception { + + //Mock ZMR initial search + ArrayList<RegisterResult> zmrResultInitial = new ArrayList<>(); + zmrClient = Mockito.mock(DummyZmrClient.class); + Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResultInitial); + ArrayList<RegisterResult> zmrResultSpecific = new ArrayList<>(); + //String bpk, String pseudonym, String givenName, String familyName, String dateOfBirth, + // String placeOfBirth, String birthName, String taxNumber, PostalAddressType address + zmrResultSpecific.add(new RegisterResult("bpkMax","de/st/max1234", "Max", "Mustermann", "1111-01-01", null, null, + "tax123", null)); + zmrResultSpecific.add(new RegisterResult("bpkMax1","de/st/max1235", "Max", "Mustermann", "1111-01-01", null, null, + "tax123", null)); + Mockito.when(zmrClient.searchItSpecific("tax123")).thenReturn(zmrResultSpecific); + + + task.setZmrClient(zmrClient); + + //Mock ernb initial search + ArrayList<RegisterResult> ernbResultInitial = new ArrayList<>(); + ernbClient = Mockito.mock(DummyErnbClient.class); + Mockito.when(ernbClient.searchWithPersonIdentifer("max123")).thenReturn(ernbResultInitial);//"de/st/max123"??? + + task.setErnbClient(ernbClient); + + try { + task.execute(pendingReq, executionContext); + + Assert.assertTrue("Wrong workflow, should not reach this point/ get a bpk", false); + + } catch (final TaskExecutionException e) { + Throwable origE = e.getOriginalException(); + Assert.assertTrue("Wrong exception", (origE.getCause() instanceof ManualFixNecessaryException)); + } + } + @Test @DirtiesContext |