aboutsummaryrefslogtreecommitdiff
path: root/connector/src/test/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'connector/src/test/java/at')
-rw-r--r--connector/src/test/java/at/asitplus/eidas/specific/connector/test/MainClassExecutableModeTest.java109
-rw-r--r--connector/src/test/java/at/asitplus/eidas/specific/connector/test/MainClassWebAppModeTest.java129
-rw-r--r--connector/src/test/java/at/asitplus/eidas/specific/connector/test/config/BasicConfigurationTest.java (renamed from connector/src/test/java/at/asitplus/eidas/specific/connector/test/BasicConfigurationTest.java)2
-rw-r--r--connector/src/test/java/at/asitplus/eidas/specific/connector/test/utils/AuthenticationDataBuilderTest.java (renamed from connector/src/test/java/at/asitplus/eidas/specific/connector/test/AuthenticationDataBuilderTest.java)2
-rw-r--r--connector/src/test/java/at/asitplus/eidas/specific/connector/test/utils/AuthnRequestValidatorTest.java (renamed from connector/src/test/java/at/asitplus/eidas/specific/connector/test/AuthnRequestValidatorTest.java)2
-rw-r--r--connector/src/test/java/at/asitplus/eidas/specific/connector/test/utils/CountrySelectionProcessImplTest.java (renamed from connector/src/test/java/at/asitplus/eidas/specific/connector/test/CountrySelectionProcessImplTest.java)2
6 files changed, 242 insertions, 4 deletions
diff --git a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/MainClassExecutableModeTest.java b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/MainClassExecutableModeTest.java
new file mode 100644
index 00000000..66147971
--- /dev/null
+++ b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/MainClassExecutableModeTest.java
@@ -0,0 +1,109 @@
+package at.asitplus.eidas.specific.connector.test;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.ignite.Ignition;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.BlockJUnit4ClassRunner;
+
+import at.asitplus.eidas.specific.connector.SpringBootApplicationInitializer;
+import at.gv.egiz.eaaf.core.impl.logging.DummyStatusMessager;
+import at.gv.egiz.eaaf.core.impl.logging.LogMessageProviderFactory;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+@RunWith(BlockJUnit4ClassRunner.class)
+public class MainClassExecutableModeTest {
+
+ /**
+ * jUnit class initializer.
+ * @throws InterruptedException In case of an error
+ *
+ */
+ @BeforeClass
+ public static void classInitializer() throws InterruptedException {
+ final String current = new java.io.File(".").toURI().toString();
+ System.clearProperty("eidas.ms.configuration");
+
+ //eIDAS Ref. Impl. properties
+ System.setProperty("EIDAS_CONFIG_REPOSITORY", current.substring("file:".length())
+ + "../basicConfig/eIDAS/");
+ System.setProperty("SPECIFIC_CONNECTOR_CONFIG_REPOSITORY", current.substring("file:".length())
+ + "../basicConfig/eIDAS/");
+ System.setProperty("SPECIFIC_PROXY_SERVICE_CONFIG_REPOSITORY", current.substring("file:".length())
+ + "../basicConfig/eIDAS/");
+
+ }
+
+ /**
+ * Initializer.
+ * @throws InterruptedException In case of an error
+ *
+ */
+ @AfterClass
+ public static void closeIgniteNode() throws InterruptedException {
+ System.out.println("Closing Ignite Node ... ");
+
+ log.info("Stopping already running Apache Ignite nodes ... ");
+ Ignition.stopAll(true);
+ Thread.sleep(1000);
+
+ }
+
+ /**
+ * Test reseter.
+ *
+ */
+ @After
+ public void cleanJvmState() throws NoSuchFieldException, SecurityException,
+ IllegalArgumentException, IllegalAccessException {
+ final Field field = LogMessageProviderFactory.class.getDeclaredField("internalMessager");
+ field.setAccessible(true);
+ field.set(null, new DummyStatusMessager());
+
+ System.clearProperty("eidas.ms.configuration");
+ SpringBootApplicationInitializer.exit();
+
+ }
+
+
+ @Test
+ public void validConfigLocation() throws ClientProtocolException, IOException {
+ SpringBootApplicationInitializer
+ .main(new String[] {
+ "--spring.config.location=src/test/resources/config/junit_config_1_springboot.properties,classpath:/application.properties",
+ "--spring.profiles.active=jUnitTestMode,springBoot" });
+
+ System.out.println("Is started!");
+
+ // test Spring-Actuator http Basic-Auth
+ testSpringActuatorSecurity();
+
+ }
+
+ private void testSpringActuatorSecurity() throws ClientProtocolException, IOException {
+ // check if authentication works on actuator end-point
+ final HttpClientBuilder builder = HttpClients.custom();
+ final CloseableHttpClient client = builder.build();
+ Assert.assertNotNull("httpClient", client);
+
+ final HttpUriRequest httpGet1 = new HttpGet("http://localhost:8080/ms_connector/actuator/info");
+ final CloseableHttpResponse httpResp1 = client.execute(httpGet1);
+ Assert.assertEquals("http statusCode", 200, httpResp1.getStatusLine().getStatusCode());
+
+ }
+
+}
diff --git a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/MainClassWebAppModeTest.java b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/MainClassWebAppModeTest.java
new file mode 100644
index 00000000..265edfb6
--- /dev/null
+++ b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/MainClassWebAppModeTest.java
@@ -0,0 +1,129 @@
+package at.asitplus.eidas.specific.connector.test;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.ignite.Ignition;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.BlockJUnit4ClassRunner;
+
+import at.asitplus.eidas.specific.connector.SpringBootApplicationInitializer;
+import at.gv.egiz.eaaf.core.impl.logging.DummyStatusMessager;
+import at.gv.egiz.eaaf.core.impl.logging.LogMessageProviderFactory;
+
+@RunWith(BlockJUnit4ClassRunner.class)
+public class MainClassWebAppModeTest {
+
+ /**
+ * jUnit class initializer.
+ *
+ */
+ @BeforeClass
+ public static void classInitializer() {
+ final String current = new java.io.File(".").toURI().toString();
+
+ //eIDAS Ref. Impl. properties
+ System.setProperty("EIDAS_CONFIG_REPOSITORY", current.substring("file:".length())
+ + "../basicConfig/eIDAS/");
+ System.setProperty("SPECIFIC_CONNECTOR_CONFIG_REPOSITORY", current.substring("file:".length())
+ + "../basicConfig/eIDAS/");
+ System.setProperty("SPECIFIC_PROXY_SERVICE_CONFIG_REPOSITORY", current.substring("file:".length())
+ + "../basicConfig/eIDAS/");
+
+ }
+
+ /**
+ * Initializer.
+ *
+ */
+ @AfterClass
+ public static void closeIgniteNode() {
+ System.out.println("Closing Ignite Node ... ");
+ Ignition.stopAll(true);
+
+ }
+
+ /**
+ * Test reseter.
+ *
+ */
+ @After
+ public void cleanJvmState() throws NoSuchFieldException, SecurityException,
+ IllegalArgumentException, IllegalAccessException {
+ final Field field = LogMessageProviderFactory.class.getDeclaredField("internalMessager");
+ field.setAccessible(true);
+ field.set(null, new DummyStatusMessager());
+
+ System.clearProperty("eidas.ms.configuration");
+ SpringBootApplicationInitializer.exit();
+
+ }
+
+ @Test
+ public void wrongConfigLocation() {
+ //MS-specific connector property
+ final String current = new java.io.File(".").toURI().toString();
+ System.setProperty("eidas.ms.configuration", current
+ + "src/test/resources/config/notextist.properties");
+
+ try {
+ //starting application
+ SpringBootApplicationInitializer
+ .main(new String[] {
+ "--spring.profiles.active=jUnitTestMode,springBoot" });
+ Assert.fail("Missing configuration not detected");
+
+ } catch (final Exception e) {
+ Assert.assertNotNull("Exception is null", e);
+
+ }
+ }
+
+
+ @Test
+ public void systemdConfigLocation() throws ClientProtocolException, IOException {
+ //MS-specific connector property
+ final String current = new java.io.File(".").toURI().toString();
+ System.setProperty("eidas.ms.configuration", current
+ + "src/test/resources/config/junit_config_1_springboot.properties");
+
+ //starting application
+ SpringBootApplicationInitializer
+ .main(new String[] {
+ "--spring.profiles.active=jUnitTestMode,springBoot" });
+
+ System.out.println("Is started!");
+
+ // test Spring-Actuator http Basic-Auth
+ testSpringActuatorSecurity();
+
+
+
+
+ }
+
+ private void testSpringActuatorSecurity() throws ClientProtocolException, IOException {
+ // check if authentication works on actuator end-point
+ final HttpClientBuilder builder = HttpClients.custom();
+ final CloseableHttpClient client = builder.build();
+ Assert.assertNotNull("httpClient", client);
+
+ final HttpUriRequest httpGet1 = new HttpGet("http://localhost:8080/ms_connector/actuator/info");
+ final CloseableHttpResponse httpResp1 = client.execute(httpGet1);
+ Assert.assertEquals("http statusCode", 200, httpResp1.getStatusLine().getStatusCode());
+
+ }
+
+}
diff --git a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/BasicConfigurationTest.java b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/config/BasicConfigurationTest.java
index 6e52f113..86342f99 100644
--- a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/BasicConfigurationTest.java
+++ b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/config/BasicConfigurationTest.java
@@ -1,4 +1,4 @@
-package at.asitplus.eidas.specific.connector.test;
+package at.asitplus.eidas.specific.connector.test.config;
import java.net.MalformedURLException;
import java.net.URL;
diff --git a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/AuthenticationDataBuilderTest.java b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/utils/AuthenticationDataBuilderTest.java
index 316dcb5f..87abb06f 100644
--- a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/AuthenticationDataBuilderTest.java
+++ b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/utils/AuthenticationDataBuilderTest.java
@@ -1,4 +1,4 @@
-package at.asitplus.eidas.specific.connector.test;
+package at.asitplus.eidas.specific.connector.test.utils;
import static at.asitplus.eidas.specific.connector.MsEidasNodeConstants.PROP_CONFIG_SP_NEW_EID_MODE;
diff --git a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/AuthnRequestValidatorTest.java b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/utils/AuthnRequestValidatorTest.java
index 389f561e..a9929a01 100644
--- a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/AuthnRequestValidatorTest.java
+++ b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/utils/AuthnRequestValidatorTest.java
@@ -1,4 +1,4 @@
-package at.asitplus.eidas.specific.connector.test;
+package at.asitplus.eidas.specific.connector.test.utils;
import java.io.IOException;
import java.util.HashMap;
diff --git a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/CountrySelectionProcessImplTest.java b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/utils/CountrySelectionProcessImplTest.java
index 455288f5..d0343eba 100644
--- a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/CountrySelectionProcessImplTest.java
+++ b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/utils/CountrySelectionProcessImplTest.java
@@ -1,4 +1,4 @@
-package at.asitplus.eidas.specific.connector.test;
+package at.asitplus.eidas.specific.connector.test.utils;
import java.util.HashMap;
import java.util.Map;