aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/at/gv/egiz/moazs
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-08-26 13:30:53 +0200
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-08-26 13:30:53 +0200
commit34adf17296b8f2252eb9b3274c62f40a9d18ae81 (patch)
treeb2453f535d759d6ce275668be0aba0812335801c /src/test/java/at/gv/egiz/moazs
parent9b68da7d6873ec390a825f6c6663d81b71534e0d (diff)
downloadmoa-zs-34adf17296b8f2252eb9b3274c62f40a9d18ae81.tar.gz
moa-zs-34adf17296b8f2252eb9b3274c62f40a9d18ae81.tar.bz2
moa-zs-34adf17296b8f2252eb9b3274c62f40a9d18ae81.zip
Fix: Change Injection of signatureVerifier Bean into TestSuite
- Problem: @TestConfiguration did not override config/MoaSigConfig. - Therefore test uses bean that is configured via application.yaml. - Solution: Replace @TestConfiguration with bean that was created and configured directly in testcase.
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);
}
}