diff ui/tests/windowsstoretest.cpp @ 222:53ea9b975d1c

Cleanup windowsstore.c The cause for the test failure was that ADD_ALWAYS did not add a duplicate in the Root store but did add a duplicate in the Memory Store. We now check if the certificate is already in the store before actually installing it.
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 27 Mar 2014 14:16:22 +0000
parents e6c5c70a67b0
children 6a7eb102716d
line wrap: on
line diff
--- a/ui/tests/windowsstoretest.cpp	Thu Mar 27 10:23:49 2014 +0000
+++ b/ui/tests/windowsstoretest.cpp	Thu Mar 27 14:16:22 2014 +0000
@@ -6,6 +6,22 @@
 
 #include <QTest>
 
+void WindowsStoreTest::dumpContents() {
+    char pszNameString[256];
+    PCCERT_CONTEXT pCert = NULL;
+    qDebug() << "Currently in store: " ;
+    while((pCert = CertEnumCertificatesInStore(testStore, pCert))) {
+        if(CertGetNameString(pCert,
+                             CERT_NAME_SIMPLE_DISPLAY_TYPE,
+                             0,
+                             NULL,
+                             pszNameString,
+                             128)){
+            qDebug() << "   " << pszNameString ;
+        }
+    }
+}
+
 void WindowsStoreTest::initTestCase() {
     testStore = CertOpenStore(
       CERT_STORE_PROV_MEMORY,    // A memory store
@@ -60,7 +76,6 @@
         QVERIFY(certFound);
         i++;
     }
-    qDebug() << i;
     QVERIFY ((size_t)validList.getInstallCertificates().size() == i);
 
     /* Remove all except one */
@@ -100,7 +115,7 @@
         bool certFound = false;
         QByteArray data = QByteArray::fromRawData((const char*) pCert->pbCertEncoded,
                 pCert->cbCertEncoded);
-        qDebug() << "Have in store: " << data.toBase64();
+        QVERIFY (data.toBase64() != to_remove[0]);
         for (int j = 0; j < validList.getInstallCertificates().size() - 1; j++) {
             const Certificate &cert = validList.getInstallCertificates()[j];
             QByteArray asn1data = QByteArray::fromBase64(
@@ -117,7 +132,8 @@
 
     /* Install all again and remove them afterwards */
     do_install(testStore, to_install);
-    do_remove(testStore, to_remove);
+    do_remove(testStore, to_install);
+
     QVERIFY (CertEnumCertificatesInStore(testStore, pCert) == NULL);
 
     strv_free(to_install);

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