diff ui/tests/certlistparsertest.cpp @ 42:6e7ef7e95031

Some more tests and some more test data
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 14 Mar 2014 09:48:56 +0000
parents 37fc66967517
children a7b8cb29f1f6
line wrap: on
line diff
--- a/ui/tests/certlistparsertest.cpp	Fri Mar 14 09:48:02 2014 +0000
+++ b/ui/tests/certlistparsertest.cpp	Fri Mar 14 09:48:56 2014 +0000
@@ -7,7 +7,6 @@
 {
     const char *fname = "list-valid-signed.txt";
     CertificateList *certList = testWithFile(fname);
-    printf("Status :%i\n ",certList->getStatus());
     QCOMPARE (certList->getStatus(), Valid);
     QVERIFY (certList->isValid());
     delete certList;
@@ -15,10 +14,15 @@
 
 void CertListTest::testInvalidSig()
 {
-    const char *fname = "list-invalid-signed.txt";
-    CertificateList *certList = testWithFile(fname);
-    QCOMPARE (certList->getStatus(), InvalidSignature);
-    delete certList;
+    const char *fnames[] = {"list-invalid-signed.txt",
+        "list-valid-other-signature.txt",
+        "list-valid-sha1-signature.txt",
+        NULL};
+    for (int i=0; fnames[i] != NULL; i++) {
+        CertificateList *certList = testWithFile(fnames[i]);
+        QCOMPARE (certList->getStatus(), InvalidSignature);
+        delete certList;
+    }
 }
 
 void verifyInvalidFile(const char *fName) {
@@ -36,12 +40,25 @@
     verifyInvalidFile("💩 ");
 }
 
+void CertListTest::testEmptyFile()
+{
+    const char *fname = "empty_file";
+    CertificateList *certList = testWithFile(fname);
+    printf("Status :%i\n ",certList->getStatus());
+    QCOMPARE (certList->getStatus(), UnknownError);
+    delete certList;
+}
+
 void CertListTest::testGarbage()
 {
-    const char *fname = "random_500KB";
-    CertificateList *certList = testWithFile(fname);
-    QCOMPARE (certList->getStatus(), InvalidFormat);
-    delete certList;
+    const char *fnames[] = {"random_500KB",
+        "list-with-null.txt",
+        NULL};
+    for (int i=0; fnames[i] != NULL; i++) {
+        CertificateList *certList = testWithFile(fnames[i]);
+        QCOMPARE (certList->getStatus(), InvalidFormat);
+        delete certList;
+    }
 }
 
 void CertListTest::testTooLarge()

http://wald.intevation.org/projects/trustbridge/