3 This file is part of qgpgme, the Qt API binding for gpgme
4 Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik
5 Software engineering by Intevation GmbH
7 QGpgME is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the
10 License, or (at your option) any later version.
12 QGpgME is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 In addition, as a special exception, the copyright holders give
22 permission to link the code of this program with any edition of
23 the Qt library by Trolltech AS, Norway (or with modified versions
24 of Qt that use the same license as Qt), and distribute linked
25 combinations including the two. You must obey the GNU General
26 Public License in all respects for all of the code used other than
27 Qt. If you modify this file, you may extend this exception to
28 your version of the file, but you are not obligated to do so. If
29 you do not wish to do so, delete this exception statement from
38 #include <QTemporaryDir>
39 #include "t-support.h"
41 #include "cryptoconfig.h"
42 #include "engineinfo.h"
46 using namespace QGpgME;
48 class CryptoConfigTest: public QGpgMETest
55 // Repeatedly set a config value and clear it
56 // this was broken at some point so it gets a
58 for (int i = 0; i < 10; i++) {
59 auto conf = cryptoConfig();
61 auto entry = conf->entry(QStringLiteral("gpg"),
62 QStringLiteral("Keyserver"),
63 QStringLiteral("keyserver"));
65 const QString url(QStringLiteral("hkp://foo.bar.baz"));
66 entry->setStringValue(url);
69 entry = conf->entry(QStringLiteral("gpg"),
70 QStringLiteral("Keyserver"),
71 QStringLiteral("keyserver"));
72 QCOMPARE (entry->stringValue(), url);
73 entry->setStringValue(QString());
76 entry = conf->entry(QStringLiteral("gpg"),
77 QStringLiteral("Keyserver"),
78 QStringLiteral("keyserver"));
79 QCOMPARE (entry->stringValue(), QString());
85 if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.2.0") {
86 // We are using compliance here and other options might also
87 // be unsupported in older versions.
90 // First set compliance to de-vs
91 auto conf = cryptoConfig();
93 auto entry = conf->entry(QStringLiteral("gpg"),
94 QStringLiteral("Configuration"),
95 QStringLiteral("compliance"));
97 entry->setStringValue("de-vs");
100 entry = conf->entry(QStringLiteral("gpg"),
101 QStringLiteral("Configuration"),
102 QStringLiteral("compliance"));
103 QCOMPARE(entry->stringValue(), QStringLiteral("de-vs"));
104 entry->resetToDefault();
107 entry = conf->entry(QStringLiteral("gpg"),
108 QStringLiteral("Configuration"),
109 QStringLiteral("compliance"));
110 QCOMPARE(entry->stringValue(), QStringLiteral("gnupg"));
115 QGpgMETest::initTestCase();
116 const QString gpgHome = qgetenv("GNUPGHOME");
117 qputenv("GNUPGHOME", mDir.path().toUtf8());
118 QVERIFY(mDir.isValid());
125 QTEST_MAIN(CryptoConfigTest)
127 #include "t-config.moc"