aboutsummaryrefslogtreecommitdiff
path: root/connector
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2020-12-22 14:15:14 +0100
committerThomas Lenz <thomas.lenz@egiz.gv.at>2020-12-22 14:15:14 +0100
commit9fd7ba09ba2a5a827ef8530967aa0bfefc412f42 (patch)
treeab1c6f7ab54851a436c2e2bd12d331f6651fcdb9 /connector
parent83d7101ae4169a840e13e2b178fd7a07108fff2d (diff)
downloadNational_eIDAS_Gateway-9fd7ba09ba2a5a827ef8530967aa0bfefc412f42.tar.gz
National_eIDAS_Gateway-9fd7ba09ba2a5a827ef8530967aa0bfefc412f42.tar.bz2
National_eIDAS_Gateway-9fd7ba09ba2a5a827ef8530967aa0bfefc412f42.zip
add jUnit tests for configuration-operations
Diffstat (limited to 'connector')
-rw-r--r--connector/src/test/java/at/asitplus/eidas/specific/connector/test/controller/ProcessEngineSignalControllerTest.java75
1 files changed, 75 insertions, 0 deletions
diff --git a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/controller/ProcessEngineSignalControllerTest.java b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/controller/ProcessEngineSignalControllerTest.java
new file mode 100644
index 00000000..cd502c48
--- /dev/null
+++ b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/controller/ProcessEngineSignalControllerTest.java
@@ -0,0 +1,75 @@
+package at.asitplus.eidas.specific.connector.test.controller;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+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.connector.controller.ProcessEngineSignalController;
+import at.gv.egiz.eaaf.core.exceptions.EaafException;
+import at.gv.egiz.eaaf.core.exceptions.EaafStorageException;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration({
+ "/applicationContext.xml",
+ "/specific_eIDAS_connector.beans.xml",
+ "/eaaf_core.beans.xml",
+ "/eaaf_pvp.beans.xml",
+ "/eaaf_pvp_idp.beans.xml",
+ "/spring/SpringTest-context_simple_storage.xml" })
+@WebAppConfiguration
+public class ProcessEngineSignalControllerTest {
+
+ @Autowired private ProcessEngineSignalController controller;
+
+ private MockHttpServletRequest httpReq;
+ private MockHttpServletResponse httpResp;
+
+ @BeforeClass
+ public static void classInitializer() {
+ final String current = new java.io.File(".").toURI().toString();
+ System.setProperty("eidas.ms.configuration", current + "src/test/resources/config/junit_config_1.properties");
+
+ }
+
+ /**
+ * jUnit test set-up.
+ */
+ @Before
+ public void setUp() throws EaafStorageException, URISyntaxException {
+ httpReq = new MockHttpServletRequest("POST", "https://localhost/authhandler");
+ httpResp = new MockHttpServletResponse();
+ RequestContextHolder.resetRequestAttributes();
+ RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpReq, httpResp));
+
+ }
+
+ @Test
+ public void noPendingRequestId() throws IOException, EaafException {
+ //set-up
+
+ //execute test
+ controller.performGenericAuthenticationProcess(httpReq, httpResp);
+
+ //validate state
+ Assert.assertEquals("http StatusCode", 302, httpResp.getStatus());
+ Assert.assertNotNull("redirect header", httpResp.getHeaderValue("Location"));
+ Assert.assertTrue("wrong redirect header",
+ httpResp.getHeader("Location").startsWith("http://localhost/errorHandling?errorid="));
+
+ }
+
+
+}