From 631af9a4ab6b75e11ab369c3a7d9ab22e60341e8 Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Mon, 19 Aug 2019 15:47:42 +0200 Subject: Add Two "VerifySignature" Testcases --- .../at/gv/egiz/moazs/ITSignatureVerifierTest.java | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/test/java/at/gv/egiz') diff --git a/src/test/java/at/gv/egiz/moazs/ITSignatureVerifierTest.java b/src/test/java/at/gv/egiz/moazs/ITSignatureVerifierTest.java index 592b108..af958a5 100644 --- a/src/test/java/at/gv/egiz/moazs/ITSignatureVerifierTest.java +++ b/src/test/java/at/gv/egiz/moazs/ITSignatureVerifierTest.java @@ -2,14 +2,20 @@ 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.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.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.test.context.junit4.SpringRunner; +import org.xml.sax.SAXException; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.TransformerException; import java.io.File; import java.io.IOException; import java.nio.file.Files; @@ -19,6 +25,8 @@ import java.nio.file.Files; @SpringBootTest public class ITSignatureVerifierTest { + private static final Logger log = LoggerFactory.getLogger(ITSignatureVerifierTest.class); + private final String resourcesPath = "src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/"; @TestConfiguration @@ -62,4 +70,34 @@ import java.nio.file.Files; verifier.accept(signature); } + + @Test + public void acceptValidSoapedDeliveryNotification() throws IOException, ParserConfigurationException, SAXException, TransformerException { + + var path = resourcesPath + "valid-signed-soaped-notification.xml"; + var soapedNotificationBytes = Files.readAllBytes(new File(path).toPath()); + + var soapUtils = new SOAPUtils(); + var soapedNotification = soapUtils.toDOM(soapedNotificationBytes); + var deliveryNotificationNode = soapUtils.getChildElementOfSoapBody(soapedNotification); + var notificationBytes = soapUtils.toBytes(deliveryNotificationNode); + + verifier.accept(notificationBytes); + } + + //shuffled means that the was moved from it's original + //place to a different place. + @Test + public void acceptValidShuffledSoapedDeliveryNotification() throws IOException, ParserConfigurationException, SAXException, TransformerException { + + var path = resourcesPath + "valid-signed-shuffled-soaped-notification.xml"; + var soapedNotificationBytes = Files.readAllBytes(new File(path).toPath()); + + var soapUtils = new SOAPUtils(); + var soapedNotification = soapUtils.toDOM(soapedNotificationBytes); + var deliveryNotificationNode = soapUtils.getChildElementOfSoapBody(soapedNotification); + var notificationBytes = soapUtils.toBytes(deliveryNotificationNode); + + verifier.accept(notificationBytes); + } } -- cgit v1.2.3