From 20b28fa85e5fc24868b22fa769e87f1dcacf205a Mon Sep 17 00:00:00 2001 From: Alexander Marsalek Date: Wed, 16 Dec 2020 17:32:43 +0100 Subject: 2 more tests (bean mocking still missing) --- .../v2/test/tasks/InitialSearchTaskFirstTest.java | 85 +++++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-) 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 zmrResultInitial = new ArrayList<>(); + zmrClient = Mockito.mock(DummyZmrClient.class); + Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResultInitial); + ArrayList 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 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 zmrResultInitial = new ArrayList<>(); + zmrClient = Mockito.mock(DummyZmrClient.class); + Mockito.when(zmrClient.searchWithPersonIdentifer("max123")).thenReturn(zmrResultInitial); + ArrayList 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 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 -- cgit v1.2.3