aboutsummaryrefslogtreecommitdiff
path: root/eidas_modules/authmodule-eIDAS-v2
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
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')
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/pom.xml13
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateOtherLoginMethodGuiTask.java11
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveOtherLoginMethodGuiResponseTask.java8
-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
5 files changed, 168 insertions, 13 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/pom.xml b/eidas_modules/authmodule-eIDAS-v2/pom.xml
index 0477ee23..95ad2856 100644
--- a/eidas_modules/authmodule-eIDAS-v2/pom.xml
+++ b/eidas_modules/authmodule-eIDAS-v2/pom.xml
@@ -103,6 +103,12 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-tomcat</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
@@ -171,7 +177,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-tomcat</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>com.github.skjolber</groupId>
<artifactId>mockito-soap-cxf</artifactId>
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateOtherLoginMethodGuiTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateOtherLoginMethodGuiTask.java
index 8c3cc994..dbdda78e 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateOtherLoginMethodGuiTask.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateOtherLoginMethodGuiTask.java
@@ -23,6 +23,12 @@
package at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
import at.asitplus.eidas.specific.connector.MsEidasNodeConstants;
import at.asitplus.eidas.specific.connector.gui.StaticGuiBuilderConfiguration;
import at.gv.egiz.eaaf.core.api.gui.IGuiBuilderConfiguration;
@@ -32,11 +38,6 @@ import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext;
import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException;
import at.gv.egiz.eaaf.core.impl.idp.auth.modules.AbstractAuthServletTask;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
/**
* Task that provides GUI for user to select an alternative login method.
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveOtherLoginMethodGuiResponseTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveOtherLoginMethodGuiResponseTask.java
index 0eb56d0b..8431d968 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveOtherLoginMethodGuiResponseTask.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveOtherLoginMethodGuiResponseTask.java
@@ -36,7 +36,7 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SelectedLoginMethod;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.InvalidUserInputException;
import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext;
import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException;
-import at.gv.egiz.eaaf.core.impl.idp.auth.modules.AbstractAuthServletTask;
+import at.gv.egiz.eaaf.core.impl.idp.controller.tasks.AbstractLocaleAuthServletTask;
import lombok.extern.slf4j.Slf4j;
/**
@@ -62,11 +62,11 @@ import lombok.extern.slf4j.Slf4j;
*/
@Slf4j
@Component("ReceiveOtherLoginMethodGuiResponseTask")
-public class ReceiveOtherLoginMethodGuiResponseTask extends AbstractAuthServletTask {
+public class ReceiveOtherLoginMethodGuiResponseTask extends AbstractLocaleAuthServletTask {
@Override
- public void execute(ExecutionContext executionContext, HttpServletRequest request, HttpServletResponse response)
- throws TaskExecutionException {
+ public void executeWithLocale(ExecutionContext executionContext, HttpServletRequest request,
+ HttpServletResponse response) throws TaskExecutionException {
try {
SelectedLoginMethod selection = SelectedLoginMethod.valueOf(extractUserSelection(request));
executionContext.put(Constants.REQ_SELECTED_LOGIN_METHOD_PARAMETER, selection);
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