aboutsummaryrefslogtreecommitdiff
path: root/modules/authmodule-eIDAS-v2/src/test/java/at
diff options
context:
space:
mode:
authorThomas <>2022-11-17 07:34:19 +0100
committerThomas <>2022-11-17 07:34:19 +0100
commit288d67a809d82298933d8c92d177673039a55f89 (patch)
treeb631ec8240c85fb3c95a105aa48b27ad774e26c3 /modules/authmodule-eIDAS-v2/src/test/java/at
parent0eb64119119f96bd48a49946cc9ab864f55902e5 (diff)
downloadNational_eIDAS_Gateway-288d67a809d82298933d8c92d177673039a55f89.tar.gz
National_eIDAS_Gateway-288d67a809d82298933d8c92d177673039a55f89.tar.bz2
National_eIDAS_Gateway-288d67a809d82298933d8c92d177673039a55f89.zip
test(core): optimize jUnit tests to get better test coverage
Diffstat (limited to 'modules/authmodule-eIDAS-v2/src/test/java/at')
-rw-r--r--modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java6
-rw-r--r--modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskRegisterTest.java5
-rw-r--r--modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskTest.java7
-rw-r--r--modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveOtherLoginMethodGuiResponseTaskTest.java29
4 files changed, 43 insertions, 4 deletions
diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java
index 25a8a5b5..2506a9b6 100644
--- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java
+++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java
@@ -75,6 +75,7 @@ import at.gv.bmi.namespace.zmr_su.base._20040201_.ServicePort;
import at.gv.bmi.namespace.zmr_su.zmr._20040201.EidasIdentitaetAnlageType;
import at.gv.bmi.namespace.zmr_su.zmr._20040201.EidasSuchdatenType;
import at.gv.egiz.eaaf.core.api.IRequest;
+import at.gv.egiz.eaaf.core.api.IRequestStorage;
import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext;
import at.gv.egiz.eaaf.core.exceptions.EaafException;
import at.gv.egiz.eaaf.core.exceptions.EaafStorageException;
@@ -105,6 +106,10 @@ public class AlternativeSearchTaskWithRegisterTest {
@Autowired private IZmrClient zmrClient;
@Autowired private List<CountrySpecificDetailSearchProcessor> handlers;
+
+ @Autowired(required = true)
+ protected IRequestStorage requestStoreage;
+
private RegisterSearchService registerSearchService;
private ServicePort zmrMock = null;
@@ -142,6 +147,7 @@ public class AlternativeSearchTaskWithRegisterTest {
registerSearchService = new RegisterSearchService(handlers, zmrClient, ernpClient);
task = new AlternativeSearchTask(registerSearchService, eidPostProcessor);
+ task.setRequestStoreage(requestStoreage);
MockHttpServletRequest httpReq = new MockHttpServletRequest("POST", "https://localhost/authhandler");
MockHttpServletResponse httpResp = new MockHttpServletResponse();
diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskRegisterTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskRegisterTest.java
index 8d52baf3..8d3959f4 100644
--- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskRegisterTest.java
+++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskRegisterTest.java
@@ -51,6 +51,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.test.clients.ZmrClientTe
import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.MatchingTaskUtils;
import at.gv.bmi.namespace.zmr_su.base._20040201.ResponseType;
import at.gv.bmi.namespace.zmr_su.base._20040201_.ServicePort;
+import at.gv.egiz.eaaf.core.api.IRequestStorage;
import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext;
import at.gv.egiz.eaaf.core.exceptions.EaafException;
import at.gv.egiz.eaaf.core.exceptions.EaafStorageException;
@@ -70,6 +71,9 @@ public class ReceiveAustrianResidenceGuiResponseTaskRegisterTest {
@Autowired
protected MsConnectorDummyConfigMap authConfig;
+ @Autowired(required = true)
+ protected IRequestStorage requestStoreage;
+
@Autowired
private RegisterSearchService registerSearchService;
@@ -112,6 +116,7 @@ public class ReceiveAustrianResidenceGuiResponseTaskRegisterTest {
executionContext = new ExecutionContextImpl();
task = new ReceiveAustrianResidenceGuiResponseTask(registerSearchService);
+ task.setRequestStoreage(requestStoreage);
httpReq = new MockHttpServletRequest("POST", "https://localhost/ms_connector");
httpResp = new MockHttpServletResponse();
diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskTest.java
index 3bd86e63..83284455 100644
--- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskTest.java
+++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskTest.java
@@ -41,6 +41,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchSe
import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.RegisterSearchService.RegisterStatusResults;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.ReceiveAustrianResidenceGuiResponseTask;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.MatchingTaskUtils;
+import at.gv.egiz.eaaf.core.api.IRequestStorage;
import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext;
import at.gv.egiz.eaaf.core.exceptions.EaafStorageException;
import at.gv.egiz.eaaf.core.impl.idp.auth.data.AuthProcessDataWrapper;
@@ -58,6 +59,9 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest {
@Autowired
protected MsConnectorDummyConfigMap authConfig;
+ @Autowired(required = true)
+ protected IRequestStorage requestStoreage;
+
@MockBean
private RegisterSearchService registerSearchService;
@@ -77,7 +81,8 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest {
public void setUp() throws Exception {
executionContext = new ExecutionContextImpl();
task = new ReceiveAustrianResidenceGuiResponseTask(registerSearchService);
-
+ task.setRequestStoreage(requestStoreage);
+
httpReq = new MockHttpServletRequest("POST", "https://localhost/ms_connector");
httpResp = new MockHttpServletResponse();
RequestContextHolder.resetRequestAttributes();
diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveOtherLoginMethodGuiResponseTaskTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveOtherLoginMethodGuiResponseTaskTest.java
index 080731d9..dfd355de 100644
--- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveOtherLoginMethodGuiResponseTaskTest.java
+++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveOtherLoginMethodGuiResponseTaskTest.java
@@ -7,6 +7,8 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
+import java.util.Collections;
+
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -23,14 +25,20 @@ import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
+import at.asitplus.eidas.specific.core.MsEidasNodeConstants;
import at.asitplus.eidas.specific.core.test.config.dummy.MsConnectorDummyConfigMap;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SelectedLoginMethod;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.ReceiveOtherLoginMethodGuiResponseTask;
+import at.gv.egiz.eaaf.core.api.IRequest;
+import at.gv.egiz.eaaf.core.api.IRequestStorage;
+import at.gv.egiz.eaaf.core.api.idp.ISpConfiguration;
import at.gv.egiz.eaaf.core.exceptions.EaafException;
import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException;
+import at.gv.egiz.eaaf.core.impl.idp.module.test.DummySpConfiguration;
import at.gv.egiz.eaaf.core.impl.idp.module.test.TestRequestImpl;
import at.gv.egiz.eaaf.core.impl.idp.process.ExecutionContextImpl;
+import lombok.SneakyThrows;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
@@ -44,6 +52,9 @@ public class ReceiveOtherLoginMethodGuiResponseTaskTest {
@Autowired MsConnectorDummyConfigMap config;
@Autowired
+ private IRequestStorage storage;
+
+ @Autowired
private ReceiveOtherLoginMethodGuiResponseTask task;
private final ExecutionContextImpl executionContext = new ExecutionContextImpl();
@@ -70,22 +81,34 @@ public class ReceiveOtherLoginMethodGuiResponseTaskTest {
RequestContextHolder.resetRequestAttributes();
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpReq, httpResp));
+ ISpConfiguration spConfig = new DummySpConfiguration(Collections.emptyMap(), config);
pendingReq = new TestRequestImpl();
pendingReq.setAuthUrl("https://localhost/ms_connector");
pendingReq.setPendingReqId(RandomStringUtils.randomAlphanumeric(10));
-
+
+ pendingReq.setSpConfig(spConfig);
config.putConfigValue("auth.eIDAS.matching.byaddress.enable", "false");
LocaleContextHolder.resetLocaleContext();
}
@Test
+ @SneakyThrows
public void withStopMatchingSelection() throws TaskExecutionException {
-httpReq.setParameter(Constants.REQ_SELECTED_LOGIN_METHOD_PARAMETER, SelectedLoginMethod.STOP_MATCHING_PROCESS.name());
+ httpReq.setParameter(Constants.REQ_SELECTED_LOGIN_METHOD_PARAMETER, SelectedLoginMethod.STOP_MATCHING_PROCESS.name());
task.execute(pendingReq, executionContext);
- assertTrue("stoppedByUser", pendingReq.isAbortedByUser());
+ assertTrue("stoppedByUser", pendingReq.isAbortedByUser());
+ assertNotNull("matchingstate", pendingReq.getRawData(MsEidasNodeConstants.DATA_MATCHING_STATE));
+ assertEquals("matchingState", MsEidasNodeConstants.MatchingStates.CANCELED_BY_USER,
+ pendingReq.getRawData(MsEidasNodeConstants.DATA_MATCHING_STATE));
+
+ IRequest storedPendingReq = storage.getPendingRequest(pendingReq.getPendingRequestId());
+ assertNotNull("pendingReq not stored", storedPendingReq);
+ assertNotNull("matchingstate storedReq", storedPendingReq.getRawData(MsEidasNodeConstants.DATA_MATCHING_STATE));
+ assertEquals("matchingState storedReq", MsEidasNodeConstants.MatchingStates.CANCELED_BY_USER,
+ storedPendingReq.getRawData(MsEidasNodeConstants.DATA_MATCHING_STATE));
}