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 +++++++++ .../valid-signed-shuffled-soaped-notification.xml | 94 ++++++++++++++++++++++ .../valid-signed-soaped-notification.xml | 94 ++++++++++++++++++++++ 3 files changed, 226 insertions(+) create mode 100644 src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-shuffled-soaped-notification.xml create mode 100644 src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-soaped-notification.xml (limited to 'src') 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); + } } diff --git a/src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-shuffled-soaped-notification.xml b/src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-shuffled-soaped-notification.xml new file mode 100644 index 0000000..1262c3e --- /dev/null +++ b/src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-shuffled-soaped-notification.xml @@ -0,0 +1,94 @@ + + + + + https://localhost/example-delivery-system + 12345 + 678910 + + + Musterbehörde + + + AT + 1234 + Graz + + Musterstraße + 1 + b2 + + + + max.mustermann@musterbehoerde.gv.at + + + + + + Maxi + Mustermann1 + + 1984-01-24-02:00 + + + 1010 + Wien + + Muststrasse + 10 + + + + + + electronic + 2002-05-30T09:00:00 + + + 2002-05-30T09:00:00 + + + + 1234 + + 1234 + + + + 100 + + + + kh0DDpXv4n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v6zT8gvKqxGFg96UamECep4swPaSZrA8AOER5WAtyGDzKI + Tz+a5zfFaTXDoba7f98PCWR96yKiFjVOhzp38WVz4VJgz+b8ZSY7Xsv5Kn7DXjOL + STX4MevFLki3rFPup3+4vGToaMBW3PEj67HXBdqR855Le6+E6rVxORqsXqlVwhsI + 6nuS0CO2LWYmBNR1IB0mXteeYH/HfxvuZc+7yDjdPQIDAQABo4IBhDCCAYAwDgYD + VR0PAQH/BAQDAgbAMAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFEmcH6VY4BG1EAGB + TLoNR9vH/g6yMFAGA1UdHwRJMEcwRaBDoEGGP2h0dHA6Ly9jYS5pYWlrLnR1Z3Jh + ei5hdC9jYXBzby9jcmxzL0lBSUtUZXN0X0ludGVybWVkaWF0ZUNBLmNybDCBqgYI + KwYBBQUHAQEEgZ0wgZowSgYIKwYBBQUHMAGGPmh0dHA6Ly9jYS5pYWlrLnR1Z3Jh + ei5hdC9jYXBzby9PQ1NQP2NhPUlBSUtUZXN0X0ludGVybWVkaWF0ZUNBMEwGCCsG + AQUFBzAChkBodHRwOi8vY2EuaWFpay50dWdyYXouYXQvY2Fwc28vY2VydHMvSUFJ + S1Rlc3RfSW50ZXJtZWRpYXRlQ0EuY2VyMCEGA1UdEQQaMBiBFnRob21hcy5sZW56 + QGVnaXouZ3YuYXQwHwYDVR0jBBgwFoAUaKJeEdreL4BrRES/jfplNoEkp28wDQYJ + KoZIhvcNAQEFBQADgYEAlFGjUxXLs7SAT8NtXSrv2WrjlklaRnHTFHLQwyVo8JWb + gvRkHHDUv2o8ofXUY2R2WJ38dxeDoccgbXrJb/Qhi8IY7YhCwv/TuIZDisyAqo8W + ORKSip/6HWlGCSR/Vgoet1GtCmF0FoUxFUIGSAuQ2yyt4fIzt5GJrU1X5ujjI1w= + + diff --git a/src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-soaped-notification.xml b/src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-soaped-notification.xml new file mode 100644 index 0000000..54e9918 --- /dev/null +++ b/src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-soaped-notification.xml @@ -0,0 +1,94 @@ + + + + + https://localhost/example-delivery-system + 12345 + 678910 + + + Musterbehörde + + + AT + 1234 + Graz + + Musterstraße + 1 + b2 + + + + max.mustermann@musterbehoerde.gv.at + + + + + + Maxi + Mustermann1 + + 1984-01-24-02:00 + + + 1010 + Wien + + Muststrasse + 10 + + + + + + electronic + 2002-05-30T09:00:00 + + + 2002-05-30T09:00:00 + + + + 1234 + + 1234 + + + + 100 + + + + kh0DDpXv4nh2gqK3lVle+3O/Oz4nSB2exjUHfalqyG0=OV3sSaUEkAh2Kls7g0v2EHCDnpsaN3BDU5dgwKhw8inkeADfhAgNbJyeq0Y/Hwl6 + JmfJOD1aF7qmxICI5/ZfTE9h+LIebcMZ30qkZ6YnzyxoeBa+hnTmvPKvSpQtGUYL + Xa1gakY5LN3l/w1AokkPN9j7WCGjF8ZoDZLP2M0KXcjhyPuwQ3XzXD8Cqnl42jfI + oL3b6P9Wd/MYugFTho9cY1awpPqIlXG4kob9zjDfFyTyEqa5A6LgcjdU5e3viSoh + N7hLuSYH6BfaLxuolwF3Bszj1GP1vGSWNQBPSHVu5crnfPb5KpDmZE4nzw3wp4zo + hovAEEVexRtqYZEX95TTiA==MIIEqzCCBBSgAwIBAgIHANux81oNezANBgkqhkiG9w0BAQUFADBAMSIwIAYDVQQD + ExlJQUlLIFRlc3QgSW50ZXJtZWRpYXRlIENBMQ0wCwYDVQQKEwRJQUlLMQswCQYD + VQQGEwJBVDAeFw0xMzA5MjcwNTMzMzdaFw0yMzA5MjcwNTMzMzdaMIHkMQswCQYD + VQQGEwJBVDENMAsGA1UEBxMER3JhejEmMCQGA1UEChMdR3JheiBVbml2ZXJzaXR5 + IG9mIFRlY2hub2xvZ3kxSDBGBgNVBAsTP0luc3RpdHV0ZSBmb3IgQXBwbGllZCBJ + bmZvcm1h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