[KGpg SoC] Status Report - May 24 2018

Rolf Eike Beer eb at emlix.com
Fri May 25 07:19:24 UTC 2018


Harindu Dilshan wrote:
> I added tests for KGpgChangeDisable and rebased branch to master.
> 
> After the rebasing, KGpgImport and KGpgVerify tests failed because
> done(int result) returned (2 - TS_MSG_SEQUENCE I think). I found what
> happened and pushed a commit for that. I don't understand why
> KGpgTransaction::setSuccess() was changed that way. Tests which failed
> before are passing with the new commit.

Ooooh crap. You broke it when fixing bug 373909, but that's not your fault. 
_I_ told you to move the call of keyConsidered() into KGpgTransaction, i.e. do 
it always. But when you look at that function you can see that it will always 
set the result to TS_MSG_SEQUENCE if the fingerprint that is found is not in 
the list of fingerprints that is passed to the function. And then the code now 
does that:

	if (m_parent->keyConsidered(line, QStringList())) {

Fails as expected. Doh! I will fix that tonight, it's not as simple as we have 
to get the keys into that place again.

Well, stop, there is one thing that must be said now: CONGRATULATIONS!! Your 
testcases found the first regression! And even cooler, there has not been a 
bug report for this yet and we will have a fix shortly. Awesome!

In the meantime I had a look on that testcase and a few things on the way, and 
here is a little exam for you ;)

This is my diff for the test directory, and I would like that you explain for 
every hunk why I'm doing this. Hint: most answers are easy when you compare 
the build and test output before and after the test (it could be that you need 
a recent version of CMake to see the change in the build output, I use 
3.11.1). Hunks with more than 2 lines added (i.e. more than to lines matching 
'^\+') have multiple things going on and need 2 explanations for the different 
parts of the change.

diff --git a/tests/common.cpp b/tests/common.cpp
index eca4a8e..5cf772d 100644
--- a/tests/common.cpp
+++ b/tests/common.cpp
@@ -12,9 +12,14 @@
 
 bool resetGpgConf()
 {
-       QDir dir(QLatin1String(".gnupg"));
+       const QString dot_gpg(QLatin1String(".gnupg"));
+
+       QDir dir(dot_gpg);
        dir.removeRecursively();
-       QDir::current().mkdir(QLatin1String(".gnupg"));
+       if (!QDir::current().mkdir(dot_gpg))
+               return false;
+       if (!QFile::setPermissions(QDir::currentPath() + QLatin1Char('/') + 
dot_gpg, QFileDevice::ReadOwner | QFileDevice::WriteOwner | 
QFileDevice::ExeOwner))
+               return false;
        return QFile::copy(QLatin1String("gnupg/gpg.conf"), 
QLatin1String(".gnupg/gpg.conf"));
 }
 
diff --git a/tests/kgpgchangedisable.cpp b/tests/kgpgchangedisable.cpp
index 0e54dde..5768095 100644
--- a/tests/kgpgchangedisable.cpp
+++ b/tests/kgpgchangedisable.cpp
@@ -8,12 +8,12 @@
 void KGpgChangeDisableTest::init()
 {
        QVERIFY(resetGpgConf());
+       addGpgKey(QLatin1String("keys/kgpgtest_BA7695F3C550DF14.asc"));
 }
 
 void KGpgChangeDisableTest::testDisableKey()
 {
-       QLatin1String keyID("BA7695F3C550DF14");
-       addGpgKey(QLatin1String("keys/kgpgtest_BA7695F3C550DF14.asc"));
+       const QString keyID = 
QLatin1String("FBAF08DD7D9D0921C15DDA9FBA7695F3C550DF14");
        KGpgChangeDisable *transaction = new KGpgChangeDisable(this, keyID, 
true);
        QSignalSpy spy(transaction, &KGpgChangeDisable::done);
        QObject::connect(transaction, &KGpgChangeDisable::done, [](int result) 
{
@@ -24,13 +24,13 @@ void KGpgChangeDisableTest::testDisableKey()
        QVERIFY(spy.wait());
        KgpgCore::KgpgKeyList keyList = 
KgpgInterface::readPublicKeys(QStringList(keyID));
 
-       QCOMPARE(keyList.first().valid(), false);
+       QVERIFY(!keyList.isEmpty());
+       QVERIFY(!keyList.first().valid());
 }
 
 void KGpgChangeDisableTest::testEnableKey()
 {
-       QLatin1String keyID("BA7695F3C550DF14");
-       addGpgKey(QLatin1String("keys/kgpgtest_BA7695F3C550DF14.asc"));
+       const QString keyID = 
QLatin1String("FBAF08DD7D9D0921C15DDA9FBA7695F3C550DF14");
        KGpgChangeDisable *transaction = new KGpgChangeDisable(this, keyID, 
true);
        QSignalSpy spy(transaction, &KGpgChangeDisable::done);
        transaction->start();
@@ -44,8 +44,8 @@ void KGpgChangeDisableTest::testEnableKey()
        QVERIFY(spy.wait());
        KgpgCore::KgpgKeyList keyList = 
KgpgInterface::readPublicKeys(QStringList(keyID));
 
-       QCOMPARE(keyList.first().valid(), true);
+       QVERIFY(!keyList.isEmpty());
+       QVERIFY(keyList.first().valid());
 }
 
-#include "kgpgchangedisable.moc"
 QTEST_MAIN(KGpgChangeDisableTest)
diff --git a/tests/kgpgchangetrust.cpp b/tests/kgpgchangetrust.cpp
index 3281643..c161d3f 100644
--- a/tests/kgpgchangetrust.cpp
+++ b/tests/kgpgchangetrust.cpp
@@ -35,5 +35,4 @@ void KGpgChangeTrustTest::testChangeTrust_data()
        QTest::newRow("never") << GPGME_VALIDITY_NEVER;
 }
 
-#include "kgpgchangetrust.moc"
 QTEST_MAIN(KGpgChangeTrustTest)
diff --git a/tests/kgpgimport.cpp b/tests/kgpgimport.cpp
index 5dd089c..9d2a152 100644
--- a/tests/kgpgimport.cpp
+++ b/tests/kgpgimport.cpp
@@ -147,5 +147,4 @@ void KGpgImportTest::testImportSecretKey()
        QVERIFY(spy.wait());
 }
 
-#include "kgpgimport.moc"
 QTEST_MAIN(KGpgImportTest)
diff --git a/tests/kgpgverify.cpp b/tests/kgpgverify.cpp
index 44eac01..0e88599 100644
--- a/tests/kgpgverify.cpp
+++ b/tests/kgpgverify.cpp
@@ -75,5 +75,4 @@ void KGpgVerifyTest::testVerifyReturnBadSignature()
        QVERIFY(spy.wait());
 }
 
-#include "kgpgverify.moc"
 QTEST_MAIN(KGpgVerifyTest)

-- 
Bitte beachten Sie unsere neue Adresse am Göttinger Standort:
emlix GmbH, Gothaer Platz 3, 37083 Göttingen

Rolf Eike Beer, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055

emlix - smart embedded open source
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 313 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-utils-devel/attachments/20180525/8e269233/attachment.sig>


More information about the Kde-utils-devel mailing list