From 847e3f5b52a7adc6baa463258087e562049ee89b Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Fri, 1 Jul 2022 14:27:19 +0200 Subject: feat(matching): add configuration property to disable 'matching-by-address-search' --- .../tasks/GenerateOtherLoginMethodGuiTaskTest.java | 30 ++++++++++++++------- ...ReceiveOtherLoginMethodGuiResponseTaskTest.java | 31 ++++++++++++++++++++++ 2 files changed, 52 insertions(+), 9 deletions(-) (limited to 'modules/authmodule-eIDAS-v2/src/test') 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 496158fa..6d08a731 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 @@ -29,6 +29,7 @@ import org.springframework.web.context.request.ServletRequestAttributes; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.json.JsonMapper; +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.GenerateOtherLoginMethodGuiTask; @@ -53,6 +54,8 @@ public class GenerateOtherLoginMethodGuiTaskTest { private static final String TEST_PATTER_REQ_PARAM = ""; + @Autowired MsConnectorDummyConfigMap config; + @Autowired GenerateOtherLoginMethodGuiTask task; @@ -86,6 +89,9 @@ public class GenerateOtherLoginMethodGuiTaskTest { executionContext = new ExecutionContextImpl(); + config.putConfigValue("auth.eIDAS.matching.byaddress.enable", "false"); + + LocaleContextHolder.resetLocaleContext(); } @@ -172,6 +178,10 @@ public class GenerateOtherLoginMethodGuiTaskTest { assertNotNull("createNewErnpEntry", json.get(Constants.HTML_FORM_CREATE_NEW_ERNP_ENTRY)); assertFalse("createNewErnpEntry", json.get(Constants.HTML_FORM_CREATE_NEW_ERNP_ENTRY).asBoolean()); + assertNotNull("enableMatchingByAddressSearch", json.get(Constants.HTML_FORM_CREATE_NEW_ERNP_ENTRY)); + assertFalse("enableMatchingByAddressSearch", json.get(Constants.HTML_FORM_CREATE_NEW_ERNP_ENTRY).asBoolean()); + + assertNotNull("pendingRequest not stored", storage.getPendingRequest(pendingReq.getPendingRequestId())); @@ -199,10 +209,11 @@ public class GenerateOtherLoginMethodGuiTaskTest { @Test public void advancedMatchingFailedMsg() throws TaskExecutionException, UnsupportedEncodingException { executionContext.put(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED, true); - + config.putConfigValue("auth.eIDAS.matching.byaddress.enable", "true"); + task.execute(pendingReq, executionContext); - String html = doBasicValidation(); + String html = doBasicValidation(true); Assert.assertFalse("Missing eIDAS infos", html.contains(MessageFormat.format(TEST_PATTER_REQ_PARAM, SelectedLoginMethod.ADD_ME_AS_NEW))); Assert.assertTrue("missing errorfield", @@ -218,7 +229,7 @@ public class GenerateOtherLoginMethodGuiTaskTest { task.execute(pendingReq, executionContext); - String html = doBasicValidation(); + String html = doBasicValidation(false); Assert.assertTrue("missing errorfield", html.contains("
task.execute(pendingReq, executionContext)); + + assertEquals("wrong errorCode", "module.eidasauth.matching.98", + ((EaafException) error.getOriginalException()).getErrorId()); + + } + @Test public void withAddMeAsNewSelection() throws TaskExecutionException { testTransition(SelectedLoginMethod.ADD_ME_AS_NEW, Constants.TRANSITION_TO_CREATE_NEW_ERNP_ENTRY_TASK); @@ -99,6 +120,14 @@ public class ReceiveOtherLoginMethodGuiResponseTaskTest { } + @Test + public void withRequestingNewEntrySelection() throws TaskExecutionException { + testTransition(SelectedLoginMethod.REQUESTING_NEW_ENTRY, Constants.TRANSITION_TO_REQUESTING_NEW_ERNP_ENTRY_TASK); + assertEquals("return to selection", true, executionContext.get(Constants.TRANSITION_TO_REQUESTING_NEW_ERNP_ENTRY_TASK)); + assertEquals("return to selection", false, executionContext.get(Constants.TRANSITION_TO_GENERATE_OTHER_LOGIN_METHOD_GUI_TASK)); + + } + public void testTransition(SelectedLoginMethod loginMethod, String expectedTransition) throws TaskExecutionException { httpReq.setParameter(Constants.REQ_SELECTED_LOGIN_METHOD_PARAMETER, loginMethod.name()); executionContext.put(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED, true); @@ -109,6 +138,8 @@ public class ReceiveOtherLoginMethodGuiResponseTaskTest { assertFalse("wrong process-cancelled flag", executionContext.isProcessCancelled()); assertNotNull("no login-selection found", executionContext.get(Constants.REQ_SELECTED_LOGIN_METHOD_PARAMETER)); assertEquals("Wrong login-selection found", loginMethod.name(), executionContext.get(Constants.REQ_SELECTED_LOGIN_METHOD_PARAMETER)); + + assertEquals("Next task", true, executionContext.get(expectedTransition)); assertNull("find advancedMatchingError flag", executionContext.get(Constants.CONTEXT_FLAG_ADVANCED_MATCHING_FAILED)); -- cgit v1.2.3