From f6d416f004ed294cff71e25358d7b37a9750a1b6 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Fri, 13 Jan 2023 14:02:43 +0100 Subject: fix(sigblock): invalid preview in case of sig-blocks with more than half page height Issue: #68 ## Info: This is only a work-around, because it looks like a general issue in methods to create visual signature tables. T --- .../test/mains/SignatureBlockParameterTest.java | 87 ---------------------- .../test/stamping/SignatureBlockParameterTest.java | 87 ++++++++++++++++++++++ 2 files changed, 87 insertions(+), 87 deletions(-) delete mode 100644 pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/mains/SignatureBlockParameterTest.java create mode 100644 pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/stamping/SignatureBlockParameterTest.java (limited to 'pdf-as-lib/src/test/java/at/gv/egiz/pdfas') diff --git a/pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/mains/SignatureBlockParameterTest.java b/pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/mains/SignatureBlockParameterTest.java deleted file mode 100644 index 23422e8e..00000000 --- a/pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/mains/SignatureBlockParameterTest.java +++ /dev/null @@ -1,87 +0,0 @@ -package at.gv.egiz.pdfas.lib.test.mains; - -import at.gv.egiz.pdfas.common.settings.DefaultSignatureProfileSettings; -import at.gv.egiz.pdfas.common.utils.CheckSignatureBlockParameters; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; -@RunWith(JUnit4.class) -public class SignatureBlockParameterTest { - - @Test - public void testKeyInvalid() { - assertFalse(checkValid( "aaaaaaaaaaaaaaaaaaaaa" , "^([A-za-z]){1,20}$")); - assertFalse(checkValid( "" , "^([A-za-z]){1,20}$")); - assertFalse(checkValid( "a9" , "^([A-za-z]){1,20}$")); - } - - @Test - public void testKeyValid() { - assertTrue(checkValid( "aaa" +"aa", "^([A-za-z]){1,20}$")); - assertTrue(checkValid( "aaa" , "^([A-za-z]){1,20}$")); - assertTrue(checkValid( "aaaaaaaaaaaaaaaaaaaa", "^([A-za-z]){1,20}$")); - assertTrue(checkValid( "AA", "^([A-za-z]){1,20}$")); - } - - @Test - public void testValueValid() { - assertTrue(checkValid( "aaa" +"aa", "^([\\p{Print}]){1,100}$")); - assertTrue(checkValid( "aaa" , "^([\\p{Print}]){1,100}$")); - assertTrue(checkValid( "a!\"$%&/()[]=?aa-_,;.:[]|{}" , "^([\\p{Print}]){1,100}$")); -// assertTrue(checkValid( "a!\"§$%&/()=?aa" , "^([\\p{Print}]){1,100}$")); - assertTrue(checkValid( "aa!%&/()=?a" , "^([\\p{Print}]){1,100}$")); - assertTrue(checkValid( "a{\"a!%&/()=?a" , "^([\\p{Print}]){1,100}$")); - assertTrue(checkValid( "BB" , "^([\\p{Print}]){1,100}$")); - assertTrue(checkValid( "BB " , "^([\\p{Print}]){1,100}$")); - } - - @Test - public void testValueValidWithDefaultRegex() { - assertTrue(checkValid( "aaa" +"aa", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - assertTrue(checkValid( "aaa" , DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - assertTrue(checkValid( "a!\"$%&/()[]=?aa-_,;.:[]|{}" , DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); -// assertTrue(checkValid( "a!\"§$%&/()=?aa" , DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - assertTrue(checkValid( "aa!%&/()=?a" , DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - assertTrue(checkValid( "a{\"a!%&/()=?a" , DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - assertTrue(checkValid( "BB" , DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - assertTrue(checkValid( "BB " , DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - assertTrue(checkValid("! €%&/()?`$\"§", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - assertTrue(checkValid("€", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - assertTrue(checkValid("$", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - assertTrue(checkValid("! €\"§$%&/()=?`", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - assertTrue(checkValid("#", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - assertTrue(checkValid("-_", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - assertTrue(checkValid("'", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - assertTrue(checkValid("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#-_ß?+#*", - DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - } - - @Test - public void testValueInvalid() { - assertFalse(checkValid((char) 13 +"aaa" +"aa", "^([\\p{Print}]){1,100}$")); - assertFalse(checkValid((char) 13 +"", "^([\\p{Print}]){1,100}$")); - assertFalse(checkValid( "aaa" +(char) 13, "^([\\p{Print}]){1,100}$")); - assertFalse(checkValid("", "^([\\p{Print}]){1,100}$")); - assertFalse(checkValid("a", "^([\\p{Print}]){2,100}$")); - assertFalse(checkValid("aaa"+(char) 13 +"aa", "^([\\p{Print}]){1,100}$")); - } - - @Test - public void testUmlauteValid() { - assertTrue(checkValid( "ä", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - assertTrue(checkValid( "ö", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - assertTrue(checkValid( "ü", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - assertTrue(checkValid( "Ä", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - assertTrue(checkValid( "Ö", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - assertTrue(checkValid( "Ü", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - assertTrue(checkValid( "ÄÖÜöäüjhsbdjej", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - assertTrue(checkValid( "aauacnhuisdc Ä Ü Ö aaxsa ö aÜaÖa", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - assertTrue(checkValid( "NMS Güssing", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); - } - - public boolean checkValid(String s, String regex) { - return CheckSignatureBlockParameters.isValid(s, regex); - } -} diff --git a/pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/stamping/SignatureBlockParameterTest.java b/pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/stamping/SignatureBlockParameterTest.java new file mode 100644 index 00000000..378cc19d --- /dev/null +++ b/pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/stamping/SignatureBlockParameterTest.java @@ -0,0 +1,87 @@ +package at.gv.egiz.pdfas.lib.test.stamping; + +import at.gv.egiz.pdfas.common.settings.DefaultSignatureProfileSettings; +import at.gv.egiz.pdfas.common.utils.CheckSignatureBlockParameters; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +@RunWith(JUnit4.class) +public class SignatureBlockParameterTest { + + @Test + public void testKeyInvalid() { + assertFalse(checkValid( "aaaaaaaaaaaaaaaaaaaaa" , "^([A-za-z]){1,20}$")); + assertFalse(checkValid( "" , "^([A-za-z]){1,20}$")); + assertFalse(checkValid( "a9" , "^([A-za-z]){1,20}$")); + } + + @Test + public void testKeyValid() { + assertTrue(checkValid( "aaa" +"aa", "^([A-za-z]){1,20}$")); + assertTrue(checkValid( "aaa" , "^([A-za-z]){1,20}$")); + assertTrue(checkValid( "aaaaaaaaaaaaaaaaaaaa", "^([A-za-z]){1,20}$")); + assertTrue(checkValid( "AA", "^([A-za-z]){1,20}$")); + } + + @Test + public void testValueValid() { + assertTrue(checkValid( "aaa" +"aa", "^([\\p{Print}]){1,100}$")); + assertTrue(checkValid( "aaa" , "^([\\p{Print}]){1,100}$")); + assertTrue(checkValid( "a!\"$%&/()[]=?aa-_,;.:[]|{}" , "^([\\p{Print}]){1,100}$")); +// assertTrue(checkValid( "a!\"§$%&/()=?aa" , "^([\\p{Print}]){1,100}$")); + assertTrue(checkValid( "aa!%&/()=?a" , "^([\\p{Print}]){1,100}$")); + assertTrue(checkValid( "a{\"a!%&/()=?a" , "^([\\p{Print}]){1,100}$")); + assertTrue(checkValid( "BB" , "^([\\p{Print}]){1,100}$")); + assertTrue(checkValid( "BB " , "^([\\p{Print}]){1,100}$")); + } + + @Test + public void testValueValidWithDefaultRegex() { + assertTrue(checkValid( "aaa" +"aa", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + assertTrue(checkValid( "aaa" , DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + assertTrue(checkValid( "a!\"$%&/()[]=?aa-_,;.:[]|{}" , DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); +// assertTrue(checkValid( "a!\"§$%&/()=?aa" , DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + assertTrue(checkValid( "aa!%&/()=?a" , DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + assertTrue(checkValid( "a{\"a!%&/()=?a" , DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + assertTrue(checkValid( "BB" , DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + assertTrue(checkValid( "BB " , DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + assertTrue(checkValid("! €%&/()?`$\"§", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + assertTrue(checkValid("€", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + assertTrue(checkValid("$", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + assertTrue(checkValid("! €\"§$%&/()=?`", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + assertTrue(checkValid("#", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + assertTrue(checkValid("-_", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + assertTrue(checkValid("'", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + assertTrue(checkValid("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#-_ß?+#*", + DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + } + + @Test + public void testValueInvalid() { + assertFalse(checkValid((char) 13 +"aaa" +"aa", "^([\\p{Print}]){1,100}$")); + assertFalse(checkValid((char) 13 +"", "^([\\p{Print}]){1,100}$")); + assertFalse(checkValid( "aaa" +(char) 13, "^([\\p{Print}]){1,100}$")); + assertFalse(checkValid("", "^([\\p{Print}]){1,100}$")); + assertFalse(checkValid("a", "^([\\p{Print}]){2,100}$")); + assertFalse(checkValid("aaa"+(char) 13 +"aa", "^([\\p{Print}]){1,100}$")); + } + + @Test + public void testUmlauteValid() { + assertTrue(checkValid( "ä", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + assertTrue(checkValid( "ö", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + assertTrue(checkValid( "ü", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + assertTrue(checkValid( "Ä", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + assertTrue(checkValid( "Ö", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + assertTrue(checkValid( "Ü", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + assertTrue(checkValid( "ÄÖÜöäüjhsbdjej", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + assertTrue(checkValid( "aauacnhuisdc Ä Ü Ö aaxsa ö aÜaÖa", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + assertTrue(checkValid( "NMS Güssing", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX)); + } + + public boolean checkValid(String s, String regex) { + return CheckSignatureBlockParameters.isValid(s, regex); + } +} -- cgit v1.2.3