package at.gv.egiz.moazs; import at.gv.egiz.eid.authhandler.modules.sigverify.moasig.api.ISignatureVerificationService; import at.gv.egiz.moazs.backend.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 ITSignatureVerifierTest { private final String resourcesPath = "src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/"; @TestConfiguration public class Config{ @Bean public SignatureVerifier verifier(@Autowired ISignatureVerificationService service){ return new SignatureVerifier(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.accept(signature); } @Test public void acceptValidDeliveryNotification() throws IOException { var path = resourcesPath + "valid-signed-notification.xml"; var signature = Files.readAllBytes(new File(path).toPath()); verifier.accept(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.accept(signature); } }