qt, tests: Don't use internal API
* lang/qt/tests/t-encrypt.cpp, lang/qt/tests/t-tofuinfo.cpp: Only use exported API. -- With the Job::Context hack we no longer need to use internal API.
This commit is contained in:
parent
df4eb611e3
commit
b56f398eff
@ -42,10 +42,10 @@
|
|||||||
#include "encryptjob.h"
|
#include "encryptjob.h"
|
||||||
#include "signencryptjob.h"
|
#include "signencryptjob.h"
|
||||||
#include "signingresult.h"
|
#include "signingresult.h"
|
||||||
#include "qgpgmeencryptjob.h"
|
#include "encryptjob.h"
|
||||||
#include "encryptionresult.h"
|
#include "encryptionresult.h"
|
||||||
#include "decryptionresult.h"
|
#include "decryptionresult.h"
|
||||||
#include "qgpgmedecryptjob.h"
|
#include "decryptjob.h"
|
||||||
#include "qgpgmebackend.h"
|
#include "qgpgmebackend.h"
|
||||||
#include "keylistresult.h"
|
#include "keylistresult.h"
|
||||||
#include "engineinfo.h"
|
#include "engineinfo.h"
|
||||||
@ -106,11 +106,11 @@ private Q_SLOTS:
|
|||||||
if (!decryptSupported()) {
|
if (!decryptSupported()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto ctx = Context::createForProtocol(OpenPGP);
|
auto decJob = openpgp()->decryptJob();
|
||||||
|
auto ctx = Job::context(decJob);
|
||||||
TestPassphraseProvider provider;
|
TestPassphraseProvider provider;
|
||||||
ctx->setPassphraseProvider(&provider);
|
ctx->setPassphraseProvider(&provider);
|
||||||
ctx->setPinentryMode(Context::PinentryLoopback);
|
ctx->setPinentryMode(Context::PinentryLoopback);
|
||||||
auto decJob = new QGpgMEDecryptJob(ctx);
|
|
||||||
QByteArray plainText;
|
QByteArray plainText;
|
||||||
auto decResult = decJob->exec(cipherText, plainText);
|
auto decResult = decJob->exec(cipherText, plainText);
|
||||||
QVERIFY(!decResult.error());
|
QVERIFY(!decResult.error());
|
||||||
@ -177,13 +177,13 @@ private Q_SLOTS:
|
|||||||
if (!decryptSupported()) {
|
if (!decryptSupported()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto ctx = Context::createForProtocol(OpenPGP);
|
auto job = openpgp()->encryptJob();
|
||||||
|
auto ctx = Job::context(job);
|
||||||
TestPassphraseProvider provider;
|
TestPassphraseProvider provider;
|
||||||
ctx->setPassphraseProvider(&provider);
|
ctx->setPassphraseProvider(&provider);
|
||||||
ctx->setPinentryMode(Context::PinentryLoopback);
|
ctx->setPinentryMode(Context::PinentryLoopback);
|
||||||
ctx->setArmor(true);
|
ctx->setArmor(true);
|
||||||
ctx->setTextMode(true);
|
ctx->setTextMode(true);
|
||||||
auto job = new QGpgMEEncryptJob(ctx);
|
|
||||||
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;
|
||||||
@ -193,10 +193,10 @@ private Q_SLOTS:
|
|||||||
|
|
||||||
killAgent(mDir.path());
|
killAgent(mDir.path());
|
||||||
|
|
||||||
auto ctx2 = Context::createForProtocol(OpenPGP);
|
auto decJob = openpgp()->decryptJob();
|
||||||
|
auto ctx2 = Job::context(decJob);
|
||||||
ctx2->setPassphraseProvider(&provider);
|
ctx2->setPassphraseProvider(&provider);
|
||||||
ctx2->setPinentryMode(Context::PinentryLoopback);
|
ctx2->setPinentryMode(Context::PinentryLoopback);
|
||||||
auto decJob = new QGpgMEDecryptJob(ctx2);
|
|
||||||
QByteArray plainText;
|
QByteArray plainText;
|
||||||
auto decResult = decJob->exec(cipherText, plainText);
|
auto decResult = decJob->exec(cipherText, plainText);
|
||||||
QVERIFY(!result.error());
|
QVERIFY(!result.error());
|
||||||
@ -238,13 +238,14 @@ private Q_SLOTS:
|
|||||||
if (!decryptSupported()) {
|
if (!decryptSupported()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto ctx = Context::createForProtocol(OpenPGP);
|
|
||||||
|
auto decJob = openpgp()->decryptJob();
|
||||||
|
auto ctx = Job::context(decJob);
|
||||||
TestPassphraseProvider provider;
|
TestPassphraseProvider provider;
|
||||||
ctx->setPassphraseProvider(&provider);
|
ctx->setPassphraseProvider(&provider);
|
||||||
ctx->setPinentryMode(Context::PinentryLoopback);
|
ctx->setPinentryMode(Context::PinentryLoopback);
|
||||||
ctx->setDecryptionFlags(Context::DecryptUnwrap);
|
ctx->setDecryptionFlags(Context::DecryptUnwrap);
|
||||||
|
|
||||||
auto decJob = new QGpgMEDecryptJob(ctx);
|
|
||||||
QByteArray plainText;
|
QByteArray plainText;
|
||||||
auto decResult = decJob->exec(cipherText, plainText);
|
auto decResult = decJob->exec(cipherText, plainText);
|
||||||
|
|
||||||
@ -282,12 +283,12 @@ private:
|
|||||||
QVERIFY(keys.size() == 1);
|
QVERIFY(keys.size() == 1);
|
||||||
delete listjob;
|
delete listjob;
|
||||||
|
|
||||||
auto ctx = Context::createForProtocol(OpenPGP);
|
auto job = openpgp()->encryptJob();
|
||||||
|
auto ctx = Job::context(job);
|
||||||
ctx->setPassphraseProvider(new TestPassphraseProvider);
|
ctx->setPassphraseProvider(new TestPassphraseProvider);
|
||||||
ctx->setPinentryMode(Context::PinentryLoopback);
|
ctx->setPinentryMode(Context::PinentryLoopback);
|
||||||
ctx->setArmor(true);
|
ctx->setArmor(true);
|
||||||
ctx->setTextMode(true);
|
ctx->setTextMode(true);
|
||||||
auto job = new QGpgMEEncryptJob(ctx);
|
|
||||||
QByteArray cipherText;
|
QByteArray cipherText;
|
||||||
printf("Before exec, flags: %x\n", Context::Symmetric | Context::AlwaysTrust);
|
printf("Before exec, flags: %x\n", Context::Symmetric | Context::AlwaysTrust);
|
||||||
auto result = job->exec(keys, QStringLiteral("Hello symmetric World").toUtf8(),
|
auto result = job->exec(keys, QStringLiteral("Hello symmetric World").toUtf8(),
|
||||||
@ -310,11 +311,11 @@ private:
|
|||||||
agentConf.write("allow-loopback-pinentry");
|
agentConf.write("allow-loopback-pinentry");
|
||||||
agentConf.close();
|
agentConf.close();
|
||||||
|
|
||||||
auto ctx2 = Context::createForProtocol(OpenPGP);
|
auto decJob = openpgp()->decryptJob();
|
||||||
|
auto ctx2 = Job::context(decJob);
|
||||||
ctx2->setPassphraseProvider(new TestPassphraseProvider);
|
ctx2->setPassphraseProvider(new TestPassphraseProvider);
|
||||||
ctx2->setPinentryMode(Context::PinentryLoopback);
|
ctx2->setPinentryMode(Context::PinentryLoopback);
|
||||||
ctx2->setTextMode(true);
|
ctx2->setTextMode(true);
|
||||||
auto decJob = new QGpgMEDecryptJob(ctx2);
|
|
||||||
QByteArray plainText;
|
QByteArray plainText;
|
||||||
auto decResult = decJob->exec(cipherText, plainText);
|
auto decResult = decJob->exec(cipherText, plainText);
|
||||||
QVERIFY(!decResult.error());
|
QVERIFY(!decResult.error());
|
||||||
|
@ -48,10 +48,11 @@
|
|||||||
#include "importresult.h"
|
#include "importresult.h"
|
||||||
#include "keylistjob.h"
|
#include "keylistjob.h"
|
||||||
#include "keylistresult.h"
|
#include "keylistresult.h"
|
||||||
#include "qgpgmesignjob.h"
|
#include "signjob.h"
|
||||||
#include "key.h"
|
#include "key.h"
|
||||||
#include "t-support.h"
|
#include "t-support.h"
|
||||||
#include "engineinfo.h"
|
#include "engineinfo.h"
|
||||||
|
#include "context.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace QGpgME;
|
using namespace QGpgME;
|
||||||
@ -151,11 +152,11 @@ private:
|
|||||||
|
|
||||||
void signAndVerify(const QString &what, const GpgME::Key &key, int expected)
|
void signAndVerify(const QString &what, const GpgME::Key &key, int expected)
|
||||||
{
|
{
|
||||||
Context *ctx = Context::createForProtocol(OpenPGP);
|
auto job = openpgp()->signJob();
|
||||||
|
auto ctx = Job::context(job);
|
||||||
TestPassphraseProvider provider;
|
TestPassphraseProvider provider;
|
||||||
ctx->setPassphraseProvider(&provider);
|
ctx->setPassphraseProvider(&provider);
|
||||||
ctx->setPinentryMode(Context::PinentryLoopback);
|
ctx->setPinentryMode(Context::PinentryLoopback);
|
||||||
auto *job = new QGpgMESignJob(ctx);
|
|
||||||
|
|
||||||
std::vector<Key> keys;
|
std::vector<Key> keys;
|
||||||
keys.push_back(key);
|
keys.push_back(key);
|
||||||
|
Loading…
Reference in New Issue
Block a user