diff options
author | Saturneric <[email protected]> | 2021-12-31 01:50:20 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2021-12-31 01:50:20 +0000 |
commit | cb10cffa20702ec3dac50adb5aeeebd6138279b0 (patch) | |
tree | c614cfb31b30d2c7f3a8175c8309ab2f738953d0 /test/GpgFrontendTest.h | |
parent | <refactor, test>(core, test): core improved and test gpg alone mode (diff) | |
download | GpgFrontend-cb10cffa20702ec3dac50adb5aeeebd6138279b0.tar.gz GpgFrontend-cb10cffa20702ec3dac50adb5aeeebd6138279b0.zip |
<refactor, test>(core, test): core improved and test gpg key generation
1. Refactor the initialization code of Context.
2. Improve some callback function support.
3. Improve the key deletion function.
4. Modify the key output of some functions.
5. Add test for key generation.
6. Delete all imported keys at the end of the test case.
7. Add setup mode initialization parameters for Context.
Diffstat (limited to '')
-rw-r--r-- | test/GpgFrontendTest.h | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/test/GpgFrontendTest.h b/test/GpgFrontendTest.h index 83778ee6..84476106 100644 --- a/test/GpgFrontendTest.h +++ b/test/GpgFrontendTest.h @@ -40,6 +40,7 @@ #include "gpg/GpgConstants.h" #include "gpg/function/GpgKeyImportExporter.h" +#include "gpg/function/GpgKeyOpera.h" class GpgCoreTest : public ::testing::Test { protected: @@ -70,6 +71,10 @@ class GpgCoreTest : public ::testing::Test { defaultConf.setToDefault(); el::Loggers::reconfigureLogger("default", defaultConf); + defaultConf.setGlobally(el::ConfigurationType::Format, + "%datetime %level %func %msg"); + el::Loggers::reconfigureLogger("default", defaultConf); + using namespace libconfig; Config cfg; ASSERT_NO_THROW(cfg.readFile(config_path.c_str())); @@ -90,12 +95,18 @@ class GpgCoreTest : public ::testing::Test { import_data_alone(); } - void TearDown() override {} + void TearDown() override { + auto key_ids = std::make_unique<GpgFrontend::KeyIdArgsList>(); + key_ids->push_back("81704859182661FB"); + key_ids->push_back("06F1C7E7240C94E8"); + key_ids->push_back("8465C55B25C9B7D1"); + key_ids->push_back("021D89771B680FFB"); + GpgFrontend::GpgKeyOpera::GetInstance(default_channel) + .DeleteKeys(std::move(key_ids)); + } private: void import_data() { - GpgFrontend::GpgContext::GetInstance(default_channel) - .SetPassphraseCb(GpgFrontend::GpgContext::test_passphrase_cb); for (const auto& secret_key : secret_keys_) { auto secret_key_copy = std::make_unique<GpgFrontend::ByteArray>(*secret_key); @@ -105,8 +116,6 @@ class GpgCoreTest : public ::testing::Test { } void import_data_alone() { - GpgFrontend::GpgContext::GetInstance(gpg_alone_channel) - .SetPassphraseCb(GpgFrontend::GpgContext::test_passphrase_cb); for (auto& secret_key : secret_keys_) { auto secret_key_copy = std::make_unique<GpgFrontend::ByteArray>(*secret_key); @@ -157,6 +166,7 @@ class GpgCoreTest : public ::testing::Test { args.independent_database = true; args.db_path = db_path.string(); args.gpg_path = gpg_path.string(); + args.test_mode = true; return std::make_unique<GpgFrontend::GpgContext>(args); }); } @@ -181,8 +191,7 @@ class GpgCoreTest : public ::testing::Test { GpgFrontend::GpgContext::CreateInstance( default_channel, [&]() -> std::unique_ptr<GpgFrontend::GpgContext> { GpgFrontend::GpgContextInitArgs args; - args.independent_database = true; - args.db_path = db_path.string(); + args.test_mode = true; return std::make_unique<GpgFrontend::GpgContext>(args); }); } |