aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/at/gv/egiz/moazs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/at/gv/egiz/moazs')
-rw-r--r--src/test/java/at/gv/egiz/moazs/ITSignatureVerifierTest.java28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/test/java/at/gv/egiz/moazs/ITSignatureVerifierTest.java b/src/test/java/at/gv/egiz/moazs/ITSignatureVerifierTest.java
index af958a5..1d6f7e0 100644
--- a/src/test/java/at/gv/egiz/moazs/ITSignatureVerifierTest.java
+++ b/src/test/java/at/gv/egiz/moazs/ITSignatureVerifierTest.java
@@ -3,6 +3,7 @@ package at.gv.egiz.moazs;
import at.gv.egiz.eid.authhandler.modules.sigverify.moasig.api.ISignatureVerificationService;
import at.gv.egiz.moazs.backend.SignatureVerifier;
import at.gv.egiz.moazs.scheme.SOAPUtils;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
@@ -11,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Primary;
import org.springframework.test.context.junit4.SpringRunner;
import org.xml.sax.SAXException;
@@ -19,6 +21,7 @@ import javax.xml.transform.TransformerException;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
+import java.util.function.Consumer;
//Note: Certificate that signed these delivery responses expires in 2023-09-27.
@RunWith(SpringRunner.class)
@@ -29,26 +32,23 @@ import java.nio.file.Files;
private final String resourcesPath = "src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/";
- @TestConfiguration
- public class Config{
+ private Consumer<byte[]> signatureVerifier;
- @Bean
- public SignatureVerifier verifier(@Autowired ISignatureVerificationService service){
- return new SignatureVerifier(service, "test-trust-profile", true);
- }
+ @Autowired
+ private ISignatureVerificationService service;
+ @Before
+ public void setup() {
+ this.signatureVerifier = new SignatureVerifier(service, "test-trustprofile", true);
}
- @Autowired
- private SignatureVerifier verifier;
-
@Test
public void acceptValidSignedDeliveryResponse() throws IOException {
var path = resourcesPath + "valid-signed-delivery-response.xml";
var signature = Files.readAllBytes(new File(path).toPath());
- verifier.accept(signature);
+ signatureVerifier.accept(signature);
}
@Test
@@ -57,7 +57,7 @@ import java.nio.file.Files;
var path = resourcesPath + "valid-signed-notification.xml";
var signature = Files.readAllBytes(new File(path).toPath());
- verifier.accept(signature);
+ signatureVerifier.accept(signature);
}
@@ -67,7 +67,7 @@ import java.nio.file.Files;
var path = resourcesPath + "invalid-signed-delivery-response.xml";
var signature = Files.readAllBytes(new File(path).toPath());
- verifier.accept(signature);
+ signatureVerifier.accept(signature);
}
@@ -82,7 +82,7 @@ import java.nio.file.Files;
var deliveryNotificationNode = soapUtils.getChildElementOfSoapBody(soapedNotification);
var notificationBytes = soapUtils.toBytes(deliveryNotificationNode);
- verifier.accept(notificationBytes);
+ signatureVerifier.accept(notificationBytes);
}
//shuffled means that the <dsig:Signature> was moved from it's original
@@ -98,6 +98,6 @@ import java.nio.file.Files;
var deliveryNotificationNode = soapUtils.getChildElementOfSoapBody(soapedNotification);
var notificationBytes = soapUtils.toBytes(deliveryNotificationNode);
- verifier.accept(notificationBytes);
+ signatureVerifier.accept(notificationBytes);
}
}