diff ui/tests/windowsstoretest.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 53ea9b975d1c
children 17e1c8f37d72
line wrap: on
line diff
--- a/ui/tests/windowsstoretest.cpp	Mon Mar 31 08:03:20 2014 +0000
+++ b/ui/tests/windowsstoretest.cpp	Mon Mar 31 08:06:17 2014 +0000
@@ -46,16 +46,24 @@
     PCCERT_CONTEXT pCert = NULL;
     size_t i = 0;
 
-    foreach (const Certificate &cert, validList.getInstallCertificates()) {
+    QList<Certificate> instList;
+
+    foreach (const Certificate &cert, validList.getCertificates()) {
+        if (cert.isInstallCert())
+            instList << cert;
+    }
+
+
+    foreach (const Certificate &cert, instList) {
         strv_append (&to_install, cert.base64Line().toLatin1().constData() + 2,
                 cert.base64Line().size() - 2);
     }
 
     /* Just a quick check for str_append_str functionality */
-    QVERIFY((size_t) validList.getInstallCertificates().size() == strv_length(to_install));
+    QVERIFY((size_t) instList.size() == strv_length(to_install));
     for (i = 0; i < strv_length(to_install); i++) {
-        QVERIFY (validList.getInstallCertificates()[i].base64Line().right(
-                    validList.getInstallCertificates()[i].base64Line().size() - 2) ==
+        QVERIFY (instList[i].base64Line().right(
+                    instList[i].base64Line().size() - 2) ==
                 QString::fromLatin1(to_install[i]));
     }
 
@@ -66,7 +74,7 @@
         bool certFound = false;
         QByteArray data = QByteArray::fromRawData ((const char *)pCert->pbCertEncoded,
                 pCert->cbCertEncoded);
-        foreach (const Certificate &cert, validList.getInstallCertificates()) {
+        foreach (const Certificate &cert, instList) {
             QByteArray asn1data = QByteArray::fromBase64(
                     cert.base64Line().right(cert.base64Line().size() - 2).toLatin1());
             if (asn1data == data) {
@@ -76,7 +84,7 @@
         QVERIFY(certFound);
         i++;
     }
-    QVERIFY ((size_t)validList.getInstallCertificates().size() == i);
+    QVERIFY ((size_t)instList.size() == i);
 
     /* Remove all except one */
     for (i = 0; i < strv_length(to_install) - 1; i++) {
@@ -116,8 +124,8 @@
         QByteArray data = QByteArray::fromRawData((const char*) pCert->pbCertEncoded,
                 pCert->cbCertEncoded);
         QVERIFY (data.toBase64() != to_remove[0]);
-        for (int j = 0; j < validList.getInstallCertificates().size() - 1; j++) {
-            const Certificate &cert = validList.getInstallCertificates()[j];
+        for (int j = 0; j < instList.size() - 1; j++) {
+            const Certificate &cert = instList[j];
             QByteArray asn1data = QByteArray::fromBase64(
                     cert.base64Line().right(cert.base64Line().size() - 2).toLatin1());
             if (asn1data == data) {

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