diff options
Diffstat (limited to 'src/test/core/GpgCoreTestKeyManagement.cpp')
-rw-r--r-- | src/test/core/GpgCoreTestKeyManagement.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/test/core/GpgCoreTestKeyManagement.cpp b/src/test/core/GpgCoreTestKeyManagement.cpp index 114c237a..135a7e51 100644 --- a/src/test/core/GpgCoreTestKeyManagement.cpp +++ b/src/test/core/GpgCoreTestKeyManagement.cpp @@ -107,6 +107,7 @@ cBEIUb80jrN959lF8eobqrVouY5GyvZXVZFGoXS4OTkFAwlEZxWBxJw= )"; namespace GpgFrontend::Test { + TEST_F(GpgCoreTest, CoreDeleteSubkeyTestA) { auto info = GpgKeyImportExporter::GetInstance().ImportKey( GFBuffer(QString::fromLatin1(TEST_PRIVATE_KEY_DATA))); @@ -127,6 +128,7 @@ TEST_F(GpgCoreTest, CoreDeleteSubkeyTestA) { ASSERT_TRUE(res); + GpgKeyGetter::GetInstance().FlushKeyCache(); key = GpgKeyGetter::GetInstance(kGpgFrontendDefaultChannel) .GetKey("822D7E13F5B85D7D"); ASSERT_TRUE(key.IsGood()); @@ -213,4 +215,40 @@ TEST_F(GpgCoreTest, CoreSetOwnerTrustA) { GpgKeyOpera::GetInstance().DeleteKey(key.GetId()); } +TEST_F(GpgCoreTest, CoreRevokeSubkeyTestA) { + auto info = GpgKeyImportExporter::GetInstance().ImportKey( + GFBuffer(QString::fromLatin1(TEST_PRIVATE_KEY_DATA))); + + ASSERT_EQ(info->not_imported, 0); + ASSERT_EQ(info->imported, 1); + + auto key = GpgKeyGetter::GetInstance(kGpgFrontendDefaultChannel) + .GetKey("822D7E13F5B85D7D"); + ASSERT_TRUE(key.IsGood()); + + auto subkeys = key.GetSubKeys(); + + ASSERT_EQ(subkeys->size(), 5); + ASSERT_EQ((*subkeys)[2].GetID(), "2D1F9FC59B568A8C"); + + auto res = GpgKeyManager::GetInstance().RevokeSubkey( + key, 2, 2, QString("H\nE\nLL\nO\n\n")); + + ASSERT_TRUE(res); + + GpgKeyGetter::GetInstance().FlushKeyCache(); + key = GpgKeyGetter::GetInstance(kGpgFrontendDefaultChannel) + .GetKey("822D7E13F5B85D7D"); + ASSERT_TRUE(key.IsGood()); + + subkeys = key.GetSubKeys(); + + ASSERT_EQ(subkeys->size(), 5); + ASSERT_EQ((*subkeys)[2].GetID(), "2D1F9FC59B568A8C"); + + ASSERT_TRUE((*subkeys)[2].IsRevoked()); + + GpgKeyOpera::GetInstance().DeleteKey(key.GetId()); +} + } // namespace GpgFrontend::Test
\ No newline at end of file |