1.1 --- a/test/src/engine_tests/DeviceModelTests.cc Thu Feb 14 13:23:29 2019 +0100
1.2 +++ b/test/src/engine_tests/DeviceModelTests.cc Sun Feb 17 14:38:56 2019 +0100
1.3 @@ -197,82 +197,48 @@
1.4 delete(second_device);
1.5 }
1.6
1.7 -// void DeviceModelTests::check_shared_mbox() {
1.8 -// // Set up devices and shared mailbox
1.9 -// pEpTestDevice* first_device = new pEpTestDevice(temp_test_home, "First");
1.10 -// first_device->set_mailbox_dir(first_device->device_dir + "/mbox");
1.11 -// first_device->unset_device_environment();
1.12 -// pEpTestDevice* second_device = new pEpTestDevice(temp_test_home, "Second");
1.13 -// second_device->set_mailbox_dir(first_device->device_dir + "/mbox");
1.14 -// first_device->grab_context(second_device);
1.15 -//
1.16 -// string alice_email = "pep.test.alice@pep-project.org";
1.17 -// string alice_fpr = "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97";
1.18 -//
1.19 -// // First device is Alice's established one with the current key
1.20 -// slurp_and_import_key(first_device->session, "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc");
1.21 -// slurp_and_import_key(first_device->session, "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc");
1.22 -//
1.23 -// pEp_identity* alice_dev_1_ident = new_identity(alice_email, alice_fpr, "ALICE", "Alice From Mel's Diner");
1.24 -//
1.25 -// PEP_STATUS status = set_own_key(first_device->session, alice_dev_1_ident, alice_fpr);
1.26 -//
1.27 -// second_device->grab_context(first_device);
1.28 -//
1.29 -// pEp_identity* alice_dev_2_ident = new_identity(alice_email, NULL, PEP_OWN_USERID, "Alice Miller");
1.30 -// // Second device is one Alice is setting up (we'll use this model for keysync tests, so why not?)
1.31 -//
1.32 -// status = myself(second_device->session, alice_dev_2_ident);
1.33 -//
1.34 -// const char* alice_2_fpr = alice_dev_2_ident->fpr;
1.35 -// char* alice_2_keydata = NULL;
1.36 -// size_t alice_2_keydata_size = 0;
1.37 -//
1.38 -// status = export_key(session, alice_2_fpr, &alice_2_keydata, &alice_2_keydata_size);
1.39 -//
1.40 -// first_device->grab_context(second_device);
1.41 -//
1.42 -// status = import_key(first_device->session, alice_2_keydata, alice_2_keydata_size);
1.43 -//
1.44 -// second_device->grab_context(first_device);
1.45 -// slurp_and_import_key(second_device->session, "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc");
1.46 -//
1.47 -//
1.48 -// cout << "creating message…\n";
1.49 -// pEp_identity * me2 = new_identity("pep.test.alice@pep-project.org", NULL, PEP_OWN_USERID, "Alice Test");
1.50 -// // pEp_identity * me2 = new_identity("test@nokey.plop", NULL, PEP_OWN_USERID, "Test no key");
1.51 -// me2->me = true;
1.52 -// identity_list *to2 = new_identity_list(new_identity("pep.test.bob@pep-project.org", NULL, "42", "Bob Test"));
1.53 -// // identity_list *to2 = new_identity_list(new_identity("still@nokey.blup", NULL, "42", "Still no key"));
1.54 -// message *msg2 = new_message(PEP_dir_outgoing);
1.55 -// TEST_ASSERT_MSG((msg2), "msg2");
1.56 -// msg2->from = me2;
1.57 -// msg2->to = to2;
1.58 -// msg2->shortmsg = strdup("hello, world");
1.59 -// msg2->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL);
1.60 -// cout << "message created.\n";
1.61 -//
1.62 -// char *text2 = nullptr;
1.63 -// PEP_STATUS status2 = mime_encode_message(msg2, false, &text2);
1.64 -// TEST_ASSERT_MSG((status2 == PEP_STATUS_OK), "status2 == PEP_STATUS_OK");
1.65 -// TEST_ASSERT_MSG((text2), "text2");
1.66 -//
1.67 -// cout << "decrypted:\n\n";
1.68 -// cout << text2 << "\n";
1.69 -//
1.70 -// free(text2);
1.71 -//
1.72 -// cout << "encrypting message as MIME multipart…\n";
1.73 -// message *enc_msg2 = nullptr;
1.74 -// cout << "calling encrypt_message()\n";
1.75 -// status2 = encrypt_message(session, msg2, NULL, &enc_msg2, PEP_enc_PGP_MIME, 0);
1.76 -// cout << "encrypt_message() returns " << status2 << '.' << endl;
1.77 -// TEST_ASSERT_MSG((status2 == PEP_STATUS_OK), "status2 == PEP_STATUS_OK");
1.78 -// TEST_ASSERT_MSG((enc_msg2), "enc_msg2");
1.79 -// cout << "message encrypted.\n";
1.80 -//
1.81 -// status2 = mime_encode_message(enc_msg2, false, &text2);
1.82 -// TEST_ASSERT_MSG((status2 == PEP_STATUS_OK), "status2 == PEP_STATUS_OK");
1.83 -// TEST_ASSERT_MSG((text2), "text2");
1.84 -//
1.85 -// }
1.86 +void DeviceModelTests::check_shared_mbox() {
1.87 + // Set up devices and shared mailbox
1.88 + pEpTestDevice* first_device = new pEpTestDevice(temp_test_home, "First");
1.89 + first_device->set_mailbox_dir(first_device->device_dir + "/mbox");
1.90 + first_device->unset_device_environment();
1.91 + pEpTestDevice* second_device = new pEpTestDevice(temp_test_home, "Second");
1.92 + second_device->set_mailbox_dir(first_device->device_dir + "/mbox");
1.93 + first_device->grab_context(second_device);
1.94 + TEST_ASSERT_MSG(first_device->mbox_dir.compare(second_device->mbox_dir) == 0,
1.95 + "Shared mailbox is not really shared");
1.96 +
1.97 + string alice_email = "pep.test.alice@pep-project.org";
1.98 + string alice_fpr = "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97";
1.99 +
1.100 + // First device is Alice's established one with the current key
1.101 + TEST_ASSERT_MSG(slurp_and_import_key(first_device->session, "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc"),
1.102 + "Alice's pubkey not imported for first device.");
1.103 + TEST_ASSERT_MSG(slurp_and_import_key(first_device->session, "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc"),
1.104 + "Alice's privkey not imported for first device.");
1.105 +
1.106 + pEp_identity* alice_dev_1_ident = new_identity(alice_email.c_str(), alice_fpr.c_str(), "ALICE", "Alice From Mel's Diner");
1.107 +
1.108 + PEP_STATUS status = set_own_key(first_device->session, alice_dev_1_ident, alice_fpr.c_str());
1.109 + TEST_ASSERT_MSG(status == PEP_STATUS_OK,
1.110 + (string("Unable to set own key on first device. status is ") + tl_status_string(status)).c_str());
1.111 +
1.112 + // Second device is one Alice is setting up (we'll use this model for keysync tests, so why not?)
1.113 + second_device->grab_context(first_device);
1.114 +
1.115 + pEp_identity* alice_dev_2_ident = new_identity(alice_email.c_str(), NULL, PEP_OWN_USERID, "Alice Miller");
1.116 +
1.117 + status = myself(second_device->session, alice_dev_2_ident);
1.118 +
1.119 + TEST_ASSERT_MSG(alice_dev_2_ident->fpr, "No fpr for alice on second device");
1.120 + TEST_ASSERT_MSG(alice_fpr.compare(alice_dev_2_ident->fpr) != 0,
1.121 + "myself did not generate new key for alice on device 2; alice's old key was found.");
1.122 +
1.123 + const char* alice_2_fpr = alice_dev_2_ident->fpr;
1.124 +
1.125 + // Ok, everybody's set up. Let's play with mailboxes.
1.126 +
1.127 + first_device->grab_context(second_device);
1.128 +
1.129 +
1.130 +}