package at.gv.egiz.moazs; import at.gv.egiz.eid.authhandler.modules.sigverify.moasig.api.ISignatureVerificationService; 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.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 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 ITMoaSPSSSignatureVerifierTest { private final String resourcesPath = "src/test/resources/at/gv/egiz/moazs/ITMoaSPSSSignatureVerifierTest/"; @TestConfiguration public class Config{ @Bean public SignatureVerifier verifier(@Autowired ISignatureVerificationService service){ return new MoaSPSSSignatureVerifier(service, "test-trust-profile", 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.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); } }