p≡p engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3448 lines
133 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
ENGINE-866 feature branch merge (squashed commit) of functionality to set the sticky bit for manually imported keys, to query for that bit in the trust database, and prevention of automatic reset of sticky keys by key reset when devices leave a device group. Squashed commit of the following: commit c64d850dc4bfe5a9dfd54aa94eea08a75ff69191 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:29:32 2021 +0100 ENGINE-866: doc'd bit getter function commit ad725b5b7c742300a6a182ad8b058db23dbc3cfb Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:23:49 2021 +0100 ENGINE-866: Key reset tested on mixed sticky and not sticky keys and does what it should. commit 0ffbdde7b598c7c3fff5d797e732dec07685f9be Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:13:53 2021 +0100 ENGINE-866: Add boolean for whether to set the sticky bit or not with set_own_imported_key. the adapter should filter this out for apps, I guess, according to Volker commit 23fec59a9a4ede0682a9ebcb9a61e78456e7d8d4 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 14:53:19 2021 +0100 ENGINE-866: Test and use the sticky bit commit 562239fda874623c40893c382a8f82df9e002ef5 Author: Krista Bennett <krista@pep.foundation> Date: Thu Feb 25 16:47:47 2021 +0100 ENGINE-866: moved bit from key to trust, created set_own_imported_key to replace set_own_key FOR MAIL APPS (does NOT replace it for key reset, as the new function can generate a passphrase error, whereas set_own_key cannot), and did an initial test to ensure the setter/getter functions work on the DB. commit 594133cfdee966adbaa66c62133ede1ca917bca0 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 11:16:21 2021 +0100 Commented out the or'd identity.flags / pgp_keypair.flags in the sql code for the get_identity functions; we've never HAD a pgp_keypair flag before, so it never hurt before, but at this point, we're going to introduce them, and I don't want trouble. If fdik wants them or'd, fine, we'll have to change the values in the keyflags to be disjoint from the identity flags so they can coexist, but for now, they are out. commit 99831445b3e22e1386aa0f86414fdb6939e5ebaf Merge: 8ba53ece d1664cf5 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 10:15:53 2021 +0100 Merge branch 'master' into ENGINE-866 commit 8ba53ece06773168a9188373d1be5f13d99b2f6e Merge: 168e2cf9 c52f4d39 Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 20:06:08 2021 +0100 Merged in engine_sql changes commit 168e2cf9578b12157b98da8b26e598f0a1448d9e Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 19:03:35 2021 +0100 ENGINE-866: Added sticky bit in database for manually set keys
1 year ago
ENGINE-866 feature branch merge (squashed commit) of functionality to set the sticky bit for manually imported keys, to query for that bit in the trust database, and prevention of automatic reset of sticky keys by key reset when devices leave a device group. Squashed commit of the following: commit c64d850dc4bfe5a9dfd54aa94eea08a75ff69191 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:29:32 2021 +0100 ENGINE-866: doc'd bit getter function commit ad725b5b7c742300a6a182ad8b058db23dbc3cfb Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:23:49 2021 +0100 ENGINE-866: Key reset tested on mixed sticky and not sticky keys and does what it should. commit 0ffbdde7b598c7c3fff5d797e732dec07685f9be Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:13:53 2021 +0100 ENGINE-866: Add boolean for whether to set the sticky bit or not with set_own_imported_key. the adapter should filter this out for apps, I guess, according to Volker commit 23fec59a9a4ede0682a9ebcb9a61e78456e7d8d4 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 14:53:19 2021 +0100 ENGINE-866: Test and use the sticky bit commit 562239fda874623c40893c382a8f82df9e002ef5 Author: Krista Bennett <krista@pep.foundation> Date: Thu Feb 25 16:47:47 2021 +0100 ENGINE-866: moved bit from key to trust, created set_own_imported_key to replace set_own_key FOR MAIL APPS (does NOT replace it for key reset, as the new function can generate a passphrase error, whereas set_own_key cannot), and did an initial test to ensure the setter/getter functions work on the DB. commit 594133cfdee966adbaa66c62133ede1ca917bca0 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 11:16:21 2021 +0100 Commented out the or'd identity.flags / pgp_keypair.flags in the sql code for the get_identity functions; we've never HAD a pgp_keypair flag before, so it never hurt before, but at this point, we're going to introduce them, and I don't want trouble. If fdik wants them or'd, fine, we'll have to change the values in the keyflags to be disjoint from the identity flags so they can coexist, but for now, they are out. commit 99831445b3e22e1386aa0f86414fdb6939e5ebaf Merge: 8ba53ece d1664cf5 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 10:15:53 2021 +0100 Merge branch 'master' into ENGINE-866 commit 8ba53ece06773168a9188373d1be5f13d99b2f6e Merge: 168e2cf9 c52f4d39 Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 20:06:08 2021 +0100 Merged in engine_sql changes commit 168e2cf9578b12157b98da8b26e598f0a1448d9e Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 19:03:35 2021 +0100 ENGINE-866: Added sticky bit in database for manually set keys
1 year ago
ENGINE-866 feature branch merge (squashed commit) of functionality to set the sticky bit for manually imported keys, to query for that bit in the trust database, and prevention of automatic reset of sticky keys by key reset when devices leave a device group. Squashed commit of the following: commit c64d850dc4bfe5a9dfd54aa94eea08a75ff69191 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:29:32 2021 +0100 ENGINE-866: doc'd bit getter function commit ad725b5b7c742300a6a182ad8b058db23dbc3cfb Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:23:49 2021 +0100 ENGINE-866: Key reset tested on mixed sticky and not sticky keys and does what it should. commit 0ffbdde7b598c7c3fff5d797e732dec07685f9be Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:13:53 2021 +0100 ENGINE-866: Add boolean for whether to set the sticky bit or not with set_own_imported_key. the adapter should filter this out for apps, I guess, according to Volker commit 23fec59a9a4ede0682a9ebcb9a61e78456e7d8d4 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 14:53:19 2021 +0100 ENGINE-866: Test and use the sticky bit commit 562239fda874623c40893c382a8f82df9e002ef5 Author: Krista Bennett <krista@pep.foundation> Date: Thu Feb 25 16:47:47 2021 +0100 ENGINE-866: moved bit from key to trust, created set_own_imported_key to replace set_own_key FOR MAIL APPS (does NOT replace it for key reset, as the new function can generate a passphrase error, whereas set_own_key cannot), and did an initial test to ensure the setter/getter functions work on the DB. commit 594133cfdee966adbaa66c62133ede1ca917bca0 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 11:16:21 2021 +0100 Commented out the or'd identity.flags / pgp_keypair.flags in the sql code for the get_identity functions; we've never HAD a pgp_keypair flag before, so it never hurt before, but at this point, we're going to introduce them, and I don't want trouble. If fdik wants them or'd, fine, we'll have to change the values in the keyflags to be disjoint from the identity flags so they can coexist, but for now, they are out. commit 99831445b3e22e1386aa0f86414fdb6939e5ebaf Merge: 8ba53ece d1664cf5 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 10:15:53 2021 +0100 Merge branch 'master' into ENGINE-866 commit 8ba53ece06773168a9188373d1be5f13d99b2f6e Merge: 168e2cf9 c52f4d39 Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 20:06:08 2021 +0100 Merged in engine_sql changes commit 168e2cf9578b12157b98da8b26e598f0a1448d9e Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 19:03:35 2021 +0100 ENGINE-866: Added sticky bit in database for manually set keys
1 year ago
ENGINE-866 feature branch merge (squashed commit) of functionality to set the sticky bit for manually imported keys, to query for that bit in the trust database, and prevention of automatic reset of sticky keys by key reset when devices leave a device group. Squashed commit of the following: commit c64d850dc4bfe5a9dfd54aa94eea08a75ff69191 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:29:32 2021 +0100 ENGINE-866: doc'd bit getter function commit ad725b5b7c742300a6a182ad8b058db23dbc3cfb Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:23:49 2021 +0100 ENGINE-866: Key reset tested on mixed sticky and not sticky keys and does what it should. commit 0ffbdde7b598c7c3fff5d797e732dec07685f9be Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:13:53 2021 +0100 ENGINE-866: Add boolean for whether to set the sticky bit or not with set_own_imported_key. the adapter should filter this out for apps, I guess, according to Volker commit 23fec59a9a4ede0682a9ebcb9a61e78456e7d8d4 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 14:53:19 2021 +0100 ENGINE-866: Test and use the sticky bit commit 562239fda874623c40893c382a8f82df9e002ef5 Author: Krista Bennett <krista@pep.foundation> Date: Thu Feb 25 16:47:47 2021 +0100 ENGINE-866: moved bit from key to trust, created set_own_imported_key to replace set_own_key FOR MAIL APPS (does NOT replace it for key reset, as the new function can generate a passphrase error, whereas set_own_key cannot), and did an initial test to ensure the setter/getter functions work on the DB. commit 594133cfdee966adbaa66c62133ede1ca917bca0 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 11:16:21 2021 +0100 Commented out the or'd identity.flags / pgp_keypair.flags in the sql code for the get_identity functions; we've never HAD a pgp_keypair flag before, so it never hurt before, but at this point, we're going to introduce them, and I don't want trouble. If fdik wants them or'd, fine, we'll have to change the values in the keyflags to be disjoint from the identity flags so they can coexist, but for now, they are out. commit 99831445b3e22e1386aa0f86414fdb6939e5ebaf Merge: 8ba53ece d1664cf5 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 10:15:53 2021 +0100 Merge branch 'master' into ENGINE-866 commit 8ba53ece06773168a9188373d1be5f13d99b2f6e Merge: 168e2cf9 c52f4d39 Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 20:06:08 2021 +0100 Merged in engine_sql changes commit 168e2cf9578b12157b98da8b26e598f0a1448d9e Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 19:03:35 2021 +0100 ENGINE-866: Added sticky bit in database for manually set keys
1 year ago
ENGINE-866 feature branch merge (squashed commit) of functionality to set the sticky bit for manually imported keys, to query for that bit in the trust database, and prevention of automatic reset of sticky keys by key reset when devices leave a device group. Squashed commit of the following: commit c64d850dc4bfe5a9dfd54aa94eea08a75ff69191 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:29:32 2021 +0100 ENGINE-866: doc'd bit getter function commit ad725b5b7c742300a6a182ad8b058db23dbc3cfb Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:23:49 2021 +0100 ENGINE-866: Key reset tested on mixed sticky and not sticky keys and does what it should. commit 0ffbdde7b598c7c3fff5d797e732dec07685f9be Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:13:53 2021 +0100 ENGINE-866: Add boolean for whether to set the sticky bit or not with set_own_imported_key. the adapter should filter this out for apps, I guess, according to Volker commit 23fec59a9a4ede0682a9ebcb9a61e78456e7d8d4 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 14:53:19 2021 +0100 ENGINE-866: Test and use the sticky bit commit 562239fda874623c40893c382a8f82df9e002ef5 Author: Krista Bennett <krista@pep.foundation> Date: Thu Feb 25 16:47:47 2021 +0100 ENGINE-866: moved bit from key to trust, created set_own_imported_key to replace set_own_key FOR MAIL APPS (does NOT replace it for key reset, as the new function can generate a passphrase error, whereas set_own_key cannot), and did an initial test to ensure the setter/getter functions work on the DB. commit 594133cfdee966adbaa66c62133ede1ca917bca0 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 11:16:21 2021 +0100 Commented out the or'd identity.flags / pgp_keypair.flags in the sql code for the get_identity functions; we've never HAD a pgp_keypair flag before, so it never hurt before, but at this point, we're going to introduce them, and I don't want trouble. If fdik wants them or'd, fine, we'll have to change the values in the keyflags to be disjoint from the identity flags so they can coexist, but for now, they are out. commit 99831445b3e22e1386aa0f86414fdb6939e5ebaf Merge: 8ba53ece d1664cf5 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 10:15:53 2021 +0100 Merge branch 'master' into ENGINE-866 commit 8ba53ece06773168a9188373d1be5f13d99b2f6e Merge: 168e2cf9 c52f4d39 Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 20:06:08 2021 +0100 Merged in engine_sql changes commit 168e2cf9578b12157b98da8b26e598f0a1448d9e Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 19:03:35 2021 +0100 ENGINE-866: Added sticky bit in database for manually set keys
1 year ago
ENGINE-866 feature branch merge (squashed commit) of functionality to set the sticky bit for manually imported keys, to query for that bit in the trust database, and prevention of automatic reset of sticky keys by key reset when devices leave a device group. Squashed commit of the following: commit c64d850dc4bfe5a9dfd54aa94eea08a75ff69191 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:29:32 2021 +0100 ENGINE-866: doc'd bit getter function commit ad725b5b7c742300a6a182ad8b058db23dbc3cfb Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:23:49 2021 +0100 ENGINE-866: Key reset tested on mixed sticky and not sticky keys and does what it should. commit 0ffbdde7b598c7c3fff5d797e732dec07685f9be Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 15:13:53 2021 +0100 ENGINE-866: Add boolean for whether to set the sticky bit or not with set_own_imported_key. the adapter should filter this out for apps, I guess, according to Volker commit 23fec59a9a4ede0682a9ebcb9a61e78456e7d8d4 Author: Krista Bennett <krista@pep.foundation> Date: Fri Feb 26 14:53:19 2021 +0100 ENGINE-866: Test and use the sticky bit commit 562239fda874623c40893c382a8f82df9e002ef5 Author: Krista Bennett <krista@pep.foundation> Date: Thu Feb 25 16:47:47 2021 +0100 ENGINE-866: moved bit from key to trust, created set_own_imported_key to replace set_own_key FOR MAIL APPS (does NOT replace it for key reset, as the new function can generate a passphrase error, whereas set_own_key cannot), and did an initial test to ensure the setter/getter functions work on the DB. commit 594133cfdee966adbaa66c62133ede1ca917bca0 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 11:16:21 2021 +0100 Commented out the or'd identity.flags / pgp_keypair.flags in the sql code for the get_identity functions; we've never HAD a pgp_keypair flag before, so it never hurt before, but at this point, we're going to introduce them, and I don't want trouble. If fdik wants them or'd, fine, we'll have to change the values in the keyflags to be disjoint from the identity flags so they can coexist, but for now, they are out. commit 99831445b3e22e1386aa0f86414fdb6939e5ebaf Merge: 8ba53ece d1664cf5 Author: Krista Bennett <krista@pep.foundation> Date: Wed Feb 24 10:15:53 2021 +0100 Merge branch 'master' into ENGINE-866 commit 8ba53ece06773168a9188373d1be5f13d99b2f6e Merge: 168e2cf9 c52f4d39 Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 20:06:08 2021 +0100 Merged in engine_sql changes commit 168e2cf9578b12157b98da8b26e598f0a1448d9e Author: Krista Bennett <krista@pep.foundation> Date: Mon Feb 22 19:03:35 2021 +0100 ENGINE-866: Added sticky bit in database for manually set keys
1 year ago
  1. // This file is under GNU General Public License 3.0
  2. // see LICENSE.txt
  3. #include <stdlib.h>
  4. #include <string>
  5. #include <vector>
  6. #include <unordered_map>
  7. #include <assert.h>
  8. #include <iostream>
  9. #include <fstream>
  10. #include "pEpEngine.h"
  11. #include "pEp_internal.h"
  12. #include "pEp_internal.h"
  13. #include "mime.h"
  14. #include "keymanagement.h"
  15. #include "key_reset.h"
  16. #include "key_reset_internal.h"
  17. #include "TestUtilities.h"
  18. #include "TestConstants.h"
  19. #include "Engine.h"
  20. #include <gtest/gtest.h>
  21. PEP_STATUS KRMT_message_send_callback(message* msg);
  22. PEP_STATUS KRMT_ensure_passphrase_callback(PEP_SESSION session, const char* key);
  23. static void* KRMT_fake_this;
  24. //The fixture for KeyResetMessageTest
  25. class KeyResetMessageTest : public ::testing::Test {
  26. public:
  27. Engine* engine;
  28. PEP_SESSION session;
  29. vector<message*> m_queue;
  30. vector<string> pass_list;
  31. protected:
  32. const char* alice_fpr = "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97";
  33. const char* bob_fpr = "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39";
  34. const char* carol_fpr = "8DD4F5827B45839E9ACCA94687BDDFFB42A85A42";
  35. const char* dave_fpr = "E8AC9779A2D13A15D8D55C84B049F489BB5BCCF6";
  36. const char* erin_fpr = "1B0E197E8AE66277B8A024B9AEA69F509F8D7CBA";
  37. const char* fenris_fpr = "0969FA229DF21C832A64A04711B1B9804F3D2900";
  38. const char* alice_receive_reset_fpr = "9B3CC93A689B1167082A90C80766A463E439CB71";
  39. const string alice_user_id = PEP_OWN_USERID;
  40. const string bob_user_id = "BobId";
  41. const string carol_user_id = "carolId";
  42. const string dave_user_id = "DaveId";
  43. const string erin_user_id = "ErinErinErin";
  44. const string fenris_user_id = "BadWolf";
  45. const char* bob2_filename = "test_keys/bob-primary-with-password-bob-subkey-without.pgp";
  46. const char* bob2_fpr = "5C76378A62B04CF3F41BEC8D4940FC9FA1878736";
  47. const char* alice2_filename = "test_keys/alice-no-passwords.pgp";
  48. const char* alice2_fpr = "03AF88F728B8E9AADA7F370BD41801C62A649B9F";
  49. const char* erwin_filename = "test_keys/erwin_normal_encrypted.pgp";
  50. const char* erwin_fpr = "CBA968BC01FCEB89F04CCF155C5E9E3F0420A570";
  51. // You can remove any or all of the following functions if its body
  52. // is empty.
  53. KeyResetMessageTest() {
  54. // You can do set-up work for each test here.
  55. test_suite_name = ::testing::UnitTest::GetInstance()->current_test_info()->GTEST_SUITE_SYM();
  56. test_name = ::testing::UnitTest::GetInstance()->current_test_info()->name();
  57. test_path = get_main_test_home_dir() + "/" + test_suite_name + "/" + test_name;
  58. }
  59. ~KeyResetMessageTest() override {
  60. // You can do clean-up work that doesn't throw exceptions here.
  61. }
  62. // If the constructor and destructor are not enough for setting up
  63. // and cleaning up each test, you can define the following methods:
  64. void SetUp() override {
  65. // Code here will be called immediately after the constructor (right
  66. // before each test).
  67. KRMT_fake_this = (void*)this;
  68. // Leave this empty if there are no files to copy to the home directory path
  69. std::vector<std::pair<std::string, std::string>> init_files = std::vector<std::pair<std::string, std::string>>();
  70. // Get a new test Engine.
  71. engine = new Engine(test_path);
  72. ASSERT_NOTNULL(engine);
  73. // Ok, let's initialize test directories etc.
  74. engine->prep(&KRMT_message_send_callback, NULL, &KRMT_ensure_passphrase_callback, init_files);
  75. // Ok, try to start this bugger.
  76. engine->start();
  77. ASSERT_NOTNULL(engine->session);
  78. session = engine->session;
  79. // Engine is up. Keep on truckin'
  80. m_queue.clear();
  81. pass_list.clear();
  82. }
  83. void TearDown() override {
  84. // Code here will be called immediately after each test (right
  85. // before the destructor).
  86. KRMT_fake_this = NULL;
  87. engine->shut_down();
  88. delete engine;
  89. engine = NULL;
  90. session = NULL;
  91. }
  92. void send_setup() {
  93. // Setup own identity
  94. PEP_STATUS status = read_file_and_import_key(session,
  95. "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc");
  96. assert(status == PEP_KEY_IMPORTED);
  97. status = set_up_ident_from_scratch(session,
  98. "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc",
  99. "pep.test.alice@pep-project.org", alice_fpr,
  100. alice_user_id.c_str(), "Alice in Wonderland", NULL, true
  101. );
  102. ASSERT_EQ(status, PEP_STATUS_OK);
  103. status = set_up_ident_from_scratch(session,
  104. "test_keys/pub/pep-test-bob-0xC9C2EE39_pub.asc",
  105. "pep.test.bob@pep-project.org", bob_fpr, bob_user_id.c_str(), "Bob's Burgers",
  106. NULL, false
  107. );
  108. ASSERT_EQ(status, PEP_STATUS_OK);
  109. status = set_up_ident_from_scratch(session,
  110. "test_keys/pub/pep-test-carol-0x42A85A42_pub.asc",
  111. "pep-test-carol@pep-project.org", carol_fpr, carol_user_id.c_str(), "Carol Burnett",
  112. NULL, false
  113. );
  114. ASSERT_EQ(status, PEP_STATUS_OK);
  115. status = set_up_ident_from_scratch(session,
  116. "test_keys/pub/pep-test-dave-0xBB5BCCF6_pub.asc",
  117. "pep-test-dave@pep-project.org", dave_fpr, dave_user_id.c_str(),
  118. "David Hasselhoff (Germans Love Me)", NULL, false
  119. );
  120. ASSERT_EQ(status, PEP_STATUS_OK);
  121. status = set_up_ident_from_scratch(session,
  122. "test_keys/pub/pep-test-erin-0x9F8D7CBA_pub.asc",
  123. "pep-test-erin@pep-project.org", erin_fpr, erin_user_id.c_str(),
  124. "Éirinn go Brách", NULL, false
  125. );
  126. ASSERT_EQ(status, PEP_STATUS_OK);
  127. status = set_up_ident_from_scratch(session,
  128. "test_keys/pub/pep.test.fenris-0x4F3D2900_pub.asc",
  129. "pep.test.fenris@thisstilldoesntwork.lu", fenris_fpr, fenris_user_id.c_str(),
  130. "Fenris Leto Hawke", NULL, false
  131. );
  132. ASSERT_EQ(status, PEP_STATUS_OK);
  133. }
  134. void receive_setup() {
  135. PEP_STATUS status = read_file_and_import_key(session,
  136. "test_keys/pub/pep-test-bob-0xC9C2EE39_pub.asc");
  137. assert(status == PEP_KEY_IMPORTED);
  138. status = set_up_ident_from_scratch(session,
  139. "test_keys/priv/pep-test-bob-0xC9C2EE39_priv.asc",
  140. "pep.test.bob@pep-project.org", bob_fpr,
  141. bob_user_id.c_str(), "Robert Redford", NULL, true
  142. );
  143. ASSERT_EQ(status, PEP_STATUS_OK);
  144. status = set_up_ident_from_scratch(session,
  145. "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc",
  146. "pep.test.alice@pep-project.org", alice_fpr, alice_user_id.c_str(), "Alice in Wonderland",
  147. NULL, false
  148. );
  149. ASSERT_EQ(status, PEP_STATUS_OK);
  150. }
  151. void create_msg_for_revoked_key() {
  152. PEP_STATUS status = set_up_ident_from_scratch(session,
  153. "test_keys/pub/pep-test-gabrielle-0xE203586C_pub.asc",
  154. "pep-test-gabrielle@pep-project.org", NULL, PEP_OWN_USERID,
  155. "Gabi", NULL, false
  156. );
  157. ASSERT_EQ(status, PEP_STATUS_OK);
  158. status = set_up_ident_from_scratch(session,
  159. "test_keys/priv/pep-test-gabrielle-0xE203586C_priv.asc",
  160. "pep-test-gabrielle@pep-project.org", NULL, PEP_OWN_USERID,
  161. "Gabi", NULL, false
  162. );
  163. ASSERT_EQ(status, PEP_STATUS_OK);
  164. status = set_up_ident_from_scratch(session,
  165. "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc",
  166. "pep.test.alice@pep-project.org", NULL, "AliceOther", "Alice in Wonderland",
  167. NULL, false
  168. );
  169. pEp_identity* from_ident = new_identity("pep-test-gabrielle@pep-project.org", NULL, PEP_OWN_USERID, NULL);
  170. status = myself(session, from_ident);
  171. ASSERT_OK;
  172. ASSERT_NOTNULL(from_ident->fpr);
  173. ASSERT_STRCASEEQ(from_ident->fpr, "906C9B8349954E82C5623C3C8C541BD4E203586C");
  174. ASSERT_TRUE(from_ident->me);
  175. // "send" some messages to update the social graph entries
  176. identity_list* send_idents =
  177. new_identity_list(
  178. new_identity("pep.test.alice@pep-project.org", NULL, "AliceOther", NULL));
  179. status = update_identity(session, send_idents->ident);
  180. ASSERT_OK;
  181. status = set_as_pEp_user(session, send_idents->ident);
  182. message* outgoing_msg = new_message(PEP_dir_outgoing);
  183. ASSERT_NOTNULL(outgoing_msg);
  184. outgoing_msg->from = from_ident;
  185. outgoing_msg->to = send_idents;
  186. outgoing_msg->shortmsg = strdup("Well isn't THIS a useless message...");
  187. outgoing_msg->longmsg = strdup("Hi Mom...\n");
  188. outgoing_msg->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL);
  189. output_stream << "Message created.\n\n";
  190. output_stream << "Encrypting message as MIME multipart…\n";
  191. message* enc_outgoing_msg = nullptr;
  192. output_stream << "Calling encrypt_message()\