From 649b3cd196987eac24a519d987676a0ba09e2432 Mon Sep 17 00:00:00 2001 From: Alexander Marsalek Date: Fri, 16 Apr 2021 21:31:36 +0200 Subject: added test & error message --- .../pdfas/cli/test/SignaturBlockParameterTest.java | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'pdf-as-cli/src/test/java/at/gv') diff --git a/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SignaturBlockParameterTest.java b/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SignaturBlockParameterTest.java index 9c53c80e..7b29b535 100644 --- a/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SignaturBlockParameterTest.java +++ b/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SignaturBlockParameterTest.java @@ -45,6 +45,7 @@ import org.junit.Test; import javax.activation.DataSource; import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.HashMap; @@ -67,6 +68,38 @@ public class SignaturBlockParameterTest { return absolutePath; } + @Test(expected = PdfAsException.class) + public void invalid() throws IOException, PdfAsException, PDFASError { + + PdfAs pdfas = PdfAsFactory.createPdfAs(new File(getPath("pdfas-config"))); + Configuration config = pdfas.getConfiguration(); + + byte[] input = IOUtils.toByteArray(new FileInputStream(getPath("simple_rotated_0.pdf"))); + + IPlainSigner signer = new PAdESSignerKeystore(getPath("test.p12"), KS_ALIAS, KS_PASS, KS_KEY_PASS, KS_TYPE); + + String profile = "SIGNATURBLOCK_DE_NOTE_DYNAMIC"; + System.out.println("Testing " + profile); + + DataSource source = new ByteArrayDataSource(input); + String outFile = getPath("out") + "/" + profile + ".pdf"; + FileOutputStream fos = new FileOutputStream(outFile); + SignParameter signParameter = PdfAsFactory.createSignParameter( + config, source, fos); + + Map map = new HashMap<>(); + map.put("subject", "TEST123"); + map.put("WAY_TOOOOOOOOOOOOOOOOOOOOO_LONG_KEY", "bar"); + signParameter.setDynamicSignatureBlockArguments(map); +// signParameter.setPlainSigner(signer); +// signParameter.setSignatureProfileId(profile); +// +// SignResult result = pdfas.sign(signParameter); + + fos.close(); + + } + @Test public void test() throws IOException, PDFASError, PdfAsException { -- cgit v1.2.3