aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/at/gv/egiz/moazs
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-05-21 13:47:34 +0200
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-05-21 13:47:34 +0200
commit59a13bea5783aa666bcbcec793df19f129965ff3 (patch)
tree15049405249a0940484e3f177e5c5b51cb5458e9 /src/test/java/at/gv/egiz/moazs
parent96f82d09c22853ce3b37db0983ce6ccc34c2587f (diff)
downloadmoa-zs-59a13bea5783aa666bcbcec793df19f129965ff3.tar.gz
moa-zs-59a13bea5783aa666bcbcec793df19f129965ff3.tar.bz2
moa-zs-59a13bea5783aa666bcbcec793df19f129965ff3.zip
WIP: SSL Client Auth
- Refactor MsgClient: Not a Singleton anymore. Use MsgClientFactory to make a client. Make request and config private fields. - Add configuration parameters to application.yaml. - Init SSL client auth testcase, but dont include in testsuite because it aint working yet.
Diffstat (limited to 'src/test/java/at/gv/egiz/moazs')
-rw-r--r--src/test/java/at/gv/egiz/moazs/MsgClientTest.java31
-rw-r--r--src/test/java/at/gv/egiz/moazs/SameThreadDeliveryPipelineTest.java9
2 files changed, 31 insertions, 9 deletions
diff --git a/src/test/java/at/gv/egiz/moazs/MsgClientTest.java b/src/test/java/at/gv/egiz/moazs/MsgClientTest.java
index 6dc94e0..5b6419f 100644
--- a/src/test/java/at/gv/egiz/moazs/MsgClientTest.java
+++ b/src/test/java/at/gv/egiz/moazs/MsgClientTest.java
@@ -1,6 +1,7 @@
package at.gv.egiz.moazs;
import at.gv.egiz.moazs.msg.MsgClient;
+import at.gv.egiz.moazs.msg.MsgClientFactory;
import at.gv.egiz.moazs.scheme.Marshaller;
import at.gv.zustellung.app2mzs.xsd.ConfigType;
import at.gv.zustellung.msg.xsd.DeliveryRequestType;
@@ -28,25 +29,41 @@ public class MsgClientTest {
private final static Logger logger = LoggerFactory.getLogger(MsgClient.class);
- private final String serviceUri = "http://localhost:8081/services/DeliveryRequest";
+ private String httpServiceUri = "http://localhost:8081/services/DeliveryRequest";
+ private String sslServiceUri = "https://localhost/zusemsg/services/DeliveryRequest";
+
private final String basePath = "src/test/resources/at/gv/egiz/moazs/MsgClientTest/";
+ private MsgClientFactory factory = new MsgClientFactory();
+
@Autowired
private Marshaller msgMarshaller;
private static final ObjectFactory OF = new ObjectFactory();
- // this test requires that a zusemsg service runs under serviceUri!
+ // this test requires that a zusemsg service runs under httpServiceUri!
@Test
public void sendValidMessage() throws IOException {
var request = loadFromFile("validDeliveryRequest.xml");
- var config = generateConfig();
- var client = new MsgClient();
+ var config = generateConfig(httpServiceUri);
+ var client = factory.create(request, config);
+
+ var status = client.send();
+
+ logger.info("status: " + msgMarshaller.marshallXml(OF.createDeliveryRequestStatus(status)));
+ }
+
+ //@Test
+ public void sendValidMessageToSSL() throws IOException {
+
+ var request = loadFromFile("validDeliveryRequest.xml");
+ var config = generateConfig(sslServiceUri);
+ var client = factory.create(request, config);
- var status = client.send(request, config);
+ var status = client.send();
logger.info("status: " + msgMarshaller.marshallXml(OF.createDeliveryRequestStatus(status)));
}
@@ -58,10 +75,10 @@ public class MsgClientTest {
}
}
- private ConfigType generateConfig() {
+ private ConfigType generateConfig(String zuseUrl) {
var server = serverTypeBuilder()
- .withZUSEUrlID(serviceUri)
+ .withZUSEUrlID(zuseUrl)
.build();
return configTypeBuilder()
diff --git a/src/test/java/at/gv/egiz/moazs/SameThreadDeliveryPipelineTest.java b/src/test/java/at/gv/egiz/moazs/SameThreadDeliveryPipelineTest.java
index 9ee3ceb..5e4b9b0 100644
--- a/src/test/java/at/gv/egiz/moazs/SameThreadDeliveryPipelineTest.java
+++ b/src/test/java/at/gv/egiz/moazs/SameThreadDeliveryPipelineTest.java
@@ -1,6 +1,7 @@
package at.gv.egiz.moazs;
import at.gv.egiz.moazs.msg.MsgClient;
+import at.gv.egiz.moazs.msg.MsgClientFactory;
import at.gv.egiz.moazs.pipeline.DeliveryPipeline;
import at.gv.egiz.moazs.pipeline.SameThreadDeliveryPipeline;
import at.gv.egiz.moazs.repository.DeliveryRepository;
@@ -46,6 +47,9 @@ public class SameThreadDeliveryPipelineTest {
private TnvzClient tnvzClient;
@Mock
+ private MsgClientFactory msgClientFactory;
+
+ @Mock
private MsgClient msgClient;
@Mock
@@ -56,7 +60,7 @@ public class SameThreadDeliveryPipelineTest {
@Before
public void setup() {
- pipeline = new SameThreadDeliveryPipeline(repository, tnvzClient, converter, msgClient);
+ pipeline = new SameThreadDeliveryPipeline(repository, tnvzClient, converter, msgClientFactory);
}
@Test
@@ -129,7 +133,8 @@ public class SameThreadDeliveryPipelineTest {
when(tnvzClient.queryPerson(any(), any())).thenReturn(setupTnvzSuccess(acceptedTypes));
when(converter.convert(eq(mzsRequest) )).thenReturn(msgRequest);
when(converter.convert(eq(mzsRequest), any())).thenReturn(msgRequest);
- when(msgClient.send(msgRequest, mzsRequest.getConfig())).thenReturn(status);
+ when(msgClientFactory.create(msgRequest, mzsRequest.getConfig())).thenReturn(msgClient);
+ when(msgClient.send()).thenReturn(status);
return status;