From a867ca9950c6bf670407b366ee2980eb747358f2 Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Wed, 19 Jun 2019 11:07:11 +0200 Subject: Add Testcase: Reject Invalid Delivery Response Signature --- .../egiz/moazs/MoaSPSSSignatureVerifierTest.java | 13 +++++++--- .../invalid-signed-delivery-response.xml | 30 ++++++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 src/test/resources/at/gv/egiz/moazs/MoaSPSSSignatureVerifierTest/invalid-signed-delivery-response.xml (limited to 'src') diff --git a/src/test/java/at/gv/egiz/moazs/MoaSPSSSignatureVerifierTest.java b/src/test/java/at/gv/egiz/moazs/MoaSPSSSignatureVerifierTest.java index afa817f..7d3e9d1 100644 --- a/src/test/java/at/gv/egiz/moazs/MoaSPSSSignatureVerifierTest.java +++ b/src/test/java/at/gv/egiz/moazs/MoaSPSSSignatureVerifierTest.java @@ -5,8 +5,6 @@ import at.gv.egiz.moazs.verify.MoaSPSSSignatureVerifier; import at.gv.egiz.moazs.verify.SignatureVerifier; 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; @@ -17,6 +15,7 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; +//Note: Certificate that signed these delivery responses expires in 2023-09-27. @RunWith(SpringRunner.class) @SpringBootTest public class MoaSPSSSignatureVerifierTest { @@ -36,7 +35,6 @@ import java.nio.file.Files; @Autowired private SignatureVerifier verifier; - //TODO make sure that testcase does not depend on runtime because it's certificate expires in 2023-09-27. @Test public void acceptValidSignedDeliveryResponse() throws IOException { @@ -46,4 +44,13 @@ import java.nio.file.Files; verifier.verify(signature); } + @Test(expected = MoaZSException.class) + public void rejectInvalidSignedDeliveryResponse() throws IOException { + + var path = resourcesPath + "invalid-signed-delivery-response.xml"; + var signature = Files.readAllBytes(new File(path).toPath()); + + verifier.verify(signature); + } + } diff --git a/src/test/resources/at/gv/egiz/moazs/MoaSPSSSignatureVerifierTest/invalid-signed-delivery-response.xml b/src/test/resources/at/gv/egiz/moazs/MoaSPSSSignatureVerifierTest/invalid-signed-delivery-response.xml new file mode 100644 index 0000000..b850145 --- /dev/null +++ b/src/test/resources/at/gv/egiz/moazs/MoaSPSSSignatureVerifierTest/invalid-signed-delivery-response.xml @@ -0,0 +1,30 @@ +https://testzustellsystem.egiz.gv.atmanipulated-delivery-idmanipulated-delivery-request-id00000ejvUI0yh/IIyauFe8x5ZonD/i5oznl8vFyS3oLNivzA=hmVZrLkMDbXaRLYQKOaV3OtK13TQgMu3csKyw9M4zWqNyva1yxnYkzoX3dKDOdc9 +O56yQJsjoA3Cuw7pXlGO7jSfVM77dTXbWSDaF95O9Vdsrmr7R6Uki0jA9SmgQLXg +hZAUG8JpsHcBn8M0L2BXADKjSn0LuMDL2L7dmU3EM7eRy+OvFwDrXDw1fhjQO6L2 +KoflAWLgUerDhJSpzr0+YfmkrjzitLUA7oIg8ieOnfGyql31ECmDJEqgnL78hyPZ +KaNZImDf3EWFs8je6mt+os1TwsyXYwz+GGbjoDR8lGTS9xVqnXdrgP8Jyv6p9FEu +0IYgSY2FlbI3skPZC8ZVXg==MIIEqzCCBBSgAwIBAgIHANux81oNezANBgkqhkiG9w0BAQUFADBAMSIwIAYDVQQD +ExlJQUlLIFRlc3QgSW50ZXJtZWRpYXRlIENBMQ0wCwYDVQQKEwRJQUlLMQswCQYD +VQQGEwJBVDAeFw0xMzA5MjcwNTMzMzdaFw0yMzA5MjcwNTMzMzdaMIHkMQswCQYD +VQQGEwJBVDENMAsGA1UEBxMER3JhejEmMCQGA1UEChMdR3JheiBVbml2ZXJzaXR5 +IG9mIFRlY2hub2xvZ3kxSDBGBgNVBAsTP0luc3RpdHV0ZSBmb3IgQXBwbGllZCBJ +bmZvcm1hdGlvbiBQcm9jZXNzaW5nIGFuZCBDb21tdW5pY2F0aW9uczEUMBIGA1U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