diff options
author | Thomas <> | 2022-03-11 07:09:27 +0100 |
---|---|---|
committer | Thomas <> | 2022-03-11 07:09:27 +0100 |
commit | 2119f7613a04651d7cc1cb9a8c7ecdc8556d07d9 (patch) | |
tree | 0d7ad91571b55e4eb74e7cefdcaaed7584bec599 /modules/authmodule-eIDAS-v2/src/test/java | |
parent | f2df62788d1c47aea5dc16d985fd8b4fd9fa424c (diff) | |
download | National_eIDAS_Gateway-2119f7613a04651d7cc1cb9a8c7ecdc8556d07d9.tar.gz National_eIDAS_Gateway-2119f7613a04651d7cc1cb9a8c7ecdc8556d07d9.tar.bz2 National_eIDAS_Gateway-2119f7613a04651d7cc1cb9a8c7ecdc8556d07d9.zip |
fix(matching): unset all matching releated parameters on executioncontext
Diffstat (limited to 'modules/authmodule-eIDAS-v2/src/test/java')
-rw-r--r-- | modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/GenerateOtherLoginMethodGuiTaskTest.java | 32 |
1 files changed, 31 insertions, 1 deletions
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,12 +83,39 @@ 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 { String reason = RandomStringUtils.randomAlphabetic(5); executionContext.put(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED, true); |