diff options
-rw-r--r-- | pom.xml | 30 | ||||
-rw-r--r-- | readme.md | 23 | ||||
-rw-r--r-- | src/main/java/at/gv/egiz/moazs/config/MarshallerConfig.java | 5 | ||||
-rw-r--r-- | src/test/java/at/gv/egiz/moazs/ITMoaSPSSSignatureVerifierTest.java (renamed from src/test/java/at/gv/egiz/moazs/MoaSPSSSignatureVerifierTest.java) | 4 | ||||
-rw-r--r-- | src/test/java/at/gv/egiz/moazs/ITMsgClientTest.java (renamed from src/test/java/at/gv/egiz/moazs/MsgClientTest.java) | 51 | ||||
-rw-r--r-- | src/test/java/at/gv/egiz/moazs/ITMzsServiceTest.java (renamed from src/test/java/at/gv/egiz/moazs/MzsServiceTest.java) | 6 | ||||
-rw-r--r-- | src/test/resources/at/gv/egiz/moazs/ITMoaSPSSSignatureVerifierTest/invalid-signed-delivery-response.xml (renamed from src/test/resources/at/gv/egiz/moazs/MoaSPSSSignatureVerifierTest/invalid-signed-delivery-response.xml) | 0 | ||||
-rw-r--r-- | src/test/resources/at/gv/egiz/moazs/ITMoaSPSSSignatureVerifierTest/valid-signed-delivery-response.xml (renamed from src/test/resources/at/gv/egiz/moazs/MoaSPSSSignatureVerifierTest/valid-signed-delivery-response.xml) | 0 | ||||
-rw-r--r-- | src/test/resources/at/gv/egiz/moazs/ITMsgClientTest/validDeliveryRequest.xml (renamed from src/test/resources/at/gv/egiz/moazs/MsgClientTest/validDeliveryRequest.xml) | 0 | ||||
-rw-r--r-- | src/test/resources/at/gv/egiz/moazs/ITMzsServiceTest/formallyIncorrectDeliveryRequest.soap (renamed from src/test/resources/at/gv/egiz/moazs/MzsServiceTest/formallyIncorrectDeliveryRequest.soap) | 0 | ||||
-rw-r--r-- | src/test/resources/at/gv/egiz/moazs/ITMzsServiceTest/missingAppDeliveryId.soap (renamed from src/test/resources/at/gv/egiz/moazs/MzsServiceTest/missingAppDeliveryId.soap) | 0 | ||||
-rw-r--r-- | src/test/resources/at/gv/egiz/moazs/ITMzsServiceTest/missingMetaData.soap (renamed from src/test/resources/at/gv/egiz/moazs/MzsServiceTest/missingMetaData.soap) | 0 | ||||
-rw-r--r-- | src/test/resources/at/gv/egiz/moazs/ITMzsServiceTest/missingSender.soap (renamed from src/test/resources/at/gv/egiz/moazs/MzsServiceTest/missingSender.soap) | 0 | ||||
-rw-r--r-- | src/test/resources/at/gv/egiz/moazs/ITMzsServiceTest/profileAndCorporateBody.soap (renamed from src/test/resources/at/gv/egiz/moazs/MzsServiceTest/profileAndCorporateBody.soap) | 0 | ||||
-rw-r--r-- | src/test/resources/at/gv/egiz/moazs/ITMzsServiceTest/validDeliveryRequest.soap (renamed from src/test/resources/at/gv/egiz/moazs/MzsServiceTest/validDeliveryRequest.soap) | 0 |
15 files changed, 83 insertions, 36 deletions
@@ -43,6 +43,7 @@ <jacoco.version>0.8.3</jacoco.version> <egovutils.version>2.0.7-snapshot</egovutils.version> <eaaf-components.version>1.0.7</eaaf-components.version> + <maven-surefire-plugin.version>2.22.1</maven-surefire-plugin.version> <mzs.ns>http://reference.e-government.gv.at/namespace/zustellung/mzs/app2mzs#</mzs.ns> <mzs.p.ns>http://reference.e-government.gv.at/namespace/zustellung/mzs/persondata#</mzs.p.ns> @@ -59,6 +60,23 @@ <tnvz.package>at.gv.zustellung.tnvz.xsd</tnvz.package> </properties> + <profiles> + <profile> + <id>dev</id> + <activation><activeByDefault>true</activeByDefault></activation> + <properties> + <exclude-test-pattern>**/IT*Test.java</exclude-test-pattern> + </properties> + </profile> + <profile> + <id>integration-test</id> + <properties> + <exclude-test-pattern></exclude-test-pattern> + </properties> + </profile> + </profiles> + + <dependencies> <!-- spring-boot --> <dependency> @@ -223,6 +241,18 @@ </execution> </executions> </plugin> + <!-- tests --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${maven-surefire-plugin.version}</version> + <configuration> + <excludes> + <exclude>${exclude-test-pattern}</exclude> + </excludes> + </configuration> + </plugin> + </plugins> </build> </project> @@ -53,10 +53,29 @@ cp <path-to-local-eaaf-components-git-repo>/eaaf_modules/eaaf_module_moa-sig/rep ## Compile & Test -Requirements: openJDK 12 (OpenJDK 11 has an unfixed bug [1] that prevents the completion of TLS handshakes.) +### Run Unit Tests +Requirements: +- openJDK 12 (OpenJDK 11 has an unfixed bug [1] that prevents the completion of TLS handshakes.) + +Command: ``` mvn test ``` -[1] https://bugs.openjdk.java.net/browse/JDK-8214098
\ No newline at end of file +### Run Integration Tests + +Integration tests start with the prefix `IT`. + +Requirements: +- OpenJDK 12 +- Some integration tests have additional requirements (e.g. external services). Ensure that these requirements are met as well. Check out the source code for further details. + +Command: +``` +mvn test -P integration-test +``` + +# Footnotes + +[1] https://bugs.openjdk.java.net/browse/JDK-8214098 diff --git a/src/main/java/at/gv/egiz/moazs/config/MarshallerConfig.java b/src/main/java/at/gv/egiz/moazs/config/MarshallerConfig.java index 38f4c1a..dfcb0e8 100644 --- a/src/main/java/at/gv/egiz/moazs/config/MarshallerConfig.java +++ b/src/main/java/at/gv/egiz/moazs/config/MarshallerConfig.java @@ -1,13 +1,8 @@ package at.gv.egiz.moazs.config; import at.gv.egiz.moazs.scheme.Marshaller; -import at.gv.egiz.moazs.scheme.MoaZSPrefixMapper; -import com.sun.xml.bind.marshaller.NamespacePrefixMapper; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.oxm.jaxb.Jaxb2Marshaller; - -import java.util.HashMap; @Configuration public class MarshallerConfig { diff --git a/src/test/java/at/gv/egiz/moazs/MoaSPSSSignatureVerifierTest.java b/src/test/java/at/gv/egiz/moazs/ITMoaSPSSSignatureVerifierTest.java index 7d3e9d1..2c6b978 100644 --- a/src/test/java/at/gv/egiz/moazs/MoaSPSSSignatureVerifierTest.java +++ b/src/test/java/at/gv/egiz/moazs/ITMoaSPSSSignatureVerifierTest.java @@ -18,9 +18,9 @@ import java.nio.file.Files; //Note: Certificate that signed these delivery responses expires in 2023-09-27. @RunWith(SpringRunner.class) @SpringBootTest - public class MoaSPSSSignatureVerifierTest { + public class ITMoaSPSSSignatureVerifierTest { - private final String resourcesPath = "src/test/resources/at/gv/egiz/moazs/MoaSPSSSignatureVerifierTest/"; + private final String resourcesPath = "src/test/resources/at/gv/egiz/moazs/ITMoaSPSSSignatureVerifierTest/"; @TestConfiguration public class Config{ diff --git a/src/test/java/at/gv/egiz/moazs/MsgClientTest.java b/src/test/java/at/gv/egiz/moazs/ITMsgClientTest.java index 485d01c..10c2859 100644 --- a/src/test/java/at/gv/egiz/moazs/MsgClientTest.java +++ b/src/test/java/at/gv/egiz/moazs/ITMsgClientTest.java @@ -7,11 +7,17 @@ import at.gv.zustellung.app2mzs.xsd.ClientType; import at.gv.zustellung.app2mzs.xsd.KeyStoreType; import at.gv.zustellung.msg.xsd.DeliveryRequestType; import at.gv.zustellung.msg.xsd.ObjectFactory; +import org.assertj.core.api.Assertions; +import org.junit.Test; +import org.junit.runner.RunWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; import javax.xml.bind.JAXBElement; +import javax.xml.ws.soap.SOAPFaultException; import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.IOException; @@ -20,14 +26,15 @@ import java.math.BigInteger; import static at.gv.zustellung.app2mzs.xsd.ClientType.clientTypeBuilder; import static at.gv.zustellung.app2mzs.xsd.KeyStoreType.keyStoreTypeBuilder; import static at.gv.zustellung.app2mzs.xsd.SSLType.SSLTypeBuilder; +import static org.assertj.core.api.Assertions.assertThat; -// @RunWith(SpringRunner.class) -// @SpringBootTest +@RunWith(SpringRunner.class) +@SpringBootTest +public class ITMsgClientTest { -public class MsgClientTest { - - private final static Logger log = LoggerFactory.getLogger(MsgClientTest.class); - private final String basePath = "src/test/resources/at/gv/egiz/moazs/MsgClientTest/"; + private final static Logger log = LoggerFactory.getLogger(ITMsgClientTest.class); + private static final Object VALID_MZS_REQUEST_ID = "valid-delivery-request-id" ; + private final String basePath = "src/test/resources/at/gv/egiz/moazs/ITMsgClientTest/"; @Autowired private Marshaller msgMarshaller; @@ -41,27 +48,24 @@ public class MsgClientTest { private static final ObjectFactory OF = new ObjectFactory(); - // tmp disabled. todo: set up integration tests - // Requirements: // - run zusemsg service under httpServiceURL - // @Test + @Test public void sendValidMessage() throws IOException { var request = loadFromFile("validDeliveryRequest.xml"); var httpServiceURL = "http://localhost:8081/services/DeliveryRequest"; var clientParams = clientTypeBuilder() .withURL(httpServiceURL) + .withConnectionTimeout(BigInteger.ZERO) + .withReceiveTimeout(BigInteger.ZERO) .build(); var client = factory.create(clientParams); - try{ - var status = client.delivery(request); - log.info("status: " + msgMarshaller.marshallXml(OF.createDeliveryResponse(status))); - } catch (Exception ex) { - System.out.println(ex.getMessage()); - } + var status = client.delivery(request); + assertThat(status.getPartialSuccess().getAppDeliveryID()).isEqualTo(VALID_MZS_REQUEST_ID); + } // Requirements: @@ -69,7 +73,7 @@ public class MsgClientTest { // - server trusts client cert (by trusting CA bundle in ssl/trusted-cas-bundle.pem) // - server uses the server certificate in ssl/server/server.localhost.*.pem // - server sends certificate chain ssl/server/ca-chain.cert.pem - //@Test + @Test public void sendOverSSLWithClientAuthentication() throws IOException { var request = loadFromFile("validDeliveryRequest.xml"); @@ -79,7 +83,7 @@ public class MsgClientTest { var client = factory.create(clientParams); var status = client.delivery(request); - log.info("status: " + msgMarshaller.marshallXml(OF.createDeliveryRequestStatus(status))); + assertThat(status.getPartialSuccess().getAppDeliveryID()).isEqualTo(VALID_MZS_REQUEST_ID); } // Requirements: @@ -87,7 +91,7 @@ public class MsgClientTest { // - server trusts client cert (by trusting CA bundle in ssl/trusted-cas-bundle.pem) // - server uses the server certificate in ssl/server/server.localhost.*.pem // - server sends certificate chain ssl/server/ca-chain.cert.pem - //@Test + @Test public void sendOverSSLWithClientAuthTrustAll() throws IOException { var request = loadFromFile("validDeliveryRequest.xml"); @@ -97,7 +101,7 @@ public class MsgClientTest { var client = factory.create(clientParams); var status = client.delivery(request); - log.info("status: " + msgMarshaller.marshallXml(OF.createDeliveryRequestStatus(status))); + assertThat(status.getPartialSuccess().getAppDeliveryID()).isEqualTo(VALID_MZS_REQUEST_ID); } // Requirements: @@ -105,7 +109,7 @@ public class MsgClientTest { // - server trusts client cert (by trusting CA bundle in ssl/trusted-cas-bundle.pem) // - server uses the server certificate in ssl/server/server.localhost.*.pem // - server sends certificate chain ssl/server/ca-chain.cert.pem - //@Test + @Test public void sendOverSSLWithClientAuthLaxHostnameVerification() throws IOException { var request = loadFromFile("validDeliveryRequest.xml"); @@ -115,7 +119,7 @@ public class MsgClientTest { var client = factory.create(clientParams); var status = client.delivery(request); - log.info("status: " + msgMarshaller.marshallXml(OF.createDeliveryRequestStatus(status))); + assertThat(status.getPartialSuccess().getAppDeliveryID()).isEqualTo(VALID_MZS_REQUEST_ID); } //Requirements: @@ -123,7 +127,7 @@ public class MsgClientTest { // - server trusts client cert (by trusting CA bundle in ssl/trusted-cas-bundle.pem) // - server uses the server certificate in ssl/server/server.localhost.*.pem // - server sends certificate chain ssl/server/ca-chain.cert.pem - //@Test(expected=SOAPFaultException.class) + @Test(expected=SOAPFaultException.class) public void rejectBecauseHostNameVerificationFails() throws IOException { var request = loadFromFile("validDeliveryRequest.xml"); @@ -132,8 +136,7 @@ public class MsgClientTest { var clientParams = generateSSLClientParams(httpsServiceURL, false, false); var client = factory.create(clientParams); - var status = client.delivery(request); - log.info("status: " + msgMarshaller.marshallXml(OF.createDeliveryRequestStatus(status))); + client.delivery(request); } private ClientType generateSSLClientParams(String httpsServiceURL, boolean trustAll, boolean laxHostNameVerification) { diff --git a/src/test/java/at/gv/egiz/moazs/MzsServiceTest.java b/src/test/java/at/gv/egiz/moazs/ITMzsServiceTest.java index 579051d..4f24518 100644 --- a/src/test/java/at/gv/egiz/moazs/MzsServiceTest.java +++ b/src/test/java/at/gv/egiz/moazs/ITMzsServiceTest.java @@ -33,13 +33,13 @@ import static org.junit.Assert.assertEquals; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) -public class MzsServiceTest { +public class ITMzsServiceTest { private final String serviceUri = "http://localhost:8080/services/DeliveryRequest"; - private final String basePath = "src/test/resources/at/gv/egiz/moazs/MzsServiceTest/"; + private final String basePath = "src/test/resources/at/gv/egiz/moazs/ITMzsServiceTest/"; - private final static Logger logger = LoggerFactory.getLogger(MzsServiceTest.class); + private final static Logger logger = LoggerFactory.getLogger(ITMzsServiceTest.class); @TestConfiguration public static class TestConfig { diff --git a/src/test/resources/at/gv/egiz/moazs/MoaSPSSSignatureVerifierTest/invalid-signed-delivery-response.xml b/src/test/resources/at/gv/egiz/moazs/ITMoaSPSSSignatureVerifierTest/invalid-signed-delivery-response.xml index b850145..b850145 100644 --- a/src/test/resources/at/gv/egiz/moazs/MoaSPSSSignatureVerifierTest/invalid-signed-delivery-response.xml +++ b/src/test/resources/at/gv/egiz/moazs/ITMoaSPSSSignatureVerifierTest/invalid-signed-delivery-response.xml diff --git a/src/test/resources/at/gv/egiz/moazs/MoaSPSSSignatureVerifierTest/valid-signed-delivery-response.xml b/src/test/resources/at/gv/egiz/moazs/ITMoaSPSSSignatureVerifierTest/valid-signed-delivery-response.xml index 59a90cf..59a90cf 100644 --- a/src/test/resources/at/gv/egiz/moazs/MoaSPSSSignatureVerifierTest/valid-signed-delivery-response.xml +++ b/src/test/resources/at/gv/egiz/moazs/ITMoaSPSSSignatureVerifierTest/valid-signed-delivery-response.xml diff --git a/src/test/resources/at/gv/egiz/moazs/MsgClientTest/validDeliveryRequest.xml b/src/test/resources/at/gv/egiz/moazs/ITMsgClientTest/validDeliveryRequest.xml index f1879eb..f1879eb 100644 --- a/src/test/resources/at/gv/egiz/moazs/MsgClientTest/validDeliveryRequest.xml +++ b/src/test/resources/at/gv/egiz/moazs/ITMsgClientTest/validDeliveryRequest.xml diff --git a/src/test/resources/at/gv/egiz/moazs/MzsServiceTest/formallyIncorrectDeliveryRequest.soap b/src/test/resources/at/gv/egiz/moazs/ITMzsServiceTest/formallyIncorrectDeliveryRequest.soap index 0570005..0570005 100644 --- a/src/test/resources/at/gv/egiz/moazs/MzsServiceTest/formallyIncorrectDeliveryRequest.soap +++ b/src/test/resources/at/gv/egiz/moazs/ITMzsServiceTest/formallyIncorrectDeliveryRequest.soap diff --git a/src/test/resources/at/gv/egiz/moazs/MzsServiceTest/missingAppDeliveryId.soap b/src/test/resources/at/gv/egiz/moazs/ITMzsServiceTest/missingAppDeliveryId.soap index e481caa..e481caa 100644 --- a/src/test/resources/at/gv/egiz/moazs/MzsServiceTest/missingAppDeliveryId.soap +++ b/src/test/resources/at/gv/egiz/moazs/ITMzsServiceTest/missingAppDeliveryId.soap diff --git a/src/test/resources/at/gv/egiz/moazs/MzsServiceTest/missingMetaData.soap b/src/test/resources/at/gv/egiz/moazs/ITMzsServiceTest/missingMetaData.soap index cf55d6d..cf55d6d 100644 --- a/src/test/resources/at/gv/egiz/moazs/MzsServiceTest/missingMetaData.soap +++ b/src/test/resources/at/gv/egiz/moazs/ITMzsServiceTest/missingMetaData.soap diff --git a/src/test/resources/at/gv/egiz/moazs/MzsServiceTest/missingSender.soap b/src/test/resources/at/gv/egiz/moazs/ITMzsServiceTest/missingSender.soap index 62cda34..62cda34 100644 --- a/src/test/resources/at/gv/egiz/moazs/MzsServiceTest/missingSender.soap +++ b/src/test/resources/at/gv/egiz/moazs/ITMzsServiceTest/missingSender.soap diff --git a/src/test/resources/at/gv/egiz/moazs/MzsServiceTest/profileAndCorporateBody.soap b/src/test/resources/at/gv/egiz/moazs/ITMzsServiceTest/profileAndCorporateBody.soap index 3e52062..3e52062 100644 --- a/src/test/resources/at/gv/egiz/moazs/MzsServiceTest/profileAndCorporateBody.soap +++ b/src/test/resources/at/gv/egiz/moazs/ITMzsServiceTest/profileAndCorporateBody.soap diff --git a/src/test/resources/at/gv/egiz/moazs/MzsServiceTest/validDeliveryRequest.soap b/src/test/resources/at/gv/egiz/moazs/ITMzsServiceTest/validDeliveryRequest.soap index 519749c..519749c 100644 --- a/src/test/resources/at/gv/egiz/moazs/MzsServiceTest/validDeliveryRequest.soap +++ b/src/test/resources/at/gv/egiz/moazs/ITMzsServiceTest/validDeliveryRequest.soap |