diff options
author | Andre Heinecke <aheinecke@gnupg.org> | 2019-11-06 09:10:03 +0100 |
---|---|---|
committer | Andre Heinecke <aheinecke@gnupg.org> | 2019-11-06 09:10:03 +0100 |
commit | a56f6015e9518180237a70b8abc5ab9804212986 (patch) | |
tree | d110841100054001fd082f331fb7421656d43d83 | |
parent | 1b840a151ad7f9680ec5144da5efb0ee6c1dcf1f (diff) | |
download | gpgme-a56f6015e9518180237a70b8abc5ab9804212986.tar.gz |
qt,tests: Add test to add an exportable certify
* lang/qt/test/t-remarks.cpp (testRemarkReplaceSingleUIDExportable):
New.
--
Just checking in case the edit-key offers new states for that.
-rw-r--r-- | lang/qt/tests/t-remarks.cpp | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/lang/qt/tests/t-remarks.cpp b/lang/qt/tests/t-remarks.cpp index eaf12ca1..3a101903 100644 --- a/lang/qt/tests/t-remarks.cpp +++ b/lang/qt/tests/t-remarks.cpp @@ -107,6 +107,94 @@ public: private Q_SLOTS: + void testRemarkReplaceSingleUIDExportable() + { + // Get the signing key (alfa) + auto ctx = Context::create(OpenPGP); + QVERIFY (ctx); + Error err; + auto seckey = ctx->key("A0FF4590BB6122EDEF6E3C542D727CC768697734", err, true); + QVERIFY (!seckey.isNull()); + QVERIFY (!err); + + // Get the target key (tango) + auto target = ctx->key("ECAC774F4EEEB0620767044A58CB9A4C85A81F38", err, false); + QVERIFY (!target.isNull()); + QVERIFY (!err); + QVERIFY (target.numUserIDs()); + + // Create the job + auto job = openpgp()->signKeyJob(); + QVERIFY (job); + + // Hack in the passphrase provider + auto jobCtx = Job::context(job); + TestPassphraseProvider provider; + jobCtx->setPassphraseProvider(&provider); + jobCtx->setPinentryMode(Context::PinentryLoopback); + + // Setup the job + job->setExportable(true); + std::vector<unsigned int> uids; + uids.push_back(0); + job->setUserIDsToSign(uids); + job->setSigningKey(seckey); + job->setRemark(QStringLiteral("The quick brown fox jumps over the lazy dog")); + + connect(job, &SignKeyJob::result, this, [this] (const GpgME::Error &err2, + const QString, + const GpgME::Error) { + Q_EMIT asyncDone(); + QVERIFY(!err2); + }); + + job->start(target); + QSignalSpy spy (this, SIGNAL(asyncDone())); + QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); + + // At this point the remark should have been added. + target.update(); + const char *remark = target.userID(0).remark(seckey, err); + QVERIFY(!err); + Q_ASSERT(remark); + QCOMPARE(QString::fromUtf8(remark), QStringLiteral("The quick brown fox " + "jumps over the lazy dog")); + + // Now replace the remark + auto job3 = openpgp()->signKeyJob(); + QVERIFY (job3); + + // Hack in the passphrase provider + auto jobCtx3 = Job::context(job3); + jobCtx3->setPassphraseProvider(&provider); + jobCtx3->setPinentryMode(Context::PinentryLoopback); + + // Setup the job + job3->setExportable(false); + job3->setUserIDsToSign(uids); + job3->setSigningKey(seckey); + job3->setDupeOk(true); + job3->setRemark(QStringLiteral("The quick brown fox fails to jump over Frodo")); + + connect(job3, &SignKeyJob::result, this, [this] (const GpgME::Error &err2, + const QString, + const GpgME::Error) { + Q_EMIT asyncDone(); + QVERIFY(!err2); + }); + + job3->start(target); + QVERIFY(spy.wait(QSIGNALSPY_TIMEOUT)); + + target.update(); + remark = target.userID(0).remark(seckey, err); + QVERIFY(!err); + QVERIFY(remark); + QCOMPARE(QString::fromUtf8(remark), QStringLiteral("The quick brown fox fails " + "to jump over Frodo")); + } + + void testMultipleRemarks() { // Get the signing key1 (alfa) |