qt: Clean up test dirs on failure
* t-encrypt.cpp, t-keylist.cpp, t-keylocate.cpp, t-ownertrust.cpp, t-tofuinfo.cpp, t-various.cpp, t-verify.cpp, t-wkspublish.cpp: Use QVERIFY instead of Q_ASSERT
This commit is contained in:
parent
9e643ab671
commit
56926c9b50
@ -85,18 +85,18 @@ private Q_SLOTS:
|
|||||||
std::vector<Key> keys;
|
std::vector<Key> keys;
|
||||||
auto keylistresult = listjob->exec(QStringList() << QStringLiteral("alfa@example.net"),
|
auto keylistresult = listjob->exec(QStringList() << QStringLiteral("alfa@example.net"),
|
||||||
false, keys);
|
false, keys);
|
||||||
Q_ASSERT(!keylistresult.error());
|
QVERIFY(!keylistresult.error());
|
||||||
Q_ASSERT(keys.size() == 1);
|
QVERIFY(keys.size() == 1);
|
||||||
delete listjob;
|
delete listjob;
|
||||||
|
|
||||||
auto job = openpgp()->encryptJob(/*ASCII Armor */true, /* Textmode */ true);
|
auto job = openpgp()->encryptJob(/*ASCII Armor */true, /* Textmode */ true);
|
||||||
Q_ASSERT(job);
|
QVERIFY(job);
|
||||||
QByteArray cipherText;
|
QByteArray cipherText;
|
||||||
auto result = job->exec(keys, QStringLiteral("Hello World").toUtf8(), Context::AlwaysTrust, cipherText);
|
auto result = job->exec(keys, QStringLiteral("Hello World").toUtf8(), Context::AlwaysTrust, cipherText);
|
||||||
delete job;
|
delete job;
|
||||||
Q_ASSERT(!result.error());
|
QVERIFY(!result.error());
|
||||||
const auto cipherString = QString::fromUtf8(cipherText);
|
const auto cipherString = QString::fromUtf8(cipherText);
|
||||||
Q_ASSERT(cipherString.startsWith("-----BEGIN PGP MESSAGE-----"));
|
QVERIFY(cipherString.startsWith("-----BEGIN PGP MESSAGE-----"));
|
||||||
|
|
||||||
/* Now decrypt */
|
/* Now decrypt */
|
||||||
if (!decryptSupported()) {
|
if (!decryptSupported()) {
|
||||||
@ -109,8 +109,8 @@ private Q_SLOTS:
|
|||||||
auto decJob = new QGpgMEDecryptJob(ctx);
|
auto decJob = new QGpgMEDecryptJob(ctx);
|
||||||
QByteArray plainText;
|
QByteArray plainText;
|
||||||
auto decResult = decJob->exec(cipherText, plainText);
|
auto decResult = decJob->exec(cipherText, plainText);
|
||||||
Q_ASSERT(!result.error());
|
QVERIFY(!result.error());
|
||||||
Q_ASSERT(QString::fromUtf8(plainText) == QStringLiteral("Hello World"));
|
QVERIFY(QString::fromUtf8(plainText) == QStringLiteral("Hello World"));
|
||||||
delete decJob;
|
delete decJob;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,12 +125,12 @@ private Q_SLOTS:
|
|||||||
std::vector<Key> keys;
|
std::vector<Key> keys;
|
||||||
auto keylistresult = listjob->exec(QStringList() << QStringLiteral("alfa@example.net"),
|
auto keylistresult = listjob->exec(QStringList() << QStringLiteral("alfa@example.net"),
|
||||||
false, keys);
|
false, keys);
|
||||||
Q_ASSERT(!keylistresult.error());
|
QVERIFY(!keylistresult.error());
|
||||||
Q_ASSERT(keys.size() == 1);
|
QVERIFY(keys.size() == 1);
|
||||||
delete listjob;
|
delete listjob;
|
||||||
|
|
||||||
auto job = openpgp()->encryptJob(/*ASCII Armor */false, /* Textmode */ false);
|
auto job = openpgp()->encryptJob(/*ASCII Armor */false, /* Textmode */ false);
|
||||||
Q_ASSERT(job);
|
QVERIFY(job);
|
||||||
QByteArray plainBa;
|
QByteArray plainBa;
|
||||||
plainBa.fill('X', PROGRESS_TEST_SIZE);
|
plainBa.fill('X', PROGRESS_TEST_SIZE);
|
||||||
QByteArray cipherText;
|
QByteArray cipherText;
|
||||||
@ -140,21 +140,21 @@ private Q_SLOTS:
|
|||||||
connect(job, &Job::progress, this, [this, &initSeen, &finishSeen] (const QString&, int current, int total) {
|
connect(job, &Job::progress, this, [this, &initSeen, &finishSeen] (const QString&, int current, int total) {
|
||||||
// We only check for progress 0 and max progress as the other progress
|
// We only check for progress 0 and max progress as the other progress
|
||||||
// lines depend on the system speed and are as such unreliable to test.
|
// lines depend on the system speed and are as such unreliable to test.
|
||||||
Q_ASSERT(total == PROGRESS_TEST_SIZE);
|
QVERIFY(total == PROGRESS_TEST_SIZE);
|
||||||
if (current == 0) {
|
if (current == 0) {
|
||||||
initSeen = true;
|
initSeen = true;
|
||||||
}
|
}
|
||||||
if (current == total) {
|
if (current == total) {
|
||||||
finishSeen = true;
|
finishSeen = true;
|
||||||
}
|
}
|
||||||
Q_ASSERT(current >= 0 && current <= total);
|
QVERIFY(current >= 0 && current <= total);
|
||||||
});
|
});
|
||||||
connect(job, &EncryptJob::result, this, [this, &initSeen, &finishSeen] (const GpgME::EncryptionResult &,
|
connect(job, &EncryptJob::result, this, [this, &initSeen, &finishSeen] (const GpgME::EncryptionResult &,
|
||||||
const QByteArray &,
|
const QByteArray &,
|
||||||
const QString,
|
const QString,
|
||||||
const GpgME::Error) {
|
const GpgME::Error) {
|
||||||
Q_ASSERT(initSeen);
|
QVERIFY(initSeen);
|
||||||
Q_ASSERT(finishSeen);
|
QVERIFY(finishSeen);
|
||||||
Q_EMIT asyncDone();
|
Q_EMIT asyncDone();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ private Q_SLOTS:
|
|||||||
|
|
||||||
job->start(keys, inptr, outptr, Context::AlwaysTrust);
|
job->start(keys, inptr, outptr, Context::AlwaysTrust);
|
||||||
QSignalSpy spy (this, SIGNAL(asyncDone()));
|
QSignalSpy spy (this, SIGNAL(asyncDone()));
|
||||||
Q_ASSERT(spy.wait());
|
QVERIFY(spy.wait());
|
||||||
}
|
}
|
||||||
|
|
||||||
void testSymmetricEncryptDecrypt()
|
void testSymmetricEncryptDecrypt()
|
||||||
@ -183,9 +183,9 @@ private Q_SLOTS:
|
|||||||
QByteArray cipherText;
|
QByteArray cipherText;
|
||||||
auto result = job->exec(std::vector<Key>(), QStringLiteral("Hello symmetric World").toUtf8(), Context::AlwaysTrust, cipherText);
|
auto result = job->exec(std::vector<Key>(), QStringLiteral("Hello symmetric World").toUtf8(), Context::AlwaysTrust, cipherText);
|
||||||
delete job;
|
delete job;
|
||||||
Q_ASSERT(!result.error());
|
QVERIFY(!result.error());
|
||||||
const auto cipherString = QString::fromUtf8(cipherText);
|
const auto cipherString = QString::fromUtf8(cipherText);
|
||||||
Q_ASSERT(cipherString.startsWith("-----BEGIN PGP MESSAGE-----"));
|
QVERIFY(cipherString.startsWith("-----BEGIN PGP MESSAGE-----"));
|
||||||
|
|
||||||
killAgent(mDir.path());
|
killAgent(mDir.path());
|
||||||
|
|
||||||
@ -195,8 +195,8 @@ private Q_SLOTS:
|
|||||||
auto decJob = new QGpgMEDecryptJob(ctx2);
|
auto decJob = new QGpgMEDecryptJob(ctx2);
|
||||||
QByteArray plainText;
|
QByteArray plainText;
|
||||||
auto decResult = decJob->exec(cipherText, plainText);
|
auto decResult = decJob->exec(cipherText, plainText);
|
||||||
Q_ASSERT(!result.error());
|
QVERIFY(!result.error());
|
||||||
Q_ASSERT(QString::fromUtf8(plainText) == QStringLiteral("Hello symmetric World"));
|
QVERIFY(QString::fromUtf8(plainText) == QStringLiteral("Hello symmetric World"));
|
||||||
delete decJob;
|
delete decJob;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,8 +212,8 @@ private:
|
|||||||
std::vector<Key> keys;
|
std::vector<Key> keys;
|
||||||
auto keylistresult = listjob->exec(QStringList() << QStringLiteral("alfa@example.net"),
|
auto keylistresult = listjob->exec(QStringList() << QStringLiteral("alfa@example.net"),
|
||||||
false, keys);
|
false, keys);
|
||||||
Q_ASSERT(!keylistresult.error());
|
QVERIFY(!keylistresult.error());
|
||||||
Q_ASSERT(keys.size() == 1);
|
QVERIFY(keys.size() == 1);
|
||||||
delete listjob;
|
delete listjob;
|
||||||
|
|
||||||
auto ctx = Context::createForProtocol(OpenPGP);
|
auto ctx = Context::createForProtocol(OpenPGP);
|
||||||
@ -229,10 +229,10 @@ private:
|
|||||||
cipherText);
|
cipherText);
|
||||||
printf("After exec\n");
|
printf("After exec\n");
|
||||||
delete job;
|
delete job;
|
||||||
Q_ASSERT(!result.error());
|
QVERIFY(!result.error());
|
||||||
printf("Cipher:\n%s\n", cipherText.constData());
|
printf("Cipher:\n%s\n", cipherText.constData());
|
||||||
const auto cipherString = QString::fromUtf8(cipherText);
|
const auto cipherString = QString::fromUtf8(cipherText);
|
||||||
Q_ASSERT(cipherString.startsWith("-----BEGIN PGP MESSAGE-----"));
|
QVERIFY(cipherString.startsWith("-----BEGIN PGP MESSAGE-----"));
|
||||||
|
|
||||||
killAgent(mDir.path());
|
killAgent(mDir.path());
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ private:
|
|||||||
QTemporaryDir tmp;
|
QTemporaryDir tmp;
|
||||||
qputenv("GNUPGHOME", tmp.path().toUtf8());
|
qputenv("GNUPGHOME", tmp.path().toUtf8());
|
||||||
QFile agentConf(tmp.path() + QStringLiteral("/gpg-agent.conf"));
|
QFile agentConf(tmp.path() + QStringLiteral("/gpg-agent.conf"));
|
||||||
Q_ASSERT(agentConf.open(QIODevice::WriteOnly));
|
QVERIFY(agentConf.open(QIODevice::WriteOnly));
|
||||||
agentConf.write("allow-loopback-pinentry");
|
agentConf.write("allow-loopback-pinentry");
|
||||||
agentConf.close();
|
agentConf.close();
|
||||||
|
|
||||||
@ -251,9 +251,9 @@ private:
|
|||||||
auto decJob = new QGpgMEDecryptJob(ctx2);
|
auto decJob = new QGpgMEDecryptJob(ctx2);
|
||||||
QByteArray plainText;
|
QByteArray plainText;
|
||||||
auto decResult = decJob->exec(cipherText, plainText);
|
auto decResult = decJob->exec(cipherText, plainText);
|
||||||
Q_ASSERT(!decResult.error());
|
QVERIFY(!decResult.error());
|
||||||
qDebug() << "Plain: " << plainText;
|
qDebug() << "Plain: " << plainText;
|
||||||
Q_ASSERT(QString::fromUtf8(plainText) == QStringLiteral("Hello symmetric World"));
|
QVERIFY(QString::fromUtf8(plainText) == QStringLiteral("Hello symmetric World"));
|
||||||
delete decJob;
|
delete decJob;
|
||||||
|
|
||||||
killAgent(tmp.path());
|
killAgent(tmp.path());
|
||||||
@ -267,12 +267,12 @@ public Q_SLOT:
|
|||||||
QGpgMETest::initTestCase();
|
QGpgMETest::initTestCase();
|
||||||
const QString gpgHome = qgetenv("GNUPGHOME");
|
const QString gpgHome = qgetenv("GNUPGHOME");
|
||||||
qputenv("GNUPGHOME", mDir.path().toUtf8());
|
qputenv("GNUPGHOME", mDir.path().toUtf8());
|
||||||
Q_ASSERT(mDir.isValid());
|
QVERIFY(mDir.isValid());
|
||||||
QFile agentConf(mDir.path() + QStringLiteral("/gpg-agent.conf"));
|
QFile agentConf(mDir.path() + QStringLiteral("/gpg-agent.conf"));
|
||||||
Q_ASSERT(agentConf.open(QIODevice::WriteOnly));
|
QVERIFY(agentConf.open(QIODevice::WriteOnly));
|
||||||
agentConf.write("allow-loopback-pinentry");
|
agentConf.write("allow-loopback-pinentry");
|
||||||
agentConf.close();
|
agentConf.close();
|
||||||
Q_ASSERT(copyKeyrings(gpgHome, mDir.path()));
|
QVERIFY(copyKeyrings(gpgHome, mDir.path()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -61,14 +61,14 @@ private Q_SLOTS:
|
|||||||
GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
|
GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
|
||||||
false, keys);
|
false, keys);
|
||||||
delete job;
|
delete job;
|
||||||
Q_ASSERT (!result.error());
|
QVERIFY (!result.error());
|
||||||
Q_ASSERT (keys.size() == 1);
|
QVERIFY (keys.size() == 1);
|
||||||
const QString kId = QLatin1String(keys.front().keyID());
|
const QString kId = QLatin1String(keys.front().keyID());
|
||||||
Q_ASSERT (kId == QStringLiteral("2D727CC768697734"));
|
QVERIFY (kId == QStringLiteral("2D727CC768697734"));
|
||||||
|
|
||||||
Q_ASSERT (keys[0].subkeys().size() == 2);
|
QVERIFY (keys[0].subkeys().size() == 2);
|
||||||
Q_ASSERT (keys[0].subkeys()[0].publicKeyAlgorithm() == Subkey::AlgoDSA);
|
QVERIFY (keys[0].subkeys()[0].publicKeyAlgorithm() == Subkey::AlgoDSA);
|
||||||
Q_ASSERT (keys[0].subkeys()[1].publicKeyAlgorithm() == Subkey::AlgoELG_E);
|
QVERIFY (keys[0].subkeys()[1].publicKeyAlgorithm() == Subkey::AlgoELG_E);
|
||||||
}
|
}
|
||||||
|
|
||||||
void testPubkeyAlgoAsString()
|
void testPubkeyAlgoAsString()
|
||||||
@ -87,7 +87,7 @@ private Q_SLOTS:
|
|||||||
{ Subkey::AlgoUnknown, QString() }
|
{ Subkey::AlgoUnknown, QString() }
|
||||||
};
|
};
|
||||||
Q_FOREACH (Subkey::PubkeyAlgo algo, expected.keys()) {
|
Q_FOREACH (Subkey::PubkeyAlgo algo, expected.keys()) {
|
||||||
Q_ASSERT(QString::fromUtf8(Subkey::publicKeyAlgorithmAsString(algo)) ==
|
QVERIFY(QString::fromUtf8(Subkey::publicKeyAlgorithmAsString(algo)) ==
|
||||||
expected.value(algo));
|
expected.value(algo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,12 +97,12 @@ private Q_SLOTS:
|
|||||||
KeyListJob *job = openpgp()->keyListJob();
|
KeyListJob *job = openpgp()->keyListJob();
|
||||||
connect(job, &KeyListJob::result, job, [this, job](KeyListResult, std::vector<Key> keys, QString, Error)
|
connect(job, &KeyListJob::result, job, [this, job](KeyListResult, std::vector<Key> keys, QString, Error)
|
||||||
{
|
{
|
||||||
Q_ASSERT(keys.size() == 1);
|
QVERIFY(keys.size() == 1);
|
||||||
Q_EMIT asyncDone();
|
Q_EMIT asyncDone();
|
||||||
});
|
});
|
||||||
job->start(QStringList() << "alfa@example.net");
|
job->start(QStringList() << "alfa@example.net");
|
||||||
QSignalSpy spy (this, SIGNAL(asyncDone()));
|
QSignalSpy spy (this, SIGNAL(asyncDone()));
|
||||||
Q_ASSERT(spy.wait());
|
QVERIFY(spy.wait());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ private Q_SLOTS:
|
|||||||
qputenv("GNUPGHOME", dir.path().toUtf8());
|
qputenv("GNUPGHOME", dir.path().toUtf8());
|
||||||
/* Could do this with gpgconf but this is not a gpgconf test ;-) */
|
/* Could do this with gpgconf but this is not a gpgconf test ;-) */
|
||||||
QFile conf(dir.path() + QStringLiteral("/gpg.conf"));
|
QFile conf(dir.path() + QStringLiteral("/gpg.conf"));
|
||||||
Q_ASSERT(conf.open(QIODevice::WriteOnly));
|
QVERIFY(conf.open(QIODevice::WriteOnly));
|
||||||
conf.write("auto-key-locate dane");
|
conf.write("auto-key-locate dane");
|
||||||
conf.close();
|
conf.close();
|
||||||
|
|
||||||
@ -71,11 +71,11 @@ private Q_SLOTS:
|
|||||||
mTestpattern = QStringLiteral("wk@gnupg.org");
|
mTestpattern = QStringLiteral("wk@gnupg.org");
|
||||||
connect(job, &KeyListJob::result, job, [this, job](KeyListResult result, std::vector<Key> keys, QString, Error)
|
connect(job, &KeyListJob::result, job, [this, job](KeyListResult result, std::vector<Key> keys, QString, Error)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!result.error());
|
QVERIFY(!result.error());
|
||||||
Q_ASSERT(keys.size() == 1);
|
QVERIFY(keys.size() == 1);
|
||||||
|
|
||||||
Key k = keys.front();
|
Key k = keys.front();
|
||||||
Q_ASSERT(k.numUserIDs());
|
QVERIFY(k.numUserIDs());
|
||||||
bool found = false;
|
bool found = false;
|
||||||
Q_FOREACH (const UserID uid, k.userIDs()) {
|
Q_FOREACH (const UserID uid, k.userIDs()) {
|
||||||
const QString mailBox = QString::fromUtf8(uid.email());
|
const QString mailBox = QString::fromUtf8(uid.email());
|
||||||
@ -83,12 +83,12 @@ private Q_SLOTS:
|
|||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Q_ASSERT(found);
|
QVERIFY(found);
|
||||||
Q_EMIT asyncDone();
|
Q_EMIT asyncDone();
|
||||||
});
|
});
|
||||||
job->start(QStringList() << mTestpattern);
|
job->start(QStringList() << mTestpattern);
|
||||||
QSignalSpy spy (this, SIGNAL(asyncDone()));
|
QSignalSpy spy (this, SIGNAL(asyncDone()));
|
||||||
Q_ASSERT(spy.wait());
|
QVERIFY(spy.wait());
|
||||||
qputenv("GNUPGHOME", oldHome.toUtf8());
|
qputenv("GNUPGHOME", oldHome.toUtf8());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -103,13 +103,13 @@ private Q_SLOTS:
|
|||||||
|
|
||||||
connect(job, &KeyListJob::result, job, [this, job](KeyListResult result, std::vector<Key> keys, QString, Error)
|
connect(job, &KeyListJob::result, job, [this, job](KeyListResult result, std::vector<Key> keys, QString, Error)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!result.isNull());
|
QVERIFY(!result.isNull());
|
||||||
Q_ASSERT(!result.isTruncated());
|
QVERIFY(!result.isTruncated());
|
||||||
Q_ASSERT(!result.error());
|
QVERIFY(!result.error());
|
||||||
Q_ASSERT(keys.size() == 1);
|
QVERIFY(keys.size() == 1);
|
||||||
|
|
||||||
Key k = keys.front();
|
Key k = keys.front();
|
||||||
Q_ASSERT(k.numUserIDs());
|
QVERIFY(k.numUserIDs());
|
||||||
bool found = false;
|
bool found = false;
|
||||||
Q_FOREACH (const UserID uid, k.userIDs()) {
|
Q_FOREACH (const UserID uid, k.userIDs()) {
|
||||||
const QString mailBox = QString::fromUtf8(uid.email());
|
const QString mailBox = QString::fromUtf8(uid.email());
|
||||||
@ -117,12 +117,12 @@ private Q_SLOTS:
|
|||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Q_ASSERT(found);
|
QVERIFY(found);
|
||||||
Q_EMIT asyncDone();
|
Q_EMIT asyncDone();
|
||||||
});
|
});
|
||||||
job->start(QStringList() << mTestpattern);
|
job->start(QStringList() << mTestpattern);
|
||||||
QSignalSpy spy (this, SIGNAL(asyncDone()));
|
QSignalSpy spy (this, SIGNAL(asyncDone()));
|
||||||
Q_ASSERT(spy.wait());
|
QVERIFY(spy.wait());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -62,10 +62,10 @@ private Q_SLOTS:
|
|||||||
GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
|
GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
|
||||||
false, keys);
|
false, keys);
|
||||||
delete job;
|
delete job;
|
||||||
Q_ASSERT (!result.error());
|
QVERIFY (!result.error());
|
||||||
Q_ASSERT (keys.size() == 1);
|
QVERIFY (keys.size() == 1);
|
||||||
Key key = keys.front();
|
Key key = keys.front();
|
||||||
Q_ASSERT (key.ownerTrust() == Key::Unknown);
|
QVERIFY (key.ownerTrust() == Key::Unknown);
|
||||||
|
|
||||||
ChangeOwnerTrustJob *job2 = openpgp()->changeOwnerTrustJob();
|
ChangeOwnerTrustJob *job2 = openpgp()->changeOwnerTrustJob();
|
||||||
connect(job2, &ChangeOwnerTrustJob::result, this, [this](Error e)
|
connect(job2, &ChangeOwnerTrustJob::result, this, [this](Error e)
|
||||||
@ -73,28 +73,28 @@ private Q_SLOTS:
|
|||||||
if (e) {
|
if (e) {
|
||||||
qDebug() << "Error in result: " << e.asString();
|
qDebug() << "Error in result: " << e.asString();
|
||||||
}
|
}
|
||||||
Q_ASSERT(!e);
|
QVERIFY(!e);
|
||||||
Q_EMIT asyncDone();
|
Q_EMIT asyncDone();
|
||||||
});
|
});
|
||||||
job2->start(key, Key::Ultimate);
|
job2->start(key, Key::Ultimate);
|
||||||
QSignalSpy spy (this, SIGNAL(asyncDone()));
|
QSignalSpy spy (this, SIGNAL(asyncDone()));
|
||||||
Q_ASSERT(spy.wait());
|
QVERIFY(spy.wait());
|
||||||
|
|
||||||
job = openpgp()->keyListJob(false, true, true);
|
job = openpgp()->keyListJob(false, true, true);
|
||||||
result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
|
result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
|
||||||
false, keys);
|
false, keys);
|
||||||
delete job;
|
delete job;
|
||||||
key = keys.front();
|
key = keys.front();
|
||||||
Q_ASSERT (key.ownerTrust() == Key::Ultimate);
|
QVERIFY (key.ownerTrust() == Key::Ultimate);
|
||||||
|
|
||||||
ChangeOwnerTrustJob *job3 = openpgp()->changeOwnerTrustJob();
|
ChangeOwnerTrustJob *job3 = openpgp()->changeOwnerTrustJob();
|
||||||
connect(job3, &ChangeOwnerTrustJob::result, this, [this](Error e)
|
connect(job3, &ChangeOwnerTrustJob::result, this, [this](Error e)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!e);
|
QVERIFY(!e);
|
||||||
Q_EMIT asyncDone();
|
Q_EMIT asyncDone();
|
||||||
});
|
});
|
||||||
job3->start(key, Key::Unknown);
|
job3->start(key, Key::Unknown);
|
||||||
Q_ASSERT(spy.wait());
|
QVERIFY(spy.wait());
|
||||||
|
|
||||||
job = openpgp()->keyListJob(false, true, true);
|
job = openpgp()->keyListJob(false, true, true);
|
||||||
result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
|
result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
|
||||||
@ -102,7 +102,7 @@ private Q_SLOTS:
|
|||||||
delete job;
|
delete job;
|
||||||
|
|
||||||
key = keys.front();
|
key = keys.front();
|
||||||
Q_ASSERT (key.ownerTrust() == Key::Unknown);
|
QVERIFY (key.ownerTrust() == Key::Unknown);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -72,12 +72,12 @@ class TofuInfoTest: public QGpgMETest
|
|||||||
|
|
||||||
void testTofuCopy(TofuInfo other, const TofuInfo &orig)
|
void testTofuCopy(TofuInfo other, const TofuInfo &orig)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!orig.isNull());
|
QVERIFY(!orig.isNull());
|
||||||
Q_ASSERT(!other.isNull());
|
QVERIFY(!other.isNull());
|
||||||
Q_ASSERT(orig.signLast() == other.signLast());
|
QVERIFY(orig.signLast() == other.signLast());
|
||||||
Q_ASSERT(orig.signCount() == other.signCount());
|
QVERIFY(orig.signCount() == other.signCount());
|
||||||
Q_ASSERT(orig.validity() == other.validity());
|
QVERIFY(orig.validity() == other.validity());
|
||||||
Q_ASSERT(orig.policy() == other.policy());
|
QVERIFY(orig.policy() == other.policy());
|
||||||
}
|
}
|
||||||
|
|
||||||
void signAndVerify(const QString &what, const GpgME::Key &key, int expected)
|
void signAndVerify(const QString &what, const GpgME::Key &key, int expected)
|
||||||
@ -94,10 +94,10 @@ class TofuInfoTest: public QGpgMETest
|
|||||||
auto sigResult = job->exec(keys, what.toUtf8(), NormalSignatureMode, signedData);
|
auto sigResult = job->exec(keys, what.toUtf8(), NormalSignatureMode, signedData);
|
||||||
delete job;
|
delete job;
|
||||||
|
|
||||||
Q_ASSERT(!sigResult.error());
|
QVERIFY(!sigResult.error());
|
||||||
foreach (const auto uid, keys[0].userIDs()) {
|
foreach (const auto uid, keys[0].userIDs()) {
|
||||||
auto info = uid.tofuInfo();
|
auto info = uid.tofuInfo();
|
||||||
Q_ASSERT(info.signCount() == expected - 1);
|
QVERIFY(info.signCount() == expected - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto verifyJob = openpgp()->verifyOpaqueJob();
|
auto verifyJob = openpgp()->verifyOpaqueJob();
|
||||||
@ -106,25 +106,25 @@ class TofuInfoTest: public QGpgMETest
|
|||||||
auto result = verifyJob->exec(signedData, verified);
|
auto result = verifyJob->exec(signedData, verified);
|
||||||
delete verifyJob;
|
delete verifyJob;
|
||||||
|
|
||||||
Q_ASSERT(!result.error());
|
QVERIFY(!result.error());
|
||||||
Q_ASSERT(verified == what.toUtf8());
|
QVERIFY(verified == what.toUtf8());
|
||||||
|
|
||||||
Q_ASSERT(result.numSignatures() == 1);
|
QVERIFY(result.numSignatures() == 1);
|
||||||
auto sig = result.signatures()[0];
|
auto sig = result.signatures()[0];
|
||||||
|
|
||||||
auto key2 = sig.key();
|
auto key2 = sig.key();
|
||||||
Q_ASSERT(!key.isNull());
|
QVERIFY(!key.isNull());
|
||||||
Q_ASSERT(!strcmp (key2.primaryFingerprint(), key.primaryFingerprint()));
|
QVERIFY(!strcmp (key2.primaryFingerprint(), key.primaryFingerprint()));
|
||||||
Q_ASSERT(!strcmp (key.primaryFingerprint(), sig.fingerprint()));
|
QVERIFY(!strcmp (key.primaryFingerprint(), sig.fingerprint()));
|
||||||
auto stats = key2.userID(0).tofuInfo();
|
auto stats = key2.userID(0).tofuInfo();
|
||||||
Q_ASSERT(!stats.isNull());
|
QVERIFY(!stats.isNull());
|
||||||
if (stats.signCount() != expected) {
|
if (stats.signCount() != expected) {
|
||||||
std::cout << "################ Key before verify: "
|
std::cout << "################ Key before verify: "
|
||||||
<< key
|
<< key
|
||||||
<< "################ Key after verify: "
|
<< "################ Key after verify: "
|
||||||
<< key2;
|
<< key2;
|
||||||
}
|
}
|
||||||
Q_ASSERT(stats.signCount() == expected);
|
QVERIFY(stats.signCount() == expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
@ -134,13 +134,13 @@ private Q_SLOTS:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TofuInfo tofu;
|
TofuInfo tofu;
|
||||||
Q_ASSERT(tofu.isNull());
|
QVERIFY(tofu.isNull());
|
||||||
Q_ASSERT(!tofu.description());
|
QVERIFY(!tofu.description());
|
||||||
Q_ASSERT(!tofu.signCount());
|
QVERIFY(!tofu.signCount());
|
||||||
Q_ASSERT(!tofu.signLast());
|
QVERIFY(!tofu.signLast());
|
||||||
Q_ASSERT(!tofu.signFirst());
|
QVERIFY(!tofu.signFirst());
|
||||||
Q_ASSERT(tofu.validity() == TofuInfo::ValidityUnknown);
|
QVERIFY(tofu.validity() == TofuInfo::ValidityUnknown);
|
||||||
Q_ASSERT(tofu.policy() == TofuInfo::PolicyUnknown);
|
QVERIFY(tofu.policy() == TofuInfo::PolicyUnknown);
|
||||||
}
|
}
|
||||||
|
|
||||||
void testTofuInfo()
|
void testTofuInfo()
|
||||||
@ -153,30 +153,30 @@ private Q_SLOTS:
|
|||||||
QByteArray plaintext;
|
QByteArray plaintext;
|
||||||
|
|
||||||
auto ctx = Job::context(job);
|
auto ctx = Job::context(job);
|
||||||
Q_ASSERT(ctx);
|
QVERIFY(ctx);
|
||||||
ctx->setSender("alfa@example.net");
|
ctx->setSender("alfa@example.net");
|
||||||
|
|
||||||
auto result = job->exec(data1, plaintext);
|
auto result = job->exec(data1, plaintext);
|
||||||
delete job;
|
delete job;
|
||||||
|
|
||||||
Q_ASSERT(!result.isNull());
|
QVERIFY(!result.isNull());
|
||||||
Q_ASSERT(!result.error());
|
QVERIFY(!result.error());
|
||||||
Q_ASSERT(!strcmp(plaintext.constData(), "Just GNU it!\n"));
|
QVERIFY(!strcmp(plaintext.constData(), "Just GNU it!\n"));
|
||||||
|
|
||||||
Q_ASSERT(result.numSignatures() == 1);
|
QVERIFY(result.numSignatures() == 1);
|
||||||
Signature sig = result.signatures()[0];
|
Signature sig = result.signatures()[0];
|
||||||
/* TOFU is always marginal */
|
/* TOFU is always marginal */
|
||||||
Q_ASSERT(sig.validity() == Signature::Marginal);
|
QVERIFY(sig.validity() == Signature::Marginal);
|
||||||
|
|
||||||
auto stats = sig.key().userID(0).tofuInfo();
|
auto stats = sig.key().userID(0).tofuInfo();
|
||||||
Q_ASSERT(!stats.isNull());
|
QVERIFY(!stats.isNull());
|
||||||
Q_ASSERT(sig.key().primaryFingerprint());
|
QVERIFY(sig.key().primaryFingerprint());
|
||||||
Q_ASSERT(sig.fingerprint());
|
QVERIFY(sig.fingerprint());
|
||||||
Q_ASSERT(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint()));
|
QVERIFY(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint()));
|
||||||
Q_ASSERT(stats.signFirst() == stats.signLast());
|
QVERIFY(stats.signFirst() == stats.signLast());
|
||||||
Q_ASSERT(stats.signCount() == 1);
|
QVERIFY(stats.signCount() == 1);
|
||||||
Q_ASSERT(stats.policy() == TofuInfo::PolicyAuto);
|
QVERIFY(stats.policy() == TofuInfo::PolicyAuto);
|
||||||
Q_ASSERT(stats.validity() == TofuInfo::LittleHistory);
|
QVERIFY(stats.validity() == TofuInfo::LittleHistory);
|
||||||
|
|
||||||
testTofuCopy(stats, stats);
|
testTofuCopy(stats, stats);
|
||||||
|
|
||||||
@ -186,42 +186,42 @@ private Q_SLOTS:
|
|||||||
result = job->exec(data1, plaintext);
|
result = job->exec(data1, plaintext);
|
||||||
delete job;
|
delete job;
|
||||||
|
|
||||||
Q_ASSERT(!result.isNull());
|
QVERIFY(!result.isNull());
|
||||||
Q_ASSERT(!result.error());
|
QVERIFY(!result.error());
|
||||||
|
|
||||||
Q_ASSERT(result.numSignatures() == 1);
|
QVERIFY(result.numSignatures() == 1);
|
||||||
sig = result.signatures()[0];
|
sig = result.signatures()[0];
|
||||||
/* TOFU is always marginal */
|
/* TOFU is always marginal */
|
||||||
Q_ASSERT(sig.validity() == Signature::Marginal);
|
QVERIFY(sig.validity() == Signature::Marginal);
|
||||||
|
|
||||||
stats = sig.key().userID(0).tofuInfo();
|
stats = sig.key().userID(0).tofuInfo();
|
||||||
Q_ASSERT(!stats.isNull());
|
QVERIFY(!stats.isNull());
|
||||||
Q_ASSERT(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint()));
|
QVERIFY(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint()));
|
||||||
Q_ASSERT(stats.signFirst() == stats.signLast());
|
QVERIFY(stats.signFirst() == stats.signLast());
|
||||||
Q_ASSERT(stats.signCount() == 1);
|
QVERIFY(stats.signCount() == 1);
|
||||||
Q_ASSERT(stats.policy() == TofuInfo::PolicyAuto);
|
QVERIFY(stats.policy() == TofuInfo::PolicyAuto);
|
||||||
Q_ASSERT(stats.validity() == TofuInfo::LittleHistory);
|
QVERIFY(stats.validity() == TofuInfo::LittleHistory);
|
||||||
|
|
||||||
/* Verify that another call yields the same result */
|
/* Verify that another call yields the same result */
|
||||||
job = openpgp()->verifyOpaqueJob(true);
|
job = openpgp()->verifyOpaqueJob(true);
|
||||||
result = job->exec(data1, plaintext);
|
result = job->exec(data1, plaintext);
|
||||||
delete job;
|
delete job;
|
||||||
|
|
||||||
Q_ASSERT(!result.isNull());
|
QVERIFY(!result.isNull());
|
||||||
Q_ASSERT(!result.error());
|
QVERIFY(!result.error());
|
||||||
|
|
||||||
Q_ASSERT(result.numSignatures() == 1);
|
QVERIFY(result.numSignatures() == 1);
|
||||||
sig = result.signatures()[0];
|
sig = result.signatures()[0];
|
||||||
/* TOFU is always marginal */
|
/* TOFU is always marginal */
|
||||||
Q_ASSERT(sig.validity() == Signature::Marginal);
|
QVERIFY(sig.validity() == Signature::Marginal);
|
||||||
|
|
||||||
stats = sig.key().userID(0).tofuInfo();
|
stats = sig.key().userID(0).tofuInfo();
|
||||||
Q_ASSERT(!stats.isNull());
|
QVERIFY(!stats.isNull());
|
||||||
Q_ASSERT(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint()));
|
QVERIFY(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint()));
|
||||||
Q_ASSERT(stats.signFirst() == stats.signLast());
|
QVERIFY(stats.signFirst() == stats.signLast());
|
||||||
Q_ASSERT(stats.signCount() == 1);
|
QVERIFY(stats.signCount() == 1);
|
||||||
Q_ASSERT(stats.policy() == TofuInfo::PolicyAuto);
|
QVERIFY(stats.policy() == TofuInfo::PolicyAuto);
|
||||||
Q_ASSERT(stats.validity() == TofuInfo::LittleHistory);
|
QVERIFY(stats.validity() == TofuInfo::LittleHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void testTofuSignCount()
|
void testTofuSignCount()
|
||||||
@ -235,9 +235,9 @@ private Q_SLOTS:
|
|||||||
GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("zulu@example.net"),
|
GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("zulu@example.net"),
|
||||||
true, keys);
|
true, keys);
|
||||||
delete job;
|
delete job;
|
||||||
Q_ASSERT(!keys.empty());
|
QVERIFY(!keys.empty());
|
||||||
Key key = keys[0];
|
Key key = keys[0];
|
||||||
Q_ASSERT(!key.isNull());
|
QVERIFY(!key.isNull());
|
||||||
|
|
||||||
/* As we sign & verify quickly here we need different
|
/* As we sign & verify quickly here we need different
|
||||||
* messages to avoid having them treated as the same
|
* messages to avoid having them treated as the same
|
||||||
@ -266,10 +266,10 @@ private Q_SLOTS:
|
|||||||
auto result = job->exec(QStringList() << QStringLiteral("zulu@example.net"),
|
auto result = job->exec(QStringList() << QStringLiteral("zulu@example.net"),
|
||||||
true, keys);
|
true, keys);
|
||||||
delete job;
|
delete job;
|
||||||
Q_ASSERT(!keys.empty());
|
QVERIFY(!keys.empty());
|
||||||
auto key = keys[0];
|
auto key = keys[0];
|
||||||
Q_ASSERT(!key.isNull());
|
QVERIFY(!key.isNull());
|
||||||
Q_ASSERT(key.userID(0).tofuInfo().isNull());
|
QVERIFY(key.userID(0).tofuInfo().isNull());
|
||||||
auto keyCopy = key;
|
auto keyCopy = key;
|
||||||
keyCopy.update();
|
keyCopy.update();
|
||||||
auto sigCnt = keyCopy.userID(0).tofuInfo().signCount();
|
auto sigCnt = keyCopy.userID(0).tofuInfo().signCount();
|
||||||
@ -285,13 +285,13 @@ private Q_SLOTS:
|
|||||||
result = job->exec(QStringList() << QStringLiteral("zulu@example.net"),
|
result = job->exec(QStringList() << QStringLiteral("zulu@example.net"),
|
||||||
true, keys);
|
true, keys);
|
||||||
delete job;
|
delete job;
|
||||||
Q_ASSERT(!result.error());
|
QVERIFY(!result.error());
|
||||||
Q_ASSERT(!keys.empty());
|
QVERIFY(!keys.empty());
|
||||||
auto key2 = keys[0];
|
auto key2 = keys[0];
|
||||||
Q_ASSERT(!key2.isNull());
|
QVERIFY(!key2.isNull());
|
||||||
auto info = key2.userID(0).tofuInfo();
|
auto info = key2.userID(0).tofuInfo();
|
||||||
Q_ASSERT(!info.isNull());
|
QVERIFY(!info.isNull());
|
||||||
Q_ASSERT(info.signCount());
|
QVERIFY(info.signCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
void testTofuPolicy()
|
void testTofuPolicy()
|
||||||
@ -326,25 +326,25 @@ private Q_SLOTS:
|
|||||||
<< ">\n fpr: " << key.primaryFingerprint();
|
<< ">\n fpr: " << key.primaryFingerprint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Q_ASSERT(!result.error());
|
QVERIFY(!result.error());
|
||||||
Q_ASSERT(!keys.empty());
|
QVERIFY(!keys.empty());
|
||||||
auto key = keys[0];
|
auto key = keys[0];
|
||||||
Q_ASSERT(!key.isNull());
|
QVERIFY(!key.isNull());
|
||||||
Q_ASSERT(key.userID(0).tofuInfo().policy() != TofuInfo::PolicyBad);
|
QVERIFY(key.userID(0).tofuInfo().policy() != TofuInfo::PolicyBad);
|
||||||
auto *tofuJob = openpgp()->tofuPolicyJob();
|
auto *tofuJob = openpgp()->tofuPolicyJob();
|
||||||
auto err = tofuJob->exec(key, TofuInfo::PolicyBad);
|
auto err = tofuJob->exec(key, TofuInfo::PolicyBad);
|
||||||
Q_ASSERT(!err);
|
QVERIFY(!err);
|
||||||
result = job->exec(QStringList() << QStringLiteral("bravo@example.net"),
|
result = job->exec(QStringList() << QStringLiteral("bravo@example.net"),
|
||||||
false, keys);
|
false, keys);
|
||||||
Q_ASSERT(!keys.empty());
|
QVERIFY(!keys.empty());
|
||||||
key = keys[0];
|
key = keys[0];
|
||||||
Q_ASSERT(key.userID(0).tofuInfo().policy() == TofuInfo::PolicyBad);
|
QVERIFY(key.userID(0).tofuInfo().policy() == TofuInfo::PolicyBad);
|
||||||
err = tofuJob->exec(key, TofuInfo::PolicyGood);
|
err = tofuJob->exec(key, TofuInfo::PolicyGood);
|
||||||
|
|
||||||
result = job->exec(QStringList() << QStringLiteral("bravo@example.net"),
|
result = job->exec(QStringList() << QStringLiteral("bravo@example.net"),
|
||||||
false, keys);
|
false, keys);
|
||||||
key = keys[0];
|
key = keys[0];
|
||||||
Q_ASSERT(key.userID(0).tofuInfo().policy() == TofuInfo::PolicyGood);
|
QVERIFY(key.userID(0).tofuInfo().policy() == TofuInfo::PolicyGood);
|
||||||
delete tofuJob;
|
delete tofuJob;
|
||||||
delete job;
|
delete job;
|
||||||
}
|
}
|
||||||
@ -354,16 +354,16 @@ private Q_SLOTS:
|
|||||||
QGpgMETest::initTestCase();
|
QGpgMETest::initTestCase();
|
||||||
const QString gpgHome = qgetenv("GNUPGHOME");
|
const QString gpgHome = qgetenv("GNUPGHOME");
|
||||||
qputenv("GNUPGHOME", mDir.path().toUtf8());
|
qputenv("GNUPGHOME", mDir.path().toUtf8());
|
||||||
Q_ASSERT(mDir.isValid());
|
QVERIFY(mDir.isValid());
|
||||||
QFile conf(mDir.path() + QStringLiteral("/gpg.conf"));
|
QFile conf(mDir.path() + QStringLiteral("/gpg.conf"));
|
||||||
Q_ASSERT(conf.open(QIODevice::WriteOnly));
|
QVERIFY(conf.open(QIODevice::WriteOnly));
|
||||||
conf.write("trust-model tofu+pgp");
|
conf.write("trust-model tofu+pgp");
|
||||||
conf.close();
|
conf.close();
|
||||||
QFile agentConf(mDir.path() + QStringLiteral("/gpg-agent.conf"));
|
QFile agentConf(mDir.path() + QStringLiteral("/gpg-agent.conf"));
|
||||||
Q_ASSERT(agentConf.open(QIODevice::WriteOnly));
|
QVERIFY(agentConf.open(QIODevice::WriteOnly));
|
||||||
agentConf.write("allow-loopback-pinentry");
|
agentConf.write("allow-loopback-pinentry");
|
||||||
agentConf.close();
|
agentConf.close();
|
||||||
Q_ASSERT(copyKeyrings(gpgHome, mDir.path()));
|
QVERIFY(copyKeyrings(gpgHome, mDir.path()));
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
QTemporaryDir mDir;
|
QTemporaryDir mDir;
|
||||||
|
@ -66,15 +66,15 @@ private Q_SLOTS:
|
|||||||
GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
|
GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("alfa@example.net"),
|
||||||
false, keys);
|
false, keys);
|
||||||
delete job;
|
delete job;
|
||||||
Q_ASSERT (!result.error());
|
QVERIFY (!result.error());
|
||||||
Q_ASSERT (keys.size() == 1);
|
QVERIFY (keys.size() == 1);
|
||||||
Key key = keys.front();
|
Key key = keys.front();
|
||||||
|
|
||||||
QVERIFY (key.numUserIDs() == 3);
|
QVERIFY (key.numUserIDs() == 3);
|
||||||
const char uid[] = "Foo Bar (with comment) <foo@bar.baz>";
|
const char uid[] = "Foo Bar (with comment) <foo@bar.baz>";
|
||||||
|
|
||||||
auto ctx = Context::createForProtocol(key.protocol());
|
auto ctx = Context::createForProtocol(key.protocol());
|
||||||
Q_ASSERT (ctx);
|
QVERIFY (ctx);
|
||||||
TestPassphraseProvider provider;
|
TestPassphraseProvider provider;
|
||||||
ctx->setPassphraseProvider(&provider);
|
ctx->setPassphraseProvider(&provider);
|
||||||
ctx->setPinentryMode(Context::PinentryLoopback);
|
ctx->setPinentryMode(Context::PinentryLoopback);
|
||||||
@ -106,14 +106,14 @@ private Q_SLOTS:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Q_ASSERT(id_revoked);
|
QVERIFY(id_revoked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initTestCase()
|
void initTestCase()
|
||||||
{
|
{
|
||||||
QGpgMETest::initTestCase();
|
QGpgMETest::initTestCase();
|
||||||
const QString gpgHome = qgetenv("GNUPGHOME");
|
const QString gpgHome = qgetenv("GNUPGHOME");
|
||||||
Q_ASSERT(copyKeyrings(gpgHome, mDir.path()));
|
QVERIFY(copyKeyrings(gpgHome, mDir.path()));
|
||||||
qputenv("GNUPGHOME", mDir.path().toUtf8());
|
qputenv("GNUPGHOME", mDir.path().toUtf8());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,14 +70,14 @@ private Q_SLOTS:
|
|||||||
QByteArray verified;
|
QByteArray verified;
|
||||||
|
|
||||||
auto result = verifyJob->exec(signedData, verified);
|
auto result = verifyJob->exec(signedData, verified);
|
||||||
Q_ASSERT(!result.error());
|
QVERIFY(!result.error());
|
||||||
delete verifyJob;
|
delete verifyJob;
|
||||||
|
|
||||||
Q_ASSERT(result.numSignatures() == 1);
|
QVERIFY(result.numSignatures() == 1);
|
||||||
auto sig = result.signatures()[0];
|
auto sig = result.signatures()[0];
|
||||||
|
|
||||||
const auto key = sig.key(true, false);
|
const auto key = sig.key(true, false);
|
||||||
Q_ASSERT(!key.isNull());
|
QVERIFY(!key.isNull());
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (const auto subkey: key.subkeys()) {
|
for (const auto subkey: key.subkeys()) {
|
||||||
@ -85,7 +85,7 @@ private Q_SLOTS:
|
|||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Q_ASSERT(found);
|
QVERIFY(found);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -127,12 +127,12 @@ private Q_SLOTS:
|
|||||||
auto job = openpgp()->wksPublishJob();
|
auto job = openpgp()->wksPublishJob();
|
||||||
connect(job, &WKSPublishJob::result, this,
|
connect(job, &WKSPublishJob::result, this,
|
||||||
[this] (Error err, QByteArray, QByteArray, QString, Error) {
|
[this] (Error err, QByteArray, QByteArray, QString, Error) {
|
||||||
Q_ASSERT(err);
|
QVERIFY(err);
|
||||||
Q_EMIT asyncDone();
|
Q_EMIT asyncDone();
|
||||||
});
|
});
|
||||||
job->startCheck ("testuser1@localhost");
|
job->startCheck ("testuser1@localhost");
|
||||||
QSignalSpy spy (this, SIGNAL(asyncDone()));
|
QSignalSpy spy (this, SIGNAL(asyncDone()));
|
||||||
Q_ASSERT(spy.wait());
|
QVERIFY(spy.wait());
|
||||||
}
|
}
|
||||||
#ifdef DO_ONLINE_TESTS
|
#ifdef DO_ONLINE_TESTS
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
@ -147,15 +147,15 @@ private:
|
|||||||
[this] (Error err, QByteArray, QByteArray, QString, Error) {
|
[this] (Error err, QByteArray, QByteArray, QString, Error) {
|
||||||
if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.0.16") {
|
if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.0.16") {
|
||||||
std::cout << err;
|
std::cout << err;
|
||||||
Q_ASSERT(err);
|
QVERIFY(err);
|
||||||
} else {
|
} else {
|
||||||
Q_ASSERT(!err);
|
QVERIFY(!err);
|
||||||
}
|
}
|
||||||
Q_EMIT asyncDone();
|
Q_EMIT asyncDone();
|
||||||
});
|
});
|
||||||
job->startCheck ("testuser1@test.gnupg.org");
|
job->startCheck ("testuser1@test.gnupg.org");
|
||||||
QSignalSpy spy (this, SIGNAL(asyncDone()));
|
QSignalSpy spy (this, SIGNAL(asyncDone()));
|
||||||
Q_ASSERT(spy.wait());
|
QVERIFY(spy.wait());
|
||||||
}
|
}
|
||||||
|
|
||||||
void testWKSPublishErrors() {
|
void testWKSPublishErrors() {
|
||||||
@ -166,13 +166,13 @@ private:
|
|||||||
auto job = openpgp()->wksPublishJob();
|
auto job = openpgp()->wksPublishJob();
|
||||||
connect(job, &WKSPublishJob::result, this,
|
connect(job, &WKSPublishJob::result, this,
|
||||||
[this] (Error err, QByteArray, QByteArray, QString, Error) {
|
[this] (Error err, QByteArray, QByteArray, QString, Error) {
|
||||||
Q_ASSERT(err);
|
QVERIFY(err);
|
||||||
Q_EMIT asyncDone();
|
Q_EMIT asyncDone();
|
||||||
});
|
});
|
||||||
job->startCreate("AB874F24E98EBB8487EE7B170F8E3D97FE7011B7",
|
job->startCreate("AB874F24E98EBB8487EE7B170F8E3D97FE7011B7",
|
||||||
QStringLiteral("Foo@bar.baz"));
|
QStringLiteral("Foo@bar.baz"));
|
||||||
QSignalSpy spy (this, SIGNAL(asyncDone()));
|
QSignalSpy spy (this, SIGNAL(asyncDone()));
|
||||||
Q_ASSERT(spy.wait());
|
QVERIFY(spy.wait());
|
||||||
}
|
}
|
||||||
|
|
||||||
void testWKSPublishCreate() {
|
void testWKSPublishCreate() {
|
||||||
@ -199,31 +199,31 @@ private:
|
|||||||
connect(keygenjob, &KeyGenerationJob::result, this,
|
connect(keygenjob, &KeyGenerationJob::result, this,
|
||||||
[this, &fpr](KeyGenerationResult result, QByteArray, QString, Error)
|
[this, &fpr](KeyGenerationResult result, QByteArray, QString, Error)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!result.error());
|
QVERIFY(!result.error());
|
||||||
fpr = QByteArray(result.fingerprint());
|
fpr = QByteArray(result.fingerprint());
|
||||||
Q_ASSERT(!fpr.isEmpty());
|
QVERIFY(!fpr.isEmpty());
|
||||||
Q_EMIT asyncDone();
|
Q_EMIT asyncDone();
|
||||||
});
|
});
|
||||||
keygenjob->start(args);
|
keygenjob->start(args);
|
||||||
QSignalSpy spy (this, SIGNAL(asyncDone()));
|
QSignalSpy spy (this, SIGNAL(asyncDone()));
|
||||||
Q_ASSERT(spy.wait());
|
QVERIFY(spy.wait());
|
||||||
|
|
||||||
/* Then try to create a request. */
|
/* Then try to create a request. */
|
||||||
auto job = openpgp()->wksPublishJob();
|
auto job = openpgp()->wksPublishJob();
|
||||||
connect(job, &WKSPublishJob::result, this,
|
connect(job, &WKSPublishJob::result, this,
|
||||||
[this] (Error err, QByteArray out, QByteArray, QString, Error) {
|
[this] (Error err, QByteArray out, QByteArray, QString, Error) {
|
||||||
Q_ASSERT(!err);
|
QVERIFY(!err);
|
||||||
Q_EMIT asyncDone();
|
Q_EMIT asyncDone();
|
||||||
const QString outstr = QString(out);
|
const QString outstr = QString(out);
|
||||||
Q_ASSERT(outstr.contains(
|
QVERIFY(outstr.contains(
|
||||||
QStringLiteral("-----BEGIN PGP PUBLIC KEY BLOCK-----")));
|
QStringLiteral("-----BEGIN PGP PUBLIC KEY BLOCK-----")));
|
||||||
Q_ASSERT(outstr.contains(
|
QVERIFY(outstr.contains(
|
||||||
QStringLiteral("Content-Type: application/pgp-keys")));
|
QStringLiteral("Content-Type: application/pgp-keys")));
|
||||||
Q_ASSERT(outstr.contains(
|
QVERIFY(outstr.contains(
|
||||||
QStringLiteral("From: " TEST_ADDRESS)));
|
QStringLiteral("From: " TEST_ADDRESS)));
|
||||||
});
|
});
|
||||||
job->startCreate(fpr.constData(), QLatin1String(TEST_ADDRESS));
|
job->startCreate(fpr.constData(), QLatin1String(TEST_ADDRESS));
|
||||||
Q_ASSERT(spy.wait());
|
QVERIFY(spy.wait());
|
||||||
}
|
}
|
||||||
|
|
||||||
void testWKSPublishReceive() {
|
void testWKSPublishReceive() {
|
||||||
@ -235,31 +235,31 @@ private:
|
|||||||
connect(importjob, &ImportJob::result, this,
|
connect(importjob, &ImportJob::result, this,
|
||||||
[this](ImportResult result, QString, Error)
|
[this](ImportResult result, QString, Error)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!result.error());
|
QVERIFY(!result.error());
|
||||||
Q_ASSERT(!result.imports().empty());
|
QVERIFY(!result.imports().empty());
|
||||||
Q_ASSERT(result.numSecretKeysImported());
|
QVERIFY(result.numSecretKeysImported());
|
||||||
Q_EMIT asyncDone();
|
Q_EMIT asyncDone();
|
||||||
});
|
});
|
||||||
importjob->start(QByteArray(testSecKey));
|
importjob->start(QByteArray(testSecKey));
|
||||||
QSignalSpy spy (this, SIGNAL(asyncDone()));
|
QSignalSpy spy (this, SIGNAL(asyncDone()));
|
||||||
Q_ASSERT(spy.wait());
|
QVERIFY(spy.wait());
|
||||||
|
|
||||||
/* Get a response. */
|
/* Get a response. */
|
||||||
auto job = openpgp()->wksPublishJob();
|
auto job = openpgp()->wksPublishJob();
|
||||||
connect(job, &WKSPublishJob::result, this,
|
connect(job, &WKSPublishJob::result, this,
|
||||||
[this] (Error err, QByteArray out, QByteArray, QString, Error) {
|
[this] (Error err, QByteArray out, QByteArray, QString, Error) {
|
||||||
Q_ASSERT(!err);
|
QVERIFY(!err);
|
||||||
Q_EMIT asyncDone();
|
Q_EMIT asyncDone();
|
||||||
const QString outstr = QString(out);
|
const QString outstr = QString(out);
|
||||||
Q_ASSERT(outstr.contains(
|
QVERIFY(outstr.contains(
|
||||||
QStringLiteral("-----BEGIN PGP MESSAGE-----")));
|
QStringLiteral("-----BEGIN PGP MESSAGE-----")));
|
||||||
Q_ASSERT(outstr.contains(
|
QVERIFY(outstr.contains(
|
||||||
QStringLiteral("Content-Type: multipart/encrypted;")));
|
QStringLiteral("Content-Type: multipart/encrypted;")));
|
||||||
Q_ASSERT(outstr.contains(
|
QVERIFY(outstr.contains(
|
||||||
QStringLiteral("From: " TEST_ADDRESS)));
|
QStringLiteral("From: " TEST_ADDRESS)));
|
||||||
});
|
});
|
||||||
job->startReceive(QByteArray(testResponse));
|
job->startReceive(QByteArray(testResponse));
|
||||||
Q_ASSERT(spy.wait());
|
QVERIFY(spy.wait());
|
||||||
}
|
}
|
||||||
|
|
||||||
void initTestCase()
|
void initTestCase()
|
||||||
@ -267,9 +267,9 @@ private:
|
|||||||
QGpgMETest::initTestCase();
|
QGpgMETest::initTestCase();
|
||||||
const QString gpgHome = qgetenv("GNUPGHOME");
|
const QString gpgHome = qgetenv("GNUPGHOME");
|
||||||
qputenv("GNUPGHOME", mDir.path().toUtf8());
|
qputenv("GNUPGHOME", mDir.path().toUtf8());
|
||||||
Q_ASSERT(mDir.isValid());
|
QVERIFY(mDir.isValid());
|
||||||
QFile agentConf(mDir.path() + QStringLiteral("/gpg-agent.conf"));
|
QFile agentConf(mDir.path() + QStringLiteral("/gpg-agent.conf"));
|
||||||
Q_ASSERT(agentConf.open(QIODevice::WriteOnly));
|
QVERIFY(agentConf.open(QIODevice::WriteOnly));
|
||||||
agentConf.write("allow-loopback-pinentry");
|
agentConf.write("allow-loopback-pinentry");
|
||||||
agentConf.close();
|
agentConf.close();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user