aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kollmann <christian.kollmann@a-sit.at>2021-02-25 08:33:16 +0100
committerChristian Kollmann <christian.kollmann@a-sit.at>2021-02-25 13:27:15 +0100
commitcdec2bbf39649f0fbe3d1655f5b47f62a5d0bae6 (patch)
treeb948b2e7691b0bd71d9427dcec242f53a3835b05
parent0c4fe92684a707040fd7536da05945a64b309740 (diff)
downloadNational_eIDAS_Gateway-cdec2bbf39649f0fbe3d1655f5b47f62a5d0bae6.tar.gz
National_eIDAS_Gateway-cdec2bbf39649f0fbe3d1655f5b47f62a5d0bae6.tar.bz2
National_eIDAS_Gateway-cdec2bbf39649f0fbe3d1655f5b47f62a5d0bae6.zip
Prepare for Mockito testing of MobilePhoneSignature task
-rw-r--r--connector/pom.xml27
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/pom.xml25
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/EidasSignalServletTest.java1
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseTaskTest.java11
-rw-r--r--pom.xml29
5 files changed, 63 insertions, 30 deletions
diff --git a/connector/pom.xml b/connector/pom.xml
index c2039ad7..0386e1f1 100644
--- a/connector/pom.xml
+++ b/connector/pom.xml
@@ -52,7 +52,7 @@
<artifactId>eaaf_module_pvp2_sp</artifactId>
</dependency>
- <!-- Third party libs -->
+ <!-- Third party libs -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
@@ -66,7 +66,7 @@
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
- </dependency>
+ </dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
@@ -94,7 +94,7 @@
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
- </dependency>
+ </dependency>
<!-- Testing -->
@@ -112,7 +112,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
- </dependency>
+ </dependency>
<dependency>
<groupId>at.gv.egiz.eaaf</groupId>
<artifactId>eaaf_core_utils</artifactId>
@@ -136,10 +136,15 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>at.gv.egiz.eaaf</groupId>
<artifactId>eaaf-springboot-utils</artifactId>
<scope>test</scope>
- </dependency>
+ </dependency>
<dependency>
<groupId>com.github.skjolber</groupId>
<artifactId>mockito-soap-cxf</artifactId>
@@ -161,9 +166,9 @@
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<scope>test</scope>
- </dependency>
+ </dependency>
</dependencies>
-
+
<profiles>
<profile>
<id>default</id>
@@ -173,7 +178,7 @@
<name>default</name>
</property>
</activation>
- <dependencies>
+ <dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
@@ -191,12 +196,12 @@
<dependency>
<groupId>at.gv.egiz.eaaf</groupId>
<artifactId>eaaf-springboot-utils</artifactId>
- </dependency>
+ </dependency>
</dependencies>
</profile>
-
+
</profiles>
-
+
<build>
<finalName>ms_connector</finalName>
diff --git a/eidas_modules/authmodule-eIDAS-v2/pom.xml b/eidas_modules/authmodule-eIDAS-v2/pom.xml
index 1b2681c3..561c4307 100644
--- a/eidas_modules/authmodule-eIDAS-v2/pom.xml
+++ b/eidas_modules/authmodule-eIDAS-v2/pom.xml
@@ -103,7 +103,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
@@ -168,6 +168,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>com.github.skjolber</groupId>
<artifactId>mockito-soap-cxf</artifactId>
<scope>test</scope>
@@ -184,14 +189,14 @@
<version>2.0.7</version>
<scope>test</scope>
</dependency>
-
+
<dependency>
<groupId>at.asitplus.eidas.ms_specific</groupId>
<artifactId>connector_lib</artifactId>
<scope>test</scope>
<type>test-jar</type>
</dependency>
-
+
<dependency>
<groupId>at.gv.egiz.eaaf</groupId>
<artifactId>eaaf_core_utils</artifactId>
@@ -209,19 +214,19 @@
<artifactId>eaaf_module_pvp2_core</artifactId>
<scope>test</scope>
<type>test-jar</type>
- </dependency>
+ </dependency>
<dependency>
<groupId>at.gv.egiz.eaaf</groupId>
<artifactId>eaaf_module_pvp2_idp</artifactId>
<scope>test</scope>
<type>test-jar</type>
- </dependency>
+ </dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<scope>test</scope>
</dependency>
-
+
</dependencies>
<build>
@@ -284,7 +289,7 @@
</execution>
</executions>
</plugin>
-
+
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
@@ -312,8 +317,8 @@
<exclude>**/org/w3/_2000/_09/*</exclude>
<exclude>**/org/w3/_2001/_04/*</exclude>
<exclude>**/szrservices/*</exclude>
- <exclude>**/generated/cxf/*</exclude>
- </excludes>
+ <exclude>**/generated/cxf/*</exclude>
+ </excludes>
</configuration>
</execution>
</executions>
@@ -335,4 +340,4 @@
</plugin>
</plugins>
</build>
-</project> \ No newline at end of file
+</project>
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/EidasSignalServletTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/EidasSignalServletTest.java
index 62d5c556..f1987e33 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/EidasSignalServletTest.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/EidasSignalServletTest.java
@@ -52,7 +52,6 @@ import eu.eidas.specificcommunication.exception.SpecificCommunicationException;
@ContextConfiguration(locations = {
"/SpringTest-context_tasks_test.xml",
"/SpringTest-context_basic_mapConfig.xml"})
-@EnableWebMvc
public class EidasSignalServletTest {
@Autowired private MsConnectorDummyConfigMap basicConfig;
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseTaskTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseTaskTest.java
index 5ea7b59b..c180e6f9 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseTaskTest.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseTaskTest.java
@@ -2,6 +2,7 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.tasks;
import at.asitplus.eidas.specific.connector.test.config.dummy.MsConnectorDummyConfigMap;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.MergedRegisterSearchResult;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.InvalidUserInputException;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.IdAustriaClientAuthConstants;
@@ -31,12 +32,15 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
import org.opensaml.core.xml.io.MarshallingException;
import org.opensaml.core.xml.util.XMLObjectSupport;
import org.opensaml.saml.saml2.core.Issuer;
import org.opensaml.saml.saml2.core.Response;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.test.context.ContextConfiguration;
@@ -49,9 +53,11 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
+import java.util.Collections;
import java.util.Objects;
import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.eq;
import static org.springframework.util.Assert.isInstanceOf;
@RunWith(SpringJUnit4ClassRunner.class)
@@ -73,6 +79,8 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest {
private PvpMetadataResolverFactory metadataFactory;
@Autowired
private ReceiveMobilePhoneSignatureResponseTask task;
+ @MockBean
+ private RegisterSearchService registerSearchService;
private final ExecutionContext executionContext = new ExecutionContextImpl();
private MockHttpServletRequest httpReq;
@@ -96,6 +104,7 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest {
*/
@Before
public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
httpReq = new MockHttpServletRequest("POST", "https://localhost/authhandler");
httpReq.setScheme("https");
httpReq.setServerPort(443);
@@ -320,13 +329,13 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest {
@Test
public void httpPostValidSignedAssertionEidValid() throws Exception {
- // klar darstellen: was ist input, was ist dann expected output ... eigentlich für alle tasks!
metadataProvider.addMetadataResolverIntoChain(metadataFactory.createMetadataProvider(
METADATA_PATH, null, "jUnit IDP", null));
initResponse("/data/Response_with_EID.xml", true);
AuthProcessDataWrapper authProcessData = pendingReq.getSessionData(AuthProcessDataWrapper.class);
SimpleEidasData eidData = createEidasDataMatchingToSamlResponse();
authProcessData.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, eidData);
+ Mockito.when(registerSearchService.searchWithBpkZp(eq("BF:QVGm48cqcM4UcyhDTNGYmVdrIoY="))).thenReturn(new MergedRegisterSearchResult(Collections.emptyList(), Collections.emptyList()));
task.execute(pendingReq, executionContext);
diff --git a/pom.xml b/pom.xml
index 796b640c..734ce689 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,12 +10,12 @@
<name>MS specific eIDAS components</name>
- <properties>
+ <properties>
<!-- Project versions -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>
-
+
<egiz.eidas.version>${project.version}</egiz.eidas.version>
@@ -83,6 +83,16 @@
</activation>
<repositories>
<repository>
+ <id>central</id>
+ <url>https://repo.maven.apache.org/maven2</url>
+ <releases>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
<id>egiz-commons</id>
<url>https://apps.egiz.gv.at/maven/</url>
<releases>
@@ -231,7 +241,6 @@
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>${spring-boot-admin-starter-client.version}</version>
</dependency>
-
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
@@ -333,7 +342,13 @@
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring-boot-starter-web.version}</version>
<scope>test</scope>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <version>${spring-boot-starter-web.version}</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>com.github.skjolber</groupId>
<artifactId>mockito-soap-cxf</artifactId>
@@ -360,14 +375,14 @@
<version>${eaaf-core.version}</version>
<scope>test</scope>
<type>test-jar</type>
- </dependency>
+ </dependency>
<dependency>
<groupId>at.gv.egiz.eaaf</groupId>
<artifactId>eaaf_module_pvp2_idp</artifactId>
<version>${eaaf-core.version}</version>
<scope>test</scope>
<type>test-jar</type>
- </dependency>
+ </dependency>
<dependency>
<groupId>at.asitplus.eidas.ms_specific</groupId>
<artifactId>connector_lib</artifactId>
@@ -599,7 +614,7 @@
</execution>
</executions>
<configuration>
- <linkXref>false</linkXref>
+ <linkXRef>false</linkXRef>
<sourceEncoding>utf-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
<targetJdk>1.8</targetJdk>