Mercurial > trustbridge
comparison 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 |
comparison
equal
deleted
inserted
replaced
41:7055a79abe02 | 42:6e7ef7e95031 |
---|---|
5 | 5 |
6 void CertListTest::testValidList() | 6 void CertListTest::testValidList() |
7 { | 7 { |
8 const char *fname = "list-valid-signed.txt"; | 8 const char *fname = "list-valid-signed.txt"; |
9 CertificateList *certList = testWithFile(fname); | 9 CertificateList *certList = testWithFile(fname); |
10 printf("Status :%i\n ",certList->getStatus()); | |
11 QCOMPARE (certList->getStatus(), Valid); | 10 QCOMPARE (certList->getStatus(), Valid); |
12 QVERIFY (certList->isValid()); | 11 QVERIFY (certList->isValid()); |
13 delete certList; | 12 delete certList; |
14 } | 13 } |
15 | 14 |
16 void CertListTest::testInvalidSig() | 15 void CertListTest::testInvalidSig() |
17 { | 16 { |
18 const char *fname = "list-invalid-signed.txt"; | 17 const char *fnames[] = {"list-invalid-signed.txt", |
19 CertificateList *certList = testWithFile(fname); | 18 "list-valid-other-signature.txt", |
20 QCOMPARE (certList->getStatus(), InvalidSignature); | 19 "list-valid-sha1-signature.txt", |
21 delete certList; | 20 NULL}; |
21 for (int i=0; fnames[i] != NULL; i++) { | |
22 CertificateList *certList = testWithFile(fnames[i]); | |
23 QCOMPARE (certList->getStatus(), InvalidSignature); | |
24 delete certList; | |
25 } | |
22 } | 26 } |
23 | 27 |
24 void verifyInvalidFile(const char *fName) { | 28 void verifyInvalidFile(const char *fName) { |
25 CertificateList *certList = new CertificateList(fName); | 29 CertificateList *certList = new CertificateList(fName); |
26 QVERIFY (certList->getStatus() != Valid); | 30 QVERIFY (certList->getStatus() != Valid); |
34 verifyInvalidFile(NULL); | 38 verifyInvalidFile(NULL); |
35 verifyInvalidFile("ä"); | 39 verifyInvalidFile("ä"); |
36 verifyInvalidFile("💩 "); | 40 verifyInvalidFile("💩 "); |
37 } | 41 } |
38 | 42 |
43 void CertListTest::testEmptyFile() | |
44 { | |
45 const char *fname = "empty_file"; | |
46 CertificateList *certList = testWithFile(fname); | |
47 printf("Status :%i\n ",certList->getStatus()); | |
48 QCOMPARE (certList->getStatus(), UnknownError); | |
49 delete certList; | |
50 } | |
51 | |
39 void CertListTest::testGarbage() | 52 void CertListTest::testGarbage() |
40 { | 53 { |
41 const char *fname = "random_500KB"; | 54 const char *fnames[] = {"random_500KB", |
42 CertificateList *certList = testWithFile(fname); | 55 "list-with-null.txt", |
43 QCOMPARE (certList->getStatus(), InvalidFormat); | 56 NULL}; |
44 delete certList; | 57 for (int i=0; fnames[i] != NULL; i++) { |
58 CertificateList *certList = testWithFile(fnames[i]); | |
59 QCOMPARE (certList->getStatus(), InvalidFormat); | |
60 delete certList; | |
61 } | |
45 } | 62 } |
46 | 63 |
47 void CertListTest::testTooLarge() | 64 void CertListTest::testTooLarge() |
48 { | 65 { |
49 const char *fname = "random_2MB"; | 66 const char *fname = "random_2MB"; |