From f66f856c89b7c02e368afe2343de7cce50e6109e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= Date: Fri, 14 Aug 2020 11:11:23 +0200 Subject: core: Add error handling to setexpire * src/genkey.c (setexpire, gpgme_op_setexpire_start, gpgme_op_setexpire): Move to ... * src/setexpire.c: New. * src/Makefile.am (main_sources): Add that file. * src/context.h (ctx_op_data_id_t): Add OPDATA_SETEXPIRE. * lang/qt/tests/t-various.cpp (testSetExpire): Test error handling. -- Errors (and failures) emitted via status-fd need to be handled explicitly, i.e. we need to provide an appropriate status handler with corresponding op_data_t. Additionally, we need to set a passphrase command handler if a passphrase callback is set in the context, e.g. during tests. GnuPG-bug-id: 4395 --- lang/qt/tests/t-various.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lang/qt/tests/t-various.cpp') diff --git a/lang/qt/tests/t-various.cpp b/lang/qt/tests/t-various.cpp index dc5a2d1c..1e6bba41 100644 --- a/lang/qt/tests/t-various.cpp +++ b/lang/qt/tests/t-various.cpp @@ -222,6 +222,15 @@ private Q_SLOTS: QVERIFY (key.subkey(0).expirationTime() == keyExpiration); QVERIFY (key.subkey(1).expirationTime() != subkeyExpiration); + + // test error handling: calling setExpire() with the primary key as + // subkey should fail with "subkey not found" + ctx = Context::createForProtocol(key.protocol()); + std::vector primaryKey; + primaryKey.push_back(key.subkey(0)); + const auto err = ctx->setExpire(key, 3000, primaryKey); + QCOMPARE(err.code(), GPG_ERR_NOT_FOUND); + delete ctx; } void testVersion() -- cgit v1.2.3