Skip to content
Snippets Groups Projects
Commit 49b2044a authored by Jan Zickermann's avatar Jan Zickermann
Browse files

KOP-3126 Mock with xta-test-server keystore

parent 2adfa0d5
Branches
No related tags found
No related merge requests found
Pipeline #2286 failed
package de.ozgcloud.xta.client; package de.ozgcloud.xta.client;
import static com.github.tomakehurst.wiremock.client.WireMock.*; import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.*; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import java.io.File;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import com.github.tomakehurst.wiremock.WireMockServer; import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.client.WireMock;
import de.ozgcloud.xta.client.config.XtaClientConfig; import de.ozgcloud.xta.client.config.XtaClientConfig;
import de.ozgcloud.xta.client.core.WrappedXtaService; import de.ozgcloud.xta.client.core.WrappedXtaService;
...@@ -18,7 +22,6 @@ import de.ozgcloud.xta.client.factory.XtaMockServerResponseTestFactory; ...@@ -18,7 +22,6 @@ import de.ozgcloud.xta.client.factory.XtaMockServerResponseTestFactory;
import de.ozgcloud.xta.client.model.XtaIdentifier; import de.ozgcloud.xta.client.model.XtaIdentifier;
import lombok.SneakyThrows; import lombok.SneakyThrows;
class XtaSchemaValidationITCase { class XtaSchemaValidationITCase {
WrappedXtaService xtaService; WrappedXtaService xtaService;
...@@ -32,16 +35,37 @@ class XtaSchemaValidationITCase { ...@@ -32,16 +35,37 @@ class XtaSchemaValidationITCase {
@BeforeEach @BeforeEach
@SneakyThrows @SneakyThrows
void setup() { void setup() {
wireMockServer = new WireMockServer(options().port(8089)); wireMockServer = new WireMockServer(options()
.port(8088)
.httpsPort(8089)
.keystorePath("store/xta-test-server_keystore.p12")
.keystorePassword("password")
.keystoreType("PKCS12")
.caKeystorePath("store/xta-test_truststore.jks")
.caKeystorePassword("password")
.caKeystoreType("JKS")
);
wireMockServer.start(); wireMockServer.start();
WireMock.configureFor(8088);
xtaService = WrappedXtaServiceFactory.from(XtaClientConfig.builder() xtaService = WrappedXtaServiceFactory.from(XtaClientConfig.builder()
.schemaValidation(true) .schemaValidation(true)
.logSoapResponses(true) .logSoapResponses(true)
.logSoapRequests(true) .logSoapRequests(true)
.managementServiceUrl(XTA_MOCK_SERVER_URL + "managementPort.svc") .trustStore(XtaClientConfig.KeyStore.builder()
.sendServiceUrl(XTA_MOCK_SERVER_URL + "sendPort.svc") .content(FileUtils.readFileToByteArray(new File("src/test/resources/store/xta-test_truststore.jks")))
.msgBoxServiceUrl(XTA_MOCK_SERVER_URL + "msgBoxPort.svc") .password("password".toCharArray())
.type("JKS")
.build())
.clientCertKeystore(XtaClientConfig.KeyStore.builder()
.content(FileUtils.readFileToByteArray(new File("src/test/resources/store/xta-test-client-john-smith_keystore.p12")))
.password("password".toCharArray())
.type("PKCS12")
.build())
.managementServiceUrl(wireMockServer.baseUrl() + XTA_MOCK_SERVER_URL_PATH + "managementPort.svc")
.sendServiceUrl(wireMockServer.baseUrl() + XTA_MOCK_SERVER_URL_PATH + "sendPort.svc")
.msgBoxServiceUrl(wireMockServer.baseUrl() + XTA_MOCK_SERVER_URL_PATH + "msgBoxPort.svc")
.build()).create(); .build()).create();
} }
...@@ -54,7 +78,7 @@ class XtaSchemaValidationITCase { ...@@ -54,7 +78,7 @@ class XtaSchemaValidationITCase {
@Test @Test
@SneakyThrows @SneakyThrows
void shouldThrowUnmarshallExceptionOnBadResponse() { void shouldThrowUnmarshallExceptionOnBadResponse() {
stubFor(post(XTA_MOCK_SERVER_URL_PATH + "msgBoxPort.svc") wireMockServer.stubFor(post(XTA_MOCK_SERVER_URL_PATH + "msgBoxPort.svc")
.willReturn( .willReturn(
XtaMockServerResponseTestFactory.createGetMessageResponse( XtaMockServerResponseTestFactory.createGetMessageResponse(
"2f45a9e9-ed40-4e14-a082-de0d063e56e7_Geschaeftsgang.Geschaeftsgang.0201.zip"))); "2f45a9e9-ed40-4e14-a082-de0d063e56e7_Geschaeftsgang.Geschaeftsgang.0201.zip")));
......
...@@ -30,7 +30,7 @@ public class XtaMockServerResponseTestFactory { ...@@ -30,7 +30,7 @@ public class XtaMockServerResponseTestFactory {
); );
private static String generateMessageID(String xtaAttachmentFileName) { private static String generateMessageID(String xtaAttachmentFileName) {
return "urn:de:xta:messageid:dataport_xta_210:%s".formatted(UUID.fromString(xtaAttachmentFileName).toString()); return "urn:de:xta:messageid:dataport_xta_210:%s".formatted(UUID.nameUUIDFromBytes(xtaAttachmentFileName.getBytes()).toString());
} }
public static ResponseDefinitionBuilder createEmptyGetStatusListResponse() { public static ResponseDefinitionBuilder createEmptyGetStatusListResponse() {
......
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://www.osci.eu/ws/2008/05/transport/urn/messageTypes/MsgBoxFetchRequest
</a:Action>
<h:MsgBoxResponse MsgBoxRequestID="urn:de:xta:messageid:dataport_xta_210:0b2d4796-7f31-40c3-b834-7f7c66c042c9"
xmlns:h="http://www.osci.eu/ws/2008/05/transport" xmlns="http://www.osci.eu/ws/2008/05/transport"
>
<ItemsPending>0</ItemsPending>
</h:MsgBoxResponse>
<h:MessageMetaData xmlns:h="http://www.osci.eu/ws/2014/10/transport"
xmlns="http://www.osci.eu/ws/2014/10/transport">
<DeliveryAttributes>
<Origin>2025-04-02T10:49:30.324</Origin>
<Delivery>2025-04-02T10:49:32.893</Delivery>
</DeliveryAttributes>
<Originators>
<Author>
<Identifier type="xoev">afmsh:WebMethod_Online-Dienste</Identifier>
</Author>
</Originators>
<Destinations>
<Reader>
<Identifier type="xoev">afmsh:ozg-cloud-stage-Utopia</Identifier>
</Reader>
</Destinations>
<MsgIdentification>
<MessageID xmlns="http://www.w3.org/2005/08/addressing">
urn:de:xta:messageid:dataport_xta_210:0b2d4796-7f31-40c3-b834-7f7c66c042c9
</MessageID>
</MsgIdentification>
<Qualifier>
<Service>urn:xdomea:AFM</Service>
<BusinessScenario>
<Defined listURI="urn:de:dataport:codeliste:business.scenario" listVersionID="1">
<code xmlns="">AFM_DATA</code>
</Defined>
</BusinessScenario>
<MessageType listURI="urn:de:payloadSchema:elementName" listVersionID="1.0"
payloadSchema="http://www.xdomea.de/V2.0.1">
<code xmlns="">Geschaeftsgang.Geschaeftsgang.0201</code>
</MessageType>
</Qualifier>
<MsgSize>57890</MsgSize>
</h:MessageMetaData>
<a:RelatesTo>urn:uuid:0cb6ed55-8ac9-492a-9e76-6235e41729ea</a:RelatesTo>
</s:Header>
<s:Body>
<GenericContentContainer xmlns="http://xoev.de/transport/xta/211">
<ContentContainer>
<Message contentType="application/zip"
filename="1088975e-5892-474e-a0e9-d3cef8ee61db_Geschaeftsgang.Geschaeftsgang.0201.zip"
id="1088975e-5892-474e-a0e9-d3cef8ee61db" size="57890">
<xop:Include href="cid:http://tempuri.org/1/638791906226975019"
xmlns:xop="http://www.w3.org/2004/08/xop/include" />
</Message>
</ContentContainer>
</GenericContentContainer>
</s:Body>
</s:Envelope>
\ No newline at end of file
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment