diff options
Diffstat (limited to 'src/test/java/at/gv/egiz/moazs')
-rw-r--r-- | src/test/java/at/gv/egiz/moazs/ITSignatureVerifierTest.java | 38 |
1 files changed, 38 insertions, 0 deletions
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 <dsig:Signature> 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); + } } |