annotate ui/tests/windowsstoretest.cpp @ 1344:cf1cd6cda97b

(Auto) Update translations
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 28 Oct 2014 12:01:27 +0100
parents 562d66614b5c
children
rev   line source
404
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
2 * Software engineering by Intevation GmbH
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
3 *
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
4 * This file is Free Software under the GNU GPL (v>=2)
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY!
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
6 * See LICENSE.txt for details.
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 249
diff changeset
7 */
220
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
8 #include "windowsstoretest.h"
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
9 #include "certificatelist.h"
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
10 #include "strhelp.h"
1327
562d66614b5c (issue169) Fix handling of exclusive locks.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1060
diff changeset
11 #include "logging.h"
220
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
12 #include "certificate.h"
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
13 #include "../cinst/windowsstore.h"
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
14
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
15 #include <QTest>
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
16
222
53ea9b975d1c Cleanup windowsstore.c
Andre Heinecke <aheinecke@intevation.de>
parents: 220
diff changeset
17 void WindowsStoreTest::dumpContents() {
602
854248d81ba4 Fully switch to unicode for windows.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 404
diff changeset
18 wchar_t pszNameString[256];
222
53ea9b975d1c Cleanup windowsstore.c
Andre Heinecke <aheinecke@intevation.de>
parents: 220
diff changeset
19 PCCERT_CONTEXT pCert = NULL;
53ea9b975d1c Cleanup windowsstore.c
Andre Heinecke <aheinecke@intevation.de>
parents: 220
diff changeset
20 qDebug() << "Currently in store: " ;
53ea9b975d1c Cleanup windowsstore.c
Andre Heinecke <aheinecke@intevation.de>
parents: 220
diff changeset
21 while((pCert = CertEnumCertificatesInStore(testStore, pCert))) {
53ea9b975d1c Cleanup windowsstore.c
Andre Heinecke <aheinecke@intevation.de>
parents: 220
diff changeset
22 if(CertGetNameString(pCert,
53ea9b975d1c Cleanup windowsstore.c
Andre Heinecke <aheinecke@intevation.de>
parents: 220
diff changeset
23 CERT_NAME_SIMPLE_DISPLAY_TYPE,
53ea9b975d1c Cleanup windowsstore.c
Andre Heinecke <aheinecke@intevation.de>
parents: 220
diff changeset
24 0,
53ea9b975d1c Cleanup windowsstore.c
Andre Heinecke <aheinecke@intevation.de>
parents: 220
diff changeset
25 NULL,
53ea9b975d1c Cleanup windowsstore.c
Andre Heinecke <aheinecke@intevation.de>
parents: 220
diff changeset
26 pszNameString,
53ea9b975d1c Cleanup windowsstore.c
Andre Heinecke <aheinecke@intevation.de>
parents: 220
diff changeset
27 128)){
53ea9b975d1c Cleanup windowsstore.c
Andre Heinecke <aheinecke@intevation.de>
parents: 220
diff changeset
28 qDebug() << " " << pszNameString ;
53ea9b975d1c Cleanup windowsstore.c
Andre Heinecke <aheinecke@intevation.de>
parents: 220
diff changeset
29 }
53ea9b975d1c Cleanup windowsstore.c
Andre Heinecke <aheinecke@intevation.de>
parents: 220
diff changeset
30 }
53ea9b975d1c Cleanup windowsstore.c
Andre Heinecke <aheinecke@intevation.de>
parents: 220
diff changeset
31 }
53ea9b975d1c Cleanup windowsstore.c
Andre Heinecke <aheinecke@intevation.de>
parents: 220
diff changeset
32
220
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
33 void WindowsStoreTest::initTestCase() {
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
34 testStore = CertOpenStore(
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
35 CERT_STORE_PROV_MEMORY, // A memory store
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
36 0, // Encoding type
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
37 // Not used with a memory store
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
38 0, // Use the default provider
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
39 0, // No flags
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
40 NULL); // Not needed
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
41 QVERIFY (testStore);
1327
562d66614b5c (issue169) Fix handling of exclusive locks.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1060
diff changeset
42 tmpFile.open(); // get the file name
562d66614b5c (issue169) Fix handling of exclusive locks.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1060
diff changeset
43 /* This is not really a secure way to open a temporay file but it's ok
562d66614b5c (issue169) Fix handling of exclusive locks.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1060
diff changeset
44 * for a unit test. The Problem is that qtemporaryfile prohibits obtaining
562d66614b5c (issue169) Fix handling of exclusive locks.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1060
diff changeset
45 * an exclusive lock on the created file. */
562d66614b5c (issue169) Fix handling of exclusive locks.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1060
diff changeset
46 QVERIFY(QFile::copy(":/list-valid-signed.txt", tmpFile.fileName() + "_exclusive"));
220
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
47 tmpFile.close();
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
48
1327
562d66614b5c (issue169) Fix handling of exclusive locks.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1060
diff changeset
49 validList = CertificateList((tmpFile.fileName() + "_exclusive").toLocal8Bit().data());
562d66614b5c (issue169) Fix handling of exclusive locks.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1060
diff changeset
50 QVERIFY(validList.isValid());
562d66614b5c (issue169) Fix handling of exclusive locks.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1060
diff changeset
51 QVERIFY(validList.getCertificates().size() > 0);
220
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
52 }
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
53
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
54 void WindowsStoreTest::testInstRemove() {
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
55 char ** to_install = NULL,
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
56 ** to_remove = NULL;
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
57 PCCERT_CONTEXT pCert = NULL;
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
58 size_t i = 0;
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
59
249
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 222
diff changeset
60 QList<Certificate> instList;
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 222
diff changeset
61
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 222
diff changeset
62 foreach (const Certificate &cert, validList.getCertificates()) {
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 222
diff changeset
63 if (cert.isInstallCert())
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 222
diff changeset
64 instList << cert;
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 222
diff changeset
65 }
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 222
diff changeset
66
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 222
diff changeset
67
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 222
diff changeset
68 foreach (const Certificate &cert, instList) {
220
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
69 strv_append (&to_install, cert.base64Line().toLatin1().constData() + 2,
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
70 cert.base64Line().size() - 2);
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
71 }
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
72
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
73 /* Just a quick check for str_append_str functionality */
249
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 222
diff changeset
74 QVERIFY((size_t) instList.size() == strv_length(to_install));
1327
562d66614b5c (issue169) Fix handling of exclusive locks.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1060
diff changeset
75 QVERIFY(strv_length(to_install) > 0);
220
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
76 for (i = 0; i < strv_length(to_install); i++) {
249
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 222
diff changeset
77 QVERIFY (instList[i].base64Line().right(
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 222
diff changeset
78 instList[i].base64Line().size() - 2) ==
220
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
79 QString::fromLatin1(to_install[i]));
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
80 }
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
81
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
82 do_install(testStore, to_install);
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
83
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
84 i = 0;
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
85 while((pCert = CertEnumCertificatesInStore(testStore, pCert))) {
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
86 bool certFound = false;
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
87 QByteArray data = QByteArray::fromRawData ((const char *)pCert->pbCertEncoded,
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
88 pCert->cbCertEncoded);
249
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 222
diff changeset
89 foreach (const Certificate &cert, instList) {
220
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
90 QByteArray asn1data = QByteArray::fromBase64(
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
91 cert.base64Line().right(cert.base64Line().size() - 2).toLatin1());
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
92 if (asn1data == data) {
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
93 certFound = true;
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
94 }
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
95 }
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
96 QVERIFY(certFound);
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
97 i++;
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
98 }
249
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 222
diff changeset
99 QVERIFY ((size_t)instList.size() == i);
220
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
100
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
101 /* Remove all except one */
1327
562d66614b5c (issue169) Fix handling of exclusive locks.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1060
diff changeset
102 QVERIFY(strv_length(to_install));
220
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
103 for (i = 0; i < strv_length(to_install) - 1; i++) {
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
104 strv_append(&to_remove, to_install[i], qstrlen(to_install[i]));
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
105 }
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
106
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
107 do_remove(testStore, to_remove);
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
108
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
109 i = 0;
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
110 while((pCert = CertEnumCertificatesInStore(testStore, pCert))) {
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
111 i++;
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
112 }
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
113
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
114 QVERIFY(i == 1);
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
115
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
116 /* Remove that too */
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
117 strv_free(to_remove);
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
118 to_remove = NULL;
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
119 strv_append(&to_remove, to_install[strv_length(to_install) - 1],
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
120 qstrlen(to_install[strv_length(to_install) - 1]));
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
121
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
122 do_remove(testStore, to_remove);
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
123
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
124 QVERIFY (CertEnumCertificatesInStore(testStore, pCert) == NULL);
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
125
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
126 /* Install them all again */
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
127 do_install(testStore, to_install);
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
128 strv_free(to_remove);
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
129 to_remove = NULL;
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
130 strv_append(&to_remove, to_install[strv_length(to_install) - 1],
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
131 qstrlen(to_install[strv_length(to_install) - 1]));
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
132 do_remove(testStore, to_remove);
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
133
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
134 i = 0;
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
135 while((pCert = CertEnumCertificatesInStore(testStore, pCert))) {
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
136 bool certFound = false;
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
137 QByteArray data = QByteArray::fromRawData((const char*) pCert->pbCertEncoded,
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
138 pCert->cbCertEncoded);
222
53ea9b975d1c Cleanup windowsstore.c
Andre Heinecke <aheinecke@intevation.de>
parents: 220
diff changeset
139 QVERIFY (data.toBase64() != to_remove[0]);
249
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 222
diff changeset
140 for (int j = 0; j < instList.size() - 1; j++) {
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 222
diff changeset
141 const Certificate &cert = instList[j];
220
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
142 QByteArray asn1data = QByteArray::fromBase64(
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
143 cert.base64Line().right(cert.base64Line().size() - 2).toLatin1());
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
144 if (asn1data == data) {
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
145 certFound = true;
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
146 }
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
147 }
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
148 QVERIFY(certFound);
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
149 i++;
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
150 }
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
151
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
152 QVERIFY(i == strv_length(to_install) - 1);
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
153
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
154 /* Install all again and remove them afterwards */
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
155 do_install(testStore, to_install);
222
53ea9b975d1c Cleanup windowsstore.c
Andre Heinecke <aheinecke@intevation.de>
parents: 220
diff changeset
156 do_remove(testStore, to_install);
53ea9b975d1c Cleanup windowsstore.c
Andre Heinecke <aheinecke@intevation.de>
parents: 220
diff changeset
157
220
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
158 QVERIFY (CertEnumCertificatesInStore(testStore, pCert) == NULL);
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
159
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
160 strv_free(to_install);
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
161 strv_free(to_remove);
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
162 }
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
163
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
164 void WindowsStoreTest::cleanupTestCase() {
1327
562d66614b5c (issue169) Fix handling of exclusive locks.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1060
diff changeset
165 QFile::remove(tmpFile.fileName() + "_exclusive");
220
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
166 CertCloseStore(testStore, 0);
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
167 }
1060
317ee9dc4684 (issue46) Make debug output optional in cinst and mozilla and propagate its setting.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 602
diff changeset
168
317ee9dc4684 (issue46) Make debug output optional in cinst and mozilla and propagate its setting.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 602
diff changeset
169 bool g_debug = true;
317ee9dc4684 (issue46) Make debug output optional in cinst and mozilla and propagate its setting.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 602
diff changeset
170
220
e6c5c70a67b0 Add test for windowsstores
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
171 QTEST_GUILESS_MAIN (WindowsStoreTest);

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