comparison ui/tests/certlistparsertest.cpp @ 87:be13e5e0a98f

Expand test to cover more functionality from certificate and certificatelist
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 20 Mar 2014 16:23:31 +0000
parents a7b8cb29f1f6
children abc76b750ea8
comparison
equal deleted inserted replaced
86:6f1a73575c99 87:be13e5e0a98f
1 #include "certlistparsertest.h" 1 #include "certlistparsertest.h"
2 #include "certificatelist.h" 2 #include "certificatelist.h"
3 #include "certificate.h"
3 4
4 #include <QDebug> 5 #include <QDebug>
5 6
6 void CertListTest::testValidList() 7 void CertListTest::testValidList()
7 { 8 {
8 const char *fname = "list-valid-signed.txt"; 9 const char *fname = "list-valid-signed.txt";
10 QFile validList(fname);
11 validList.open(QIODevice::ReadOnly);
12 QString validData = QString::fromLatin1(validList.readAll());
13 QStringList instLines;
14 QStringList remoLines;
15
9 CertificateList *certList = testWithFile(fname); 16 CertificateList *certList = testWithFile(fname);
10 QCOMPARE (certList->getStatus(), Valid); 17 QCOMPARE(certList->getStatus(), Valid);
11 QVERIFY (certList->isValid()); 18 QVERIFY(certList->isValid());
19
20 QVERIFY(certList->rawData() == validData.toLatin1());
21
22 const QList<Certificate> instList = certList->getInstallCertificates();
23 const QList<Certificate> remoList = certList->getInstallCertificates();
24
25 foreach (QString act, validData.split("\r\n")) {
26 if (act.startsWith("I:")) {
27 instLines << act;
28 continue;
29 }
30 if (act.startsWith("R:")) {
31 remoLines << act;
32 continue;
33 }
34 }
35
36 foreach (const Certificate& cert, instList) {
37 QVERIFY(cert.isValid());
38 QVERIFY(instLines.contains(cert.base64Line()));
39 }
40 foreach (const Certificate& cert, remoList) {
41 QVERIFY(cert.isValid());
42 QVERIFY(remoLines.contains(cert.base64Line()));
43 }
44
45 /* Be variable if test data changes later */
46 QVERIFY(instList.size() >= 1);
47 QVERIFY(remoList.size() >= 1);
48 QVERIFY(instLines.size() == instList.size());
49 QVERIFY(remoLines.size() == remoList.size());
50
51
12 delete certList; 52 delete certList;
13 } 53 }
14 54
15 void CertListTest::testInvalidSig() 55 void CertListTest::testInvalidSig()
16 { 56 {

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