Mercurial > trustbridge
comparison ui/tests/certlistparsertest.cpp @ 249:6a7eb102716d
Remove code duplication by unifying the certificatelist.
You should now check for isInstallCert to determine wether this
certificate should be installed or removed.
Leaving the getInstallCertificates and getRemoveCertificates
in place for compatibilty would have been easier to keep the
tests stable.
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 31 Mar 2014 08:06:17 +0000 |
parents | c05e126b0b9e |
children | ee59ab0eb7ff |
comparison
equal
deleted
inserted
replaced
248:9f0865dc8b14 | 249:6a7eb102716d |
---|---|
21 QCOMPARE(certList->getStatus(), Valid); | 21 QCOMPARE(certList->getStatus(), Valid); |
22 QVERIFY(certList->isValid()); | 22 QVERIFY(certList->isValid()); |
23 | 23 |
24 QVERIFY(certList->rawData() == validData.toLatin1()); | 24 QVERIFY(certList->rawData() == validData.toLatin1()); |
25 | 25 |
26 const QList<Certificate> instList = certList->getInstallCertificates(); | 26 const QList<Certificate> cList = certList->getCertificates(); |
27 const QList<Certificate> remoList = certList->getRemoveCertificates(); | |
28 | 27 |
29 foreach (QString act, validData.split("\r\n")) { | 28 foreach (QString act, validData.split("\r\n")) { |
30 if (act.startsWith("I:")) { | 29 if (act.startsWith("I:")) { |
31 instLines << act; | 30 instLines << act; |
32 continue; | 31 continue; |
35 remoLines << act; | 34 remoLines << act; |
36 continue; | 35 continue; |
37 } | 36 } |
38 } | 37 } |
39 | 38 |
40 foreach (const Certificate& cert, instList) { | 39 int instCnt = 0, |
40 remoCnt = 0; | |
41 foreach (const Certificate& cert, cList) { | |
41 QVERIFY(cert.isValid()); | 42 QVERIFY(cert.isValid()); |
42 QVERIFY(instLines.contains(cert.base64Line())); | 43 if (cert.isInstallCert()) { |
43 } | 44 QVERIFY(instLines.contains(cert.base64Line())); |
44 foreach (const Certificate& cert, remoList) { | 45 instCnt++; |
45 QVERIFY(cert.isValid()); | 46 } else { |
46 QVERIFY(remoLines.contains(cert.base64Line())); | 47 QVERIFY(remoLines.contains(cert.base64Line())); |
48 remoCnt++; | |
49 } | |
47 } | 50 } |
48 | 51 |
49 /* Be variable if test data changes later */ | 52 /* Be variable if test data changes later */ |
50 QVERIFY(instList.size() >= 1); | 53 QVERIFY(instCnt >= 1); |
51 QVERIFY(remoList.size() >= 1); | 54 QVERIFY(remoCnt >= 1); |
52 QVERIFY(instLines.size() == instList.size()); | 55 QVERIFY(instLines.size() == instCnt); |
53 QVERIFY(remoLines.size() == remoList.size()); | 56 QVERIFY(remoLines.size() == remoCnt); |
54 | 57 |
55 /* Check that a default certificate is invalid */ | 58 /* Check that a default certificate is invalid */ |
56 Certificate cert; | 59 Certificate cert; |
57 QVERIFY(!cert.isValid()); | 60 QVERIFY(!cert.isValid()); |
58 | 61 |
59 certList->readList(fileName.toLocal8Bit().data()); | 62 certList->readList(fileName.toLocal8Bit().data()); |
60 | 63 |
61 const QList<Certificate> instList2 = certList->getInstallCertificates(); | 64 const QList<Certificate> cList2 = certList->getCertificates(); |
62 const QList<Certificate> remoList2 = certList->getRemoveCertificates(); | 65 QVERIFY(instLines.size() + remoLines.size() == cList2.size()); |
63 QVERIFY(instLines.size() == instList2.size()); | |
64 QVERIFY(remoLines.size() == remoList2.size()); | |
65 | 66 |
66 delete certList; | 67 delete certList; |
67 } | 68 } |
68 | 69 |
69 void CertListTest::testInvalidSig() | 70 void CertListTest::testInvalidSig() |