File indexing completed on 2024-04-28 09:46:02
0001 #include "kgpgchangedisable.h" 0002 #include "../transactions/kgpgchangedisable.h" 0003 #include "../kgpginterface.h" 0004 #include "common.h" 0005 0006 #include <QSignalSpy> 0007 #include <QTest> 0008 0009 void KGpgChangeDisableTest::init() 0010 { 0011 QVERIFY(resetGpgConf(m_tempdir)); 0012 addGpgKey(m_tempdir, QLatin1String("keys/kgpgtest_BA7695F3C550DF14_pub.asc")); 0013 } 0014 0015 void KGpgChangeDisableTest::testDisableKey() 0016 { 0017 const QString keyID = QLatin1String("FBAF08DD7D9D0921C15DDA9FBA7695F3C550DF14"); 0018 KGpgChangeDisable *transaction = new KGpgChangeDisable(this, keyID, true); 0019 QSignalSpy spy(transaction, &KGpgChangeDisable::done); 0020 QObject::connect(transaction, &KGpgChangeDisable::done, [](int result) { 0021 QCOMPARE(result, static_cast<int>(KGpgTransaction::TS_OK)); 0022 }); 0023 transaction->start(); 0024 QVERIFY(spy.wait(10000)); 0025 KgpgCore::KgpgKeyList keyList = KgpgInterface::readPublicKeys(QStringList(keyID)); 0026 QVERIFY(!keyList.isEmpty()); 0027 QVERIFY(!keyList.first().valid()); 0028 } 0029 0030 void KGpgChangeDisableTest::testEnableKey() 0031 { 0032 const QString keyID = QLatin1String("FBAF08DD7D9D0921C15DDA9FBA7695F3C550DF14"); 0033 KGpgChangeDisable *transaction = new KGpgChangeDisable(this, keyID, true); 0034 QSignalSpy spy(transaction, &KGpgChangeDisable::done); 0035 transaction->start(); 0036 QVERIFY(spy.wait(10000)); 0037 QObject::connect(transaction, &KGpgChangeDisable::done, [](int result) { 0038 QCOMPARE(result, static_cast<int>(KGpgTransaction::TS_OK)); 0039 }); 0040 transaction->setDisable(false); 0041 transaction->start(); 0042 QVERIFY(spy.wait(10000)); 0043 KgpgCore::KgpgKeyList keyList = KgpgInterface::readPublicKeys(QStringList(keyID)); 0044 QVERIFY(!keyList.isEmpty()); 0045 QVERIFY(keyList.first().valid()); 0046 } 0047 0048 QTEST_GUILESS_MAIN(KGpgChangeDisableTest)