From 2119f7613a04651d7cc1cb9a8c7ecdc8556d07d9 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Fri, 11 Mar 2022 07:09:27 +0100 Subject: fix(matching): unset all matching releated parameters on executioncontext --- .../tasks/GenerateOtherLoginMethodGuiTaskTest.java | 32 +++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'modules/authmodule-eIDAS-v2/src/test/java') diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/GenerateOtherLoginMethodGuiTaskTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/GenerateOtherLoginMethodGuiTaskTest.java index cc092004..1751e95a 100644 --- a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/GenerateOtherLoginMethodGuiTaskTest.java +++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/GenerateOtherLoginMethodGuiTaskTest.java @@ -2,6 +2,7 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.tasks; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.io.UnsupportedEncodingException; @@ -30,8 +31,10 @@ import com.fasterxml.jackson.databind.json.JsonMapper; 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.GenerateOtherLoginMethodGuiTask; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.ReceiveOtherLoginMethodGuiResponseTask; import at.asitplus.eidas.specific.modules.auth.eidas.v2.test.dummy.DummyOA; import at.gv.egiz.eaaf.core.api.IRequestStorage; +import at.gv.egiz.eaaf.core.api.data.EaafConstants; import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; import at.gv.egiz.eaaf.core.impl.idp.module.test.TestRequestImpl; import at.gv.egiz.eaaf.core.impl.idp.process.ExecutionContextImpl; @@ -54,7 +57,7 @@ public class GenerateOtherLoginMethodGuiTaskTest { @Autowired IRequestStorage storage; - private ExecutionContextImpl executionContext = new ExecutionContextImpl(); + private ExecutionContextImpl executionContext; private TestRequestImpl pendingReq; private MockHttpServletRequest httpReq; private MockHttpServletResponse httpResp; @@ -80,10 +83,37 @@ public class GenerateOtherLoginMethodGuiTaskTest { pendingReq.setPendingReqId(RandomStringUtils.randomAlphanumeric(10)); pendingReq.setSpConfig(new DummyOA()); + executionContext = new ExecutionContextImpl(); + LocaleContextHolder.resetLocaleContext(); } + @Test + @SneakyThrows + public void unsetExecutionContextParameters() throws TaskExecutionException, UnsupportedEncodingException { + httpReq.addHeader("Accept", "application/json"); + ReceiveOtherLoginMethodGuiResponseTask.ALL_EXECUTIONCONTEXT_PARAMETERS.forEach( + el -> executionContext.put(el, RandomStringUtils.randomAlphabetic(5))); + + // execute test + task.execute(pendingReq, executionContext); + + //result validation + Assert.assertEquals("httpStausCode", 200, httpResp.getStatus()); + Assert.assertEquals("http ContentType", "application/json;charset=UTF-8", httpResp.getContentType()); + + ReceiveOtherLoginMethodGuiResponseTask.ALL_EXECUTIONCONTEXT_PARAMETERS.forEach( + el -> assertNull("executionContext parameter: " + el, executionContext.get(el))); + + // remove pendingRequestId because it's added by default + executionContext.remove(EaafConstants.PROCESS_ENGINE_PENDINGREQUESTID); + + // in case of 'ReceiveOtherLoginMethodGuiResponseTask.ALL_EXECUTIONCONTEXT_PARAMETERS' does not include all parameters + assertTrue("ExecutionContext is not empty", executionContext.keySet().isEmpty()); + + } + @Test @SneakyThrows public void jsonResponse() throws TaskExecutionException, UnsupportedEncodingException { -- cgit v1.2.3