aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/test/java/at/gv/egiz/pdfas
diff options
context:
space:
mode:
authorAlexander Marsalek <amarsalek@iaik.tugraz.at>2021-04-14 19:05:02 +0200
committerAlexander Marsalek <amarsalek@iaik.tugraz.at>2021-04-14 19:05:02 +0200
commit1be82e61c0acf4d7380dcee3e3fcaaa8a8386f1b (patch)
treee82cf8d679867779d4dbd2bf1a857dc8e9b3fafa /pdf-as-lib/src/test/java/at/gv/egiz/pdfas
parent97b362c9f6906ecaf94c3f0d4fba10ab60206b2a (diff)
downloadpdf-as-4-1be82e61c0acf4d7380dcee3e3fcaaa8a8386f1b.tar.gz
pdf-as-4-1be82e61c0acf4d7380dcee3e3fcaaa8a8386f1b.tar.bz2
pdf-as-4-1be82e61c0acf4d7380dcee3e3fcaaa8a8386f1b.zip
added sbp check
Diffstat (limited to 'pdf-as-lib/src/test/java/at/gv/egiz/pdfas')
-rw-r--r--pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/mains/SignatureBlockParameterTest.java51
1 files changed, 51 insertions, 0 deletions
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
new file mode 100644
index 00000000..3c76ce11
--- /dev/null
+++ b/pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/mains/SignatureBlockParameterTest.java
@@ -0,0 +1,51 @@
+package at.gv.egiz.pdfas.lib.test.mains;
+
+import at.gv.egiz.pdfas.common.utils.CheckSignatureBlockParameters;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+@RunWith(JUnit4.class)
+public class SignatureBlockParameterTest {
+
+
+ @Test
+ public void testKeyInvalid() {
+ if(checkValid( "aaaaaaaaaaaaaaaaaaaaa" , "^([A-za-z]){1,20}$") == true){assert(false);}
+ if(checkValid( "" , "^([A-za-z]){1,20}$") == true){assert(false);}
+ if(checkValid( "a9" , "^([A-za-z]){1,20}$") == true){assert(false);}
+ }
+ @Test
+ public void testKeyValid() {
+ if(checkValid( "aaa" +"aa", "^([A-za-z]){1,20}$") == false){assert(false);}
+ if(checkValid( "aaa" , "^([A-za-z]){1,20}$") == false){assert(false);}
+ if(checkValid( "aaaaaaaaaaaaaaaaaaaa", "^([A-za-z]){1,20}$") == false){assert(false);}
+ if(checkValid( "AA", "^([A-za-z]){1,20}$") == false){assert(false);}
+ }
+ @Test
+ public void testValueValid() {
+ if(checkValid( "aaa" +"aa", "^([\\p{Print}]){1,100}$") == false){assert(false);}
+ if(checkValid( "aaa" , "^([\\p{Print}]){1,100}$") == false){assert(false);}
+ if(checkValid( "a!\"$%&/()[]=?aa" , "^([\\p{Print}]){1,100}$") == false){assert(false);}
+ if(checkValid( "a!\"$%&/()[]=?aa-_,;.:[]|{}" , "^([\\p{Print}]){1,100}$") == false){assert(false);}
+// if(checkValid( "a!\"ยง$%&/()=?aa" , "^([\\p{Print}]){1,100}$") == false){assert(false);}
+ if(checkValid( "aa!%&/()=?a" , "^([\\p{Print}]){1,100}$") == false){assert(false);}
+ if(checkValid( "a{\"a!%&/()=?a" , "^([\\p{Print}]){1,100}$") == false){assert(false);}
+ if(checkValid( "BB" , "^([\\p{Print}]){1,100}$") == false){assert(false);}
+ if(checkValid( "BB " , "^([\\p{Print}]){1,100}$") == false){assert(false);}
+ }
+ @Test
+ public void testValueInvalid() {
+ if(checkValid((char) 13 +"aaa" +"aa", "^([\\p{Print}]){1,100}$") == true){assert(false);}
+ if(checkValid((char) 13 +"", "^([\\p{Print}]){1,100}$") == true){assert(false);}
+ if(checkValid( "aaa" +(char) 13, "^([\\p{Print}]){1,100}$") == true){assert(false);}
+ if(checkValid("", "^([\\p{Print}]){1,100}$") == true){assert(false);}
+ if(checkValid("a", "^([\\p{Print}]){2,100}$") == true){assert(false);}
+ if(checkValid("aaa"+(char) 13 +"aa", "^([\\p{Print}]){1,100}$") == true){assert(false);}
+
+ }
+
+ public boolean checkValid(String s, String regex) {
+ return CheckSignatureBlockParameters.isValid(s, regex);
+ }
+}