aboutsummaryrefslogtreecommitdiff
path: root/eidas_modules/authmodule-eIDAS-v2/src/test
diff options
context:
space:
mode:
authorThomas <>2021-07-07 09:31:43 +0200
committerThomas <>2021-07-07 09:31:43 +0200
commitcbf1d0408519d0763a1a87b733c16a1ba5d022ba (patch)
tree6a714ea861f3d6687e4105a075124cc98eab8074 /eidas_modules/authmodule-eIDAS-v2/src/test
parent249e3805da249afafe164ae7dc43884ba3777727 (diff)
downloadNational_eIDAS_Gateway-cbf1d0408519d0763a1a87b733c16a1ba5d022ba.tar.gz
National_eIDAS_Gateway-cbf1d0408519d0763a1a87b733c16a1ba5d022ba.tar.bz2
National_eIDAS_Gateway-cbf1d0408519d0763a1a87b733c16a1ba5d022ba.zip
add HTML template for additional eID information
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/test')
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/GenerateOtherLoginMethodGuiTaskTest.java143
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_1.properties6
2 files changed, 146 insertions, 3 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/GenerateOtherLoginMethodGuiTaskTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/GenerateOtherLoginMethodGuiTaskTest.java
new file mode 100644
index 00000000..0b169ca4
--- /dev/null
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/GenerateOtherLoginMethodGuiTaskTest.java
@@ -0,0 +1,143 @@
+package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.tasks;
+
+import java.io.UnsupportedEncodingException;
+import java.text.MessageFormat;
+import java.util.Locale;
+
+import org.apache.commons.lang3.RandomStringUtils;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.i18n.LocaleContextHolder;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+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.modules.auth.eidas.v2.dao.SelectedLoginMethod;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.GenerateOtherLoginMethodGuiTask;
+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;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = {
+ "/SpringTest-context_tasks_test.xml",
+ "/SpringTest-context_basic_mapConfig.xml",
+ "/common_gui.beans.xml"
+})
+@WebAppConfiguration
+public class GenerateOtherLoginMethodGuiTaskTest {
+
+ private static final String TEST_PATTER_REQ_PARAM =
+ "<input type=\"hidden\" name=\"loginSelection\" value=\"{0}\">";
+
+ @Autowired GenerateOtherLoginMethodGuiTask task;
+
+ private ExecutionContextImpl executionContext = new ExecutionContextImpl();
+ private TestRequestImpl pendingReq;
+ private MockHttpServletRequest httpReq;
+ private MockHttpServletResponse httpResp;
+
+ /**
+ * jUnit test set-up.
+ *
+ */
+ @Before
+ public void initialize() {
+ httpReq = new MockHttpServletRequest("POST", "https://localhost/ms_connector");
+ httpResp = new MockHttpServletResponse();
+ RequestContextHolder.resetRequestAttributes();
+ RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpReq, httpResp));
+
+ pendingReq = new TestRequestImpl();
+ pendingReq.setAuthUrl("https://localhost/ms_connector");
+ pendingReq.setPendingReqId(RandomStringUtils.randomAlphanumeric(10));
+
+ LocaleContextHolder.resetLocaleContext();
+ }
+
+ @Test
+ public void validHtmlResponseWithOutLocale() throws TaskExecutionException, UnsupportedEncodingException {
+
+ task.execute(pendingReq, executionContext);
+
+ //result validation
+ String html = doBasicValidation();
+
+ Assert.assertTrue("No english text",
+ html.contains("Information on Logins with European eIDs"));
+
+ }
+
+ @Test
+ public void validHtmlResponseWithDE() throws TaskExecutionException, UnsupportedEncodingException {
+ LocaleContextHolder.setLocale(Locale.GERMAN);
+ httpReq.addHeader("Accept-Language", "de");
+
+ task.execute(pendingReq, executionContext);
+
+ //result validation
+ String html = doBasicValidation();
+
+ Assert.assertTrue("No english text",
+ html.contains("Information zur Anmeldung über Europäische eIDs"));
+
+ }
+
+ @Test
+ public void validHtmlResponseWithEN() throws TaskExecutionException, UnsupportedEncodingException {
+ LocaleContextHolder.setLocale(Locale.ENGLISH);
+
+ task.execute(pendingReq, executionContext);
+
+ //result validation
+ String html = doBasicValidation();
+
+ Assert.assertTrue("No english text",
+ html.contains("Information on Logins with European eIDs"));
+
+ }
+
+ @Test
+ public void validHtmlResponseWithFR() throws TaskExecutionException, UnsupportedEncodingException {
+ LocaleContextHolder.setLocale(Locale.FRANCE);
+ httpReq.addHeader("Accept-Language", "fr");
+
+ task.execute(pendingReq, executionContext);
+
+ //result validation
+ String html = doBasicValidation();
+
+ Assert.assertTrue("No english text",
+ html.contains("Information on Logins with European eIDs"));
+
+ }
+
+ private String doBasicValidation() throws UnsupportedEncodingException {
+ Assert.assertEquals("Wrong http StatusCode", 200, httpResp.getStatus());
+ Assert.assertEquals("Wrong http ContentType", "text/html;charset=UTF-8", httpResp.getContentType());
+
+ String html = httpResp.getContentAsString();
+ Assert.assertNotNull("html result is null", html);
+ Assert.assertFalse("html result is empty", html.isEmpty());
+
+ Assert.assertTrue("Missing IDA Login",
+ html.contains(MessageFormat.format(TEST_PATTER_REQ_PARAM, SelectedLoginMethod.MOBILE_PHONE_SIGNATURE_LOGIN)));
+ Assert.assertTrue("Missing residence infos",
+ html.contains(MessageFormat.format(TEST_PATTER_REQ_PARAM, SelectedLoginMethod.NO_OTHER_LOGIN)));
+
+ Assert.assertTrue("No language selector with pendingRequestId",
+ html.contains("/otherLoginMethod?pendingid=" + pendingReq.getPendingRequestId()));
+ Assert.assertTrue("No country-selection form",
+ html.contains("<form class=\"block\" method=\"post\" action=\"/otherLoginMethod\">"));
+
+ return html;
+
+ }
+}
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_1.properties b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_1.properties
index f5895f76..9e6876f4 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_1.properties
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/resources/config/junit_config_1.properties
@@ -19,9 +19,9 @@ eidas.ms.revisionlog.write.MDS.into.revisionlog=true
eidas.ms.revisionlog.logIPAddressOfUser=true
##Directory for static Web content
-eidas.ms.webcontent.static.directory=webcontent/
-eidas.ms.webcontent.templates=templates/
-eidas.ms.webcontent.properties=properties/messages
+eidas.ms.webcontent.static.directory=../../../../../../basicConfig/webcontent/
+eidas.ms.webcontent.templates=../../../../../../basicConfig/templates/
+eidas.ms.webcontent.properties=../../../../../../basicConfig/properties/messages
## extended validation of pending-request Id's
eidas.ms.core.pendingrequestid.maxlifetime=300