Browse Source

Probably committing a whole lot of C++ sins, but preset was bugging me. Still not sure about that inline static object array. Will fix later.

IPS-2
Krista Bennett 12 months ago
parent
commit
52ddb9d36d
14 changed files with 206 additions and 328 deletions
  1. +11
    -11
      test/src/AsciiBinaryAtt998Test.cc
  2. +8
    -8
      test/src/DefaultFromEmailTest.cc
  3. +16
    -16
      test/src/EmptyLongmsgFullHtmlTest.cc
  4. +6
    -6
      test/src/Engine514Test.cc
  5. +2
    -2
      test/src/Engine704Test.cc
  6. +1
    -1
      test/src/GetKeyRatingForUserTest.cc
  7. +10
    -10
      test/src/IsOwnKeyTest.cc
  8. +7
    -7
      test/src/KeyResetMessageTest.cc
  9. +20
    -20
      test/src/Message2_1Test.cc
  10. +5
    -5
      test/src/ReencryptPlusExtraKeysTest.cc
  11. +4
    -4
      test/src/TestSetDefaultFPRTest.cc
  12. +18
    -199
      test/src/TestUtilities.cc
  13. +93
    -34
      test/src/TestUtilities.h
  14. +5
    -5
      test/src/UnencryptedPepMailTest.cc

+ 11
- 11
test/src/AsciiBinaryAtt998Test.cc View File

@ -9,7 +9,7 @@
#include "pEpEngine.h"
#include "pEp_internal.h"
#include "test_util.h"
#include "TestUtilities.h"
#include "TestConstants.h"
#include "Engine.h"
@ -86,14 +86,14 @@ namespace {
TEST_F(AsciiBinary998Test, check_engine_895) {
PEP_STATUS status = PEP_STATUS_OK;
pEp_identity* alice = NULL;
status = set_up_preset(session, ALICE, true, true, true, true, true, true, &alice);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALICE, true, true, true, true, true, true, &alice);
ASSERT_EQ(status, PEP_STATUS_OK);
ASSERT_NE(alice, nullptr);
status = myself(session, alice);
char* alicename = strdup(alice->username);
pEp_identity* alice_is_bob = NULL;
status = set_up_preset(session, BOB, true, true, true, true, false, true, &alice_is_bob);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::BOB, true, true, true, true, false, true, &alice_is_bob);
ASSERT_EQ(status, PEP_STATUS_OK);
ASSERT_NE(alice_is_bob, nullptr);
alice_is_bob->user_id = strdup(alice->user_id);
@ -177,14 +177,14 @@ TEST_F(AsciiBinary998Test, check_engine_895) {
TEST_F(AsciiBinary998Test, check_increasing_attachment_size_mime_encode) {
PEP_STATUS status = PEP_STATUS_OK;
pEp_identity* alice = NULL;
status = set_up_preset(session, ALICE, true, true, true, true, true, true, &alice);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALICE, true, true, true, true, true, true, &alice);
ASSERT_EQ(status, PEP_STATUS_OK);
ASSERT_NE(alice, nullptr);
status = myself(session, alice);
char* alicename = strdup(alice->username);
pEp_identity* alice_is_bob = NULL;
status = set_up_preset(session, BOB, true, true, true, true, false, true, &alice_is_bob);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::BOB, true, true, true, true, false, true, &alice_is_bob);
ASSERT_EQ(status, PEP_STATUS_OK);
ASSERT_NE(alice_is_bob, nullptr);
alice_is_bob->user_id = strdup(alice->user_id);
@ -218,14 +218,14 @@ TEST_F(AsciiBinary998Test, check_increasing_attachment_size_mime_encode) {
TEST_F(AsciiBinary998Test, check_997_strings_in_attachment) {
PEP_STATUS status = PEP_STATUS_OK;
pEp_identity* alice = NULL;
status = set_up_preset(session, ALICE, true, true, true, true, true, true, &alice);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALICE, true, true, true, true, true, true, &alice);
ASSERT_EQ(status, PEP_STATUS_OK);
ASSERT_NE(alice, nullptr);
status = myself(session, alice);
char* alicename = strdup(alice->username);
pEp_identity* alice_is_bob = NULL;
status = set_up_preset(session, BOB, true, true, true, true, false, true, &alice_is_bob);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::BOB, true, true, true, true, false, true, &alice_is_bob);
ASSERT_EQ(status, PEP_STATUS_OK);
ASSERT_NE(alice_is_bob, nullptr);
alice_is_bob->user_id = strdup(alice->user_id);
@ -267,14 +267,14 @@ TEST_F(AsciiBinary998Test, check_997_strings_in_attachment) {
TEST_F(AsciiBinary998Test, check_big_plaintext_998) {
PEP_STATUS status = PEP_STATUS_OK;
pEp_identity* alice = NULL;
status = set_up_preset(session, ALICE, true, true, true, true, true, true, &alice);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALICE, true, true, true, true, true, true, &alice);
ASSERT_EQ(status, PEP_STATUS_OK);
ASSERT_NE(alice, nullptr);
status = myself(session, alice);
char* alicename = strdup(alice->username);
pEp_identity* alice_is_bob = NULL;
status = set_up_preset(session, BOB, true, true, true, true, false, true, &alice_is_bob);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::BOB, true, true, true, true, false, true, &alice_is_bob);
ASSERT_EQ(status, PEP_STATUS_OK);
ASSERT_NE(alice_is_bob, nullptr);
alice_is_bob->user_id = strdup(alice->user_id);
@ -306,14 +306,14 @@ TEST_F(AsciiBinary998Test, check_big_plaintext_998) {
TEST_F(AsciiBinary998Test, check_big_plaintext_999) {
PEP_STATUS status = PEP_STATUS_OK;
pEp_identity* alice = NULL;
status = set_up_preset(session, ALICE, true, true, true, true, true, true, &alice);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALICE, true, true, true, true, true, true, &alice);
ASSERT_EQ(status, PEP_STATUS_OK);
ASSERT_NE(alice, nullptr);
status = myself(session, alice);
char* alicename = strdup(alice->username);
pEp_identity* alice_is_bob = NULL;
status = set_up_preset(session, BOB, true, true, true, true, false, true, &alice_is_bob);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::BOB, true, true, true, true, false, true, &alice_is_bob);
ASSERT_EQ(status, PEP_STATUS_OK);
ASSERT_NE(alice_is_bob, nullptr);
alice_is_bob->user_id = strdup(alice->user_id);


+ 8
- 8
test/src/DefaultFromEmailTest.cc View File

@ -81,11 +81,11 @@ namespace {
void create_base_test_msg(message** msg, unsigned int to_major, unsigned int to_minor, bool is_pEp) {
pEp_identity* from = NULL;
PEP_STATUS status = set_up_preset(session, JOHN, true, true, true, true, true, true, &from);
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::JOHN, true, true, true, true, true, true, &from);
ASSERT_OK;
pEp_identity* to = NULL;
status = set_up_preset(session, INQUISITOR, true, true,is_pEp, false, false, false, &to);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::INQUISITOR, true, true,is_pEp, false, false, false, &to);
ASSERT_OK;
to->major_ver = to_major;
to->minor_ver = to_minor;
@ -467,7 +467,7 @@ TEST_F(DefaultFromEmailTest, check_to_to_OpenPGP_import_bare_default) {
ASSERT_NOTNULL(enc_msg);
pEp_identity* me = NULL;
status = set_up_preset(session, INQUISITOR, true, true, true, true, true, true, &me);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::INQUISITOR, true, true, true, true, true, true, &me);
ASSERT_OK;
message* dec_msg = NULL;
@ -513,7 +513,7 @@ TEST_F(DefaultFromEmailTest, check_to_pEp_v1_import_bare_default) {
ASSERT_NOTNULL(enc_msg);
pEp_identity* me = NULL;
status = set_up_preset(session, INQUISITOR, true, true, true, true, true, true, &me);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::INQUISITOR, true, true, true, true, true, true, &me);
ASSERT_OK;
message* dec_msg = NULL;
@ -558,7 +558,7 @@ TEST_F(DefaultFromEmailTest, check_to_pEp_v2_0_import_bare_default) {
ASSERT_NOTNULL(enc_msg);
pEp_identity* me = NULL;
status = set_up_preset(session, INQUISITOR, true, true, true, true, true, true, &me);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::INQUISITOR, true, true, true, true, true, true, &me);
ASSERT_OK;
message* dec_msg = NULL;
@ -603,7 +603,7 @@ TEST_F(DefaultFromEmailTest, check_to_pEp_v2_1_import_bare_default) {
ASSERT_NOTNULL(enc_msg);
pEp_identity* me = NULL;
status = set_up_preset(session, INQUISITOR, true, true, true, true, true, true, &me);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::INQUISITOR, true, true, true, true, true, true, &me);
ASSERT_OK;
message* dec_msg = NULL;
@ -648,7 +648,7 @@ TEST_F(DefaultFromEmailTest, check_to_pEp_v2_2_import_bare_default) {
ASSERT_NOTNULL(enc_msg);
pEp_identity* me = NULL;
status = set_up_preset(session, INQUISITOR, true, true, true, true, true, true, &me);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::INQUISITOR, true, true, true, true, true, true, &me);
ASSERT_OK;
message* dec_msg = NULL;
@ -693,7 +693,7 @@ TEST_F(DefaultFromEmailTest, check_to_pEp_v10_111_import_bare_default) {
ASSERT_NOTNULL(enc_msg);
pEp_identity* me = NULL;
status = set_up_preset(session, INQUISITOR, true, true, true, true, true, true, &me);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::INQUISITOR, true, true, true, true, true, true, &me);
ASSERT_OK;
message* dec_msg = NULL;


+ 16
- 16
test/src/EmptyLongmsgFullHtmlTest.cc View File

@ -123,9 +123,9 @@ TEST_F(EmptyLongmsgFullHtmlTest, check_empty_longmsg_full_html_NULL) {
// This is just a dummy test case. The convention is check_whatever_you_are_checking
// so for multiple test cases in a suite, be more explicit ;)
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL, true, true, true, true, true, true, &carol);
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL, true, true, true, true, true, true, &carol);
pEp_identity* dave = NULL;
status = set_up_preset(session, DAVE, true, true, true, true, false, false, &dave);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::DAVE, true, true, true, true, false, false, &dave);
message* msg = new_message(PEP_dir_outgoing);
msg->from = carol;
@ -144,9 +144,9 @@ TEST_F(EmptyLongmsgFullHtmlTest, check_empty_longmsg_full_html_text_att) {
// This is just a dummy test case. The convention is check_whatever_you_are_checking
// so for multiple test cases in a suite, be more explicit ;)
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL, true, true, true, true, true, true, &carol);
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL, true, true, true, true, true, true, &carol);
pEp_identity* dave = NULL;
status = set_up_preset(session, DAVE, true, true, true, true, false, false, &dave);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::DAVE, true, true, true, true, false, false, &dave);
message* msg = new_message(PEP_dir_outgoing);
msg->from = carol;
@ -170,9 +170,9 @@ TEST_F(EmptyLongmsgFullHtmlTest, check_empty_longmsg_full_html_html_att) {
// This is just a dummy test case. The convention is check_whatever_you_are_checking
// so for multiple test cases in a suite, be more explicit ;)
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL, true, true, true, true, true, true, &carol);
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL, true, true, true, true, true, true, &carol);
pEp_identity* dave = NULL;
status = set_up_preset(session, DAVE, true, true, true, true, false, false, &dave);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::DAVE, true, true, true, true, false, false, &dave);
message* msg = new_message(PEP_dir_outgoing);
msg->from = carol;
@ -198,9 +198,9 @@ TEST_F(EmptyLongmsgFullHtmlTest, check_empty_longmsg_full_html_text_html_atts) {
// This is just a dummy test case. The convention is check_whatever_you_are_checking
// so for multiple test cases in a suite, be more explicit ;)
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL, true, true, true, true, true, true, &carol);
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL, true, true, true, true, true, true, &carol);
pEp_identity* dave = NULL;
status = set_up_preset(session, DAVE, true, true, true, true, false, false, &dave);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::DAVE, true, true, true, true, false, false, &dave);
message* msg = new_message(PEP_dir_outgoing);
msg->from = carol;
@ -240,9 +240,9 @@ TEST_F(EmptyLongmsgFullHtmlTest, check_empty_longmsg_full_html_text_html_atts) {
TEST_F(EmptyLongmsgFullHtmlTest, check_empty_longmsg_full_html_html_text_atts) {
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL, true, true, true, true, true, true, &carol);
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL, true, true, true, true, true, true, &carol);
pEp_identity* dave = NULL;
status = set_up_preset(session, DAVE, true, true, true, true, false, false, &dave);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::DAVE, true, true, true, true, false, false, &dave);
message* msg = new_message(PEP_dir_outgoing);
msg->from = carol;
@ -282,9 +282,9 @@ TEST_F(EmptyLongmsgFullHtmlTest, check_empty_longmsg_full_html_text_empty) {
// This is just a dummy test case. The convention is check_whatever_you_are_checking
// so for multiple test cases in a suite, be more explicit ;)
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL, true, true, true, true, true, true, &carol);
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL, true, true, true, true, true, true, &carol);
pEp_identity* dave = NULL;
status = set_up_preset(session, DAVE, true, true, true, true, false, false, &dave);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::DAVE, true, true, true, true, false, false, &dave);
message* msg = new_message(PEP_dir_outgoing);
msg->from = carol;
@ -304,9 +304,9 @@ TEST_F(EmptyLongmsgFullHtmlTest, check_empty_longmsg_full_html_text_inline_att)
// This is just a dummy test case. The convention is check_whatever_you_are_checking
// so for multiple test cases in a suite, be more explicit ;)
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL, true, true, true, true, true, true, &carol);
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL, true, true, true, true, true, true, &carol);
pEp_identity* dave = NULL;
status = set_up_preset(session, DAVE, true, true, true, true, false, false, &dave);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::DAVE, true, true, true, true, false, false, &dave);
message* msg = new_message(PEP_dir_outgoing);
msg->from = carol;
@ -353,9 +353,9 @@ TEST_F(EmptyLongmsgFullHtmlTest, check_empty_longmsg_full_html_text_inline_att_p
// This is just a dummy test case. The convention is check_whatever_you_are_checking
// so for multiple test cases in a suite, be more explicit ;)
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL, true, true, true, true, true, true, &carol);
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL, true, true, true, true, true, true, &carol);
pEp_identity* dave = NULL;
status = set_up_preset(session, DAVE, true, true, true, true, false, false, &dave);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::DAVE, true, true, true, true, false, false, &dave);
message* msg = new_message(PEP_dir_outgoing);
msg->from = carol;


+ 6
- 6
test/src/Engine514Test.cc View File

@ -99,7 +99,7 @@ TEST_F(Engine514Test, check_engine514_unencrypted) {
message* msg = new_message(PEP_dir_outgoing);
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL, true, true, true, true, true, true, &carol);
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL, true, true, true, true, true, true, &carol);
ASSERT_EQ(status, PEP_STATUS_OK);
ASSERT_NOTNULL(carol);
status = myself(session, carol);
@ -150,7 +150,7 @@ TEST_F(Engine514Test, check_engine514_unencrypted_second_position) {
message* msg = new_message(PEP_dir_outgoing);
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL, true, true, true, true, true, true, &carol);
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL, true, true, true, true, true, true, &carol);
ASSERT_EQ(status, PEP_STATUS_OK);
ASSERT_NOTNULL(carol);
status = myself(session, carol);
@ -199,14 +199,14 @@ TEST_F(Engine514Test, check_engine514_encode_and_decode) {
message* msg = new_message(PEP_dir_outgoing);
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL, true, true, true, true, true, true, &carol);
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL, true, true, true, true, true, true, &carol);
ASSERT_EQ(status, PEP_STATUS_OK);
ASSERT_NOTNULL(carol);
status = myself(session, carol);
ASSERT_EQ(status, PEP_STATUS_OK);
pEp_identity* dave = NULL;
status = set_up_preset(session, DAVE, true, true, true, true, false, false, &dave);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::DAVE, true, true, true, true, false, false, &dave);
msg->from = carol;
msg->to = new_identity_list(dave);
msg->shortmsg = strdup("This is the actual message");
@ -246,14 +246,14 @@ TEST_F(Engine514Test, check_engine514_encrypted) {
message* msg = new_message(PEP_dir_outgoing);
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL, true, true, true, true, true, true, &carol);
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL, true, true, true, true, true, true, &carol);
ASSERT_EQ(status, PEP_STATUS_OK);
ASSERT_NOTNULL(carol);
status = myself(session, carol);
ASSERT_EQ(status, PEP_STATUS_OK);
pEp_identity* dave = NULL;
status = set_up_preset(session, DAVE, true, true, true, true, false, false, &dave);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::DAVE, true, true, true, true, false, false, &dave);
msg->from = carol;
msg->to = new_identity_list(dave);
msg->shortmsg = strdup("This is the actual message");


+ 2
- 2
test/src/Engine704Test.cc View File

@ -81,14 +81,14 @@ namespace {
TEST_F(Engine704Test, check_engine704) {
PEP_STATUS status = PEP_STATUS_OK;
pEp_identity* alice = NULL;
status = set_up_preset(session, ALICE, true, true, true, true, true, true, &alice);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALICE, true, true, true, true, true, true, &alice);
ASSERT_EQ(status, PEP_STATUS_OK);
ASSERT_NOTNULL(alice);
status = myself(session, alice);
char* alicename = strdup(alice->username);
pEp_identity* alice_is_bob = NULL;
status = set_up_preset(session, BOB, false, true, true, true, false, true, &alice_is_bob);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::BOB, false, true, true, true, false, true, &alice_is_bob);
alice_is_bob->fpr = strdup("BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39");
ASSERT_EQ(status, PEP_STATUS_OK);
ASSERT_NOTNULL(alice_is_bob);


+ 1
- 1
test/src/GetKeyRatingForUserTest.cc View File

@ -87,7 +87,7 @@ namespace {
TEST_F(GetKeyRatingForUserTest, check_get_key_rating_for_user) {
pEp_identity* alice = NULL;
PEP_STATUS status = set_up_preset(session, ALICE, false, true,false, false, false, false, &alice);
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALICE, false, true,false, false, false, false, &alice);
pEp_identity* test_null = NULL;
const char* fpr_save = alice->fpr;
alice->fpr = NULL;


+ 10
- 10
test/src/IsOwnKeyTest.cc View File

@ -80,7 +80,7 @@ namespace {
/*
PEP_STATUS set_up_preset(PEP_SESSION session,
pEp_test_ident_preset preset_name,
ident_preset preset_name,
bool set_ident,
bool set_pep,
bool trust,
@ -90,7 +90,7 @@ PEP_STATUS set_up_preset(PEP_SESSION session,
*/
TEST_F(IsOwnKeyTest, check_is_own_key_normal) {
pEp_identity* alice = NULL;
PEP_STATUS status = set_up_preset(session, ALICE, true, true, true, true, true, true, &alice);
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALICE, true, true, true, true, true, true, &alice);
ASSERT_OK;
bool is_own = false;
status = is_own_key(session, alice->fpr, &is_own);
@ -103,7 +103,7 @@ TEST_F(IsOwnKeyTest, check_is_own_key_OpenPGP) {
TEST_F(IsOwnKeyTest, check_is_own_key_external_revoked) {
pEp_identity* alice = NULL;
PEP_STATUS status = set_up_preset(session, ALICE, true, true, true, true, true, true, &alice);
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALICE, true, true, true, true, true, true, &alice);
ASSERT_OK;
bool is_own = false;
status = is_own_key(session, alice->fpr, &is_own);
@ -119,7 +119,7 @@ TEST_F(IsOwnKeyTest, check_is_own_key_external_revoked) {
TEST_F(IsOwnKeyTest, check_is_own_key_external_marked_revoked) {
pEp_identity* alice = NULL;
PEP_STATUS status = set_up_preset(session, ALICE, true, true, true, true, true, true, &alice);
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALICE, true, true, true, true, true, true, &alice);
ASSERT_OK;
bool is_own = false;
status = is_own_key(session, alice->fpr, &is_own);
@ -142,7 +142,7 @@ TEST_F(IsOwnKeyTest, check_is_own_key_external_marked_revoked) {
TEST_F(IsOwnKeyTest, check_is_own_key_revoked_through_reset) { // Probably mistrusted case...
pEp_identity* alice = NULL;
PEP_STATUS status = set_up_preset(session, ALICE, true, true, true, true, true, true, &alice);
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALICE, true, true, true, true, true, true, &alice);
ASSERT_OK;
bool is_own = false;
status = is_own_key(session, alice->fpr, &is_own);
@ -158,7 +158,7 @@ TEST_F(IsOwnKeyTest, check_is_own_key_revoked_through_reset) { // Probably mistr
TEST_F(IsOwnKeyTest, check_is_own_key_mistrusted) {
pEp_identity* alice = NULL;
PEP_STATUS status = set_up_preset(session, ALICE, true, true, true, true, true, true, &alice);
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALICE, true, true, true, true, true, true, &alice);
ASSERT_OK;
bool is_own = false;
status = is_own_key(session, alice->fpr, &is_own);
@ -188,12 +188,12 @@ TEST_F(IsOwnKeyTest, check_is_own_key_expired) {
TEST_F(IsOwnKeyTest, check_is_key_someone_elses_pubkey) {
pEp_identity* alice = NULL;
PEP_STATUS status = set_up_preset(session, ALICE, true, true, true, true, true, true, &alice);
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALICE, true, true, true, true, true, true, &alice);
ASSERT_OK;
// Dave == NOT OWN
pEp_identity* dave = NULL;
status = set_up_preset(session, DAVE, true, true, true, true, false, false, &dave);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::DAVE, true, true, true, true, false, false, &dave);
// import the private part also
const char* dave_fpr = "E8AC9779A2D13A15D8D55C84B049F489BB5BCCF6";
@ -205,12 +205,12 @@ TEST_F(IsOwnKeyTest, check_is_key_someone_elses_pubkey) {
TEST_F(IsOwnKeyTest, check_is_non_own_priv_key) {
pEp_identity* alice = NULL;
PEP_STATUS status = set_up_preset(session, ALICE, true, true, true, true, true, true, &alice);
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALICE, true, true, true, true, true, true, &alice);
ASSERT_OK;
// Dave == NOT OWN
pEp_identity* dave = NULL;
status = set_up_preset(session, DAVE, true, true, true, true, false, false, &dave);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::DAVE, true, true, true, true, false, false, &dave);
// import the private part also
bool imported = slurp_and_import_key(session, "test_keys/priv/pep-test-dave-0xBB5BCCF6_priv.asc");
ASSERT_TRUE(imported);


+ 7
- 7
test/src/KeyResetMessageTest.cc View File

@ -2593,7 +2593,7 @@ test_keys/pub/pep.test.alexander6-0xBDA17020_pub.asc
TEST_F(KeyResetMessageTest, not_a_test) {
pEp_identity* bob = NULL;
PEP_STATUS status = set_up_preset(session, BOB,
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::BOB,
true, true, true, true, true, true, &bob);
const char* carol_fpr = "8DD4F5827B45839E9ACCA94687BDDFFB42A85A42";
@ -2625,7 +2625,7 @@ TEST_F(KeyResetMessageTest, not_a_test) {
TEST_F(KeyResetMessageTest, check_no_reset_message_to_self) {
pEp_identity* bob = NULL;
PEP_STATUS status = set_up_preset(session, BOB,
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::BOB,
true, true, true, true, true, true, &bob);
slurp_and_import_key(session, "test_keys/pub/pep-test-bob-0xC9C2EE39_pub.asc");
@ -2656,7 +2656,7 @@ TEST_F(KeyResetMessageTest, check_no_reset_message_to_self) {
TEST_F(KeyResetMessageTest, check_reset_mistrust_next_msg_have_not_mailed) {
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL,
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL,
true, true, true, true, true, true, &carol);
status = myself(session, carol);
@ -3223,19 +3223,19 @@ TEST_F(KeyResetMessageTest, check_reset_own_with_revocations) {
pEp_identity* id1 = new_identity("krista-not-real@darthmama.org", NULL, PEP_OWN_USERID, "Krista at Home");
PEP_STATUS status = myself(session, id1);
pEp_identity* id2 = NULL;
status = set_up_preset(session, ALICE, true, true, true, false, false, false, &id2);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALICE, true, true, true, false, false, false, &id2);
pEp_identity* id3 = new_identity("krista-not-real@angryshark.eu", NULL, PEP_OWN_USERID, "Krista at Shark");
status = myself(session, id3);
pEp_identity* id4 = NULL;
status = set_up_preset(session, BOB, true, true,false, false, false, false, &id4);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::BOB, true, true,false, false, false, false, &id4);
pEp_identity* id5 = new_identity("krista-not-real@pep.foundation", NULL, PEP_OWN_USERID, "Krista at Work");
status = myself(session, id5);
pEp_identity* id6 = new_identity("grrrr-not-real@angryshark.eu", NULL, PEP_OWN_USERID, "GRRRR is a Shark");
status = myself(session, id6);
pEp_identity* id7 = NULL;
status = set_up_preset(session, CAROL, true, true,false, true, false, false, &id7);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL, true, true,false, true, false, false, &id7);
pEp_identity* id8 = NULL;
status = set_up_preset(session, DAVE, true, true, true, true, false, false, &id8);
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::DAVE, true, true, true, true, false, false, &id8);
identity_list* own_identities = NULL;
stringlist_t* revocations = NULL;


+ 20
- 20
test/src/Message2_1Test.cc View File

@ -138,13 +138,13 @@ TEST_F(Message2_1Test, check_message2_1_recip_2_0) {
pEp_identity* alice = NULL;
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, ALICE,
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALICE,
true, true, true, true, true, true, &alice);
ASSERT_OK;
ASSERT_NOTNULL(alice);
status = set_up_preset(session, CAROL,
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL,
true, true, true, false, false, false, &carol);
ASSERT_OK;
@ -181,7 +181,7 @@ TEST_F(Message2_1Test, check_message2_1_recip_2_0) {
}
/* PEP_STATUS set_up_preset(PEP_SESSION session,
pEp_test_ident_preset preset_name,
ident_preset preset_name,
bool set_ident,
bool set_pep,
bool trust,
@ -195,13 +195,13 @@ TEST_F(Message2_1Test, check_message2_1_recip_OpenPGP) {
pEp_identity* alice = NULL;
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, ALICE,
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALICE,
true, true, true, true, true, true, &alice);
ASSERT_OK;
ASSERT_NOTNULL(alice);
status = set_up_preset(session, CAROL,
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL,
true, true, false, false, false, false, &carol);
ASSERT_OK;
@ -243,13 +243,13 @@ TEST_F(Message2_1Test, check_message2_1_recip_2_1) {
pEp_identity* alice = NULL;
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, ALICE,
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALICE,
true, true, true, true, true, true, &alice);
ASSERT_OK;
ASSERT_NOTNULL(alice);
status = set_up_preset(session, CAROL,
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL,
true, true, true, false, false, false, &carol);
ASSERT_OK;
@ -290,7 +290,7 @@ TEST_F(Message2_1Test, check_message2_1_recip_2_1) {
TEST_F(Message2_1Test, check_message2_1_recip_1_0_from_msg_OpenPGP) {
pEp_identity* alex = NULL;
PEP_STATUS status = set_up_preset(session, ALEX_0,
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALEX_0,
true, true, true, true, true, true, &alex);
ASSERT_OK;
@ -337,7 +337,7 @@ TEST_F(Message2_1Test, check_message2_1_recip_2_0_from_msg) {
// receive 2.0 message
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL,
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL,
true, true, true, true, true, true, &carol);
ASSERT_OK;
@ -384,7 +384,7 @@ TEST_F(Message2_1Test, check_message2_1_recip_2_1_from_msg) {
// receive 2.1 message
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL,
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL,
true, true, true, true, true, true, &carol);
ASSERT_OK;
@ -440,13 +440,13 @@ TEST_F(Message2_1Test, check_message2_1_recip_mixed_2_0) {
pEp_identity* dave = NULL;
pEp_identity* alex = NULL;
PEP_STATUS status = set_up_preset(session, ALICE,
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALICE,
true, true, true, true, true, true, &alice);
ASSERT_OK;
ASSERT_NOTNULL(alice);
status = set_up_preset(session, BOB,
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::BOB,
true, true, true, false, false, false, &bob);
ASSERT_OK;
@ -460,7 +460,7 @@ TEST_F(Message2_1Test, check_message2_1_recip_mixed_2_0) {
ASSERT_EQ(bob->major_ver , 2);
ASSERT_EQ(bob->minor_ver , 1);
status = set_up_preset(session, CAROL,
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL,
true, true, true, false, false, false, &carol);
ASSERT_OK;
@ -474,7 +474,7 @@ TEST_F(Message2_1Test, check_message2_1_recip_mixed_2_0) {
ASSERT_EQ(carol->major_ver , 2);
ASSERT_EQ(carol->minor_ver , 1);
status = set_up_preset(session, DAVE,
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::DAVE,
true, true, true, false, false, false, &dave);
ASSERT_OK;
@ -488,7 +488,7 @@ TEST_F(Message2_1Test, check_message2_1_recip_mixed_2_0) {
ASSERT_EQ(dave->major_ver , 2);
ASSERT_EQ(dave->minor_ver , 0);
status = set_up_preset(session, ALEX,
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALEX,
true, true, true, true, false, false, &alex);
ASSERT_OK;
@ -535,13 +535,13 @@ TEST_F(Message2_1Test, check_message2_1_recip_mixed_1_0_OpenPGP) {
pEp_identity* dave = NULL;
pEp_identity* alex = NULL;
PEP_STATUS status = set_up_preset(session, ALICE,
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALICE,
true, true, true, true, true, true, &alice);
ASSERT_OK;
ASSERT_NOTNULL(alice);
status = set_up_preset(session, BOB,
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::BOB,
true, true, true, false, false, false, &bob);
ASSERT_OK;
@ -555,7 +555,7 @@ TEST_F(Message2_1Test, check_message2_1_recip_mixed_1_0_OpenPGP) {
ASSERT_EQ(bob->major_ver , 2);
ASSERT_EQ(bob->minor_ver , 1);
status = set_up_preset(session, CAROL,
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL,
true, true, true, false, false, false, &carol);
ASSERT_OK;
@ -569,7 +569,7 @@ TEST_F(Message2_1Test, check_message2_1_recip_mixed_1_0_OpenPGP) {
ASSERT_EQ(carol->major_ver , 2);
ASSERT_EQ(carol->minor_ver , 1);
status = set_up_preset(session, DAVE,
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::DAVE,
true, true, true, false, false, false, &dave);
ASSERT_OK;
@ -583,7 +583,7 @@ TEST_F(Message2_1Test, check_message2_1_recip_mixed_1_0_OpenPGP) {
ASSERT_EQ(dave->major_ver , 2);
ASSERT_EQ(dave->minor_ver , 0);
status = set_up_preset(session, ALEX,
status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALEX,
true, true, false, true, false, false, &alex);
ASSERT_OK;


+ 5
- 5
test/src/ReencryptPlusExtraKeysTest.cc View File

@ -150,7 +150,7 @@ TEST_F(ReencryptPlusExtraKeysTest, check_reencrypt_unencrypted_subj) {
config_unencrypted_subject(session, true);
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL,
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL,
true, true, true, true, true, true, &carol);
ASSERT_OK;
@ -204,7 +204,7 @@ TEST_F(ReencryptPlusExtraKeysTest, check_reencrypt_unencrypted_subj_check_effici
config_unencrypted_subject(session, true);
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL,
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL,
true, true, true, true, true, true, &carol);
ASSERT_OK;
@ -280,7 +280,7 @@ TEST_F(ReencryptPlusExtraKeysTest, check_reencrypt_unencrypted_subj_extra_keys)
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL,
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL,
true, true, true, true, true, true, &carol);
ASSERT_EQ(status, PEP_STATUS_OK);
@ -371,7 +371,7 @@ TEST_F(ReencryptPlusExtraKeysTest, check_reencrypt_unencrypted_subj_extra_keys_e
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL,
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL,
true, true, true, true, true, true, &carol);
ASSERT_EQ(status, PEP_STATUS_OK);
@ -451,7 +451,7 @@ TEST_F(ReencryptPlusExtraKeysTest, check_reencrypt_unencrypted_subj_extra_keys_e
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL,
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL,
true, true, true, true, true, true, &carol);
ASSERT_EQ(status, PEP_STATUS_OK);


+ 4
- 4
test/src/TestSetDefaultFPRTest.cc View File

@ -82,7 +82,7 @@ namespace {
TEST_F(TestSetDefaultFPRTest, check_test_set_default_fpr) {
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL,
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL,
true, false, true, false, false, false, &carol);
ASSERT_EQ(carol->fpr, nullptr);
status = update_identity(session, carol);
@ -110,7 +110,7 @@ TEST_F(TestSetDefaultFPRTest, check_test_set_default_fpr) {
TEST_F(TestSetDefaultFPRTest, check_test_set_comm_partner_key) {
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL,
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL,
true, false, true, false, false, false, &carol);
status = set_comm_partner_key(session, carol, carol_fpr);
ASSERT_OK;
@ -134,7 +134,7 @@ TEST_F(TestSetDefaultFPRTest, check_test_set_comm_partner_key) {
TEST_F(TestSetDefaultFPRTest, check_test_set_default_no_identity) {
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL,
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL,
true, false, true, false, false, false, &carol);
status = update_identity(session, carol);
ASSERT_OK;
@ -162,7 +162,7 @@ TEST_F(TestSetDefaultFPRTest, check_test_set_default_no_identity) {
TEST_F(TestSetDefaultFPRTest, check_test_set_comm_partner_key_no_set_identity) {
pEp_identity* carol = NULL;
PEP_STATUS status = set_up_preset(session, CAROL,
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::CAROL,
false, false, false, false, false, false, &carol);
string user_id_cache = carol->user_id;
status = set_comm_partner_key(session, carol, carol_fpr);


+ 18
- 199
test/src/TestUtilities.cc View File

@ -866,25 +866,20 @@ PEP_STATUS set_fpr_preserve_ident(PEP_SESSION session, const pEp_identity* ident
return status;
}
PEP_STATUS set_up_preset(PEP_SESSION session,
pEp_test_ident_preset preset_name,
bool set_ident,
bool set_fpr,
bool set_pep,
bool trust,
bool set_own,
bool setup_private,
pEp_identity** ident) {
PEP_STATUS TestUtilsPreset::set_up_preset(PEP_SESSION session,
ident_preset preset_name,
bool set_ident,
bool set_fpr,
bool set_pep,
bool trust,
bool set_own,
bool setup_private,
pEp_identity** ident) {
if (set_own && !set_ident)
return PEP_ILLEGAL_VALUE;
const char* name = NULL;
const char* user_id = NULL;
const char* email = NULL;
const char* key_prefix = NULL;
string pubkey_dir = "test_keys/pub/";
string privkey_dir = "test_keys/priv/";
const char* fpr = NULL;
PEP_STATUS status = PEP_STATUS_OK;
if (ident)
@ -892,188 +887,13 @@ PEP_STATUS set_up_preset(PEP_SESSION session,
pEp_identity* retval = NULL;
switch (preset_name) {
case ALICE:
name = "Alice Spivak Hyatt";
user_id = "ALICE";
email = "pep.test.alice@pep-project.org";
key_prefix = "pep-test-alice-0x6FF00E97";
fpr = "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97";
break;
case APPLE:
name = "Apple of my Computer";
user_id = "APPLE";
email = "pep.test.apple@pep-project.org";
key_prefix = "pep-test-apple-0x1CCBC7D7";
fpr = "3D8D9423D03DDF61B60161150313D94A1CCBC7D7";
break;
case BOB:
name = "Bob Dog";
user_id = "BOB";
email = "pep.test.bob@pep-project.org";
key_prefix = "pep-test-bob-0xC9C2EE39";
fpr = "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39";
break;
case CAROL:
name = "Carol Burnett";
user_id = "CAROL";
email = "pep-test-carol@pep-project.org";
key_prefix = "pep-test-carol-0x42A85A42";
fpr = "8DD4F5827B45839E9ACCA94687BDDFFB42A85A42";
break;
case DAVE:
name = "The Hoff";
user_id = "DAVE";
email = "pep-test-dave@pep-project.org";
key_prefix = "pep-test-dave-0xBB5BCCF6";
fpr = "E8AC9779A2D13A15D8D55C84B049F489BB5BCCF6";
break;
case ERIN:
name = "Erin Ireland";
user_id = "ERIN";
email = "pep-test-erin@pep-project.org";
key_prefix = "pep-test-erin-0x9F8D7CBA";
fpr = "1B0E197E8AE66277B8A024B9AEA69F509F8D7CBA";
break;
case FRANK:
name = "Frank N. Furter";
user_id = "FRANK";
email = "pep-test-frank@pep-project.org";
key_prefix = "pep-test-frank-0x9A7FC670";
fpr = "B022B74476D8A8E1F01E55FBAB6972569A7FC670"; // currently expired
break;
case GABRIELLE:
name = "Gabrielle Gonzales";
user_id = "GABI";
email = "pep-test-gabrielle@pep-project.org";
key_prefix = "pep-test-gabrielle-0xE203586C";
fpr = "906C9B8349954E82C5623C3C8C541BD4E203586C";
break;
case JOHN:
name = "John Denver";
user_id = "JOHN";
email = "pep.test.john@pep-project.org";
key_prefix = "pep-test-john-0x70DCF575";
fpr = "AA2E4BEB93E5FE33DEFD8BE1135CD6D170DCF575";
break;
case ALEX:
name = "Alex Braithwaite";
user_id = "ALEX";
email = "pep.test.alexander@peptest.ch";
key_prefix = "pep.test.alexander-0x26B54E4E";
fpr = "3AD9F60FAEB22675DB873A1362D6981326B54E4E";
break;
case ALEX_0:
name = "Alex Braithwaite";
user_id = "ALEX";
email = "pep.test.alexander0@darthmama.org";
key_prefix = "pep.test.alexander0-0x3B7302DB";
fpr = "F4598A17D4690EB3B5B0F6A344F04E963B7302DB";
break;
case ALEX_1:
name = "Alex Braithwaite";
user_id = "ALEX";
email = "pep.test.alexander1@darthmama.org";
key_prefix = "pep.test.alexander1-0x541260F6";
fpr = "59AF4C51492283522F6904531C09730A541260F6";
break;
case ALEX_2:
name = "Alex Braithwaite";
user_id = "ALEX";
email = "pep.test.alexander2@darthmama.org";
key_prefix = "pep.test.alexander2-0xA6512F30";
fpr = "46A994F19077C05610870273C4B8AB0BA6512F30";
break;
case ALEX_3:
name = "Alex Braithwaite";
user_id = "ALEX";
email = "pep.test.alexander3@darthmama.org";
key_prefix = "pep.test.alexander3-0x724B3975";
fpr = "5F7076BBD92E14EA49F0DF7C2CE49419724B3975";
break;
case ALEX_4:
name = "Alex Braithwaite";
user_id = "ALEX";
email = "pep.test.alexander4@darthmama.org";
key_prefix = "pep.test.alexander4-0x844B9DCF";
fpr = "E95FFF95B8E2FDD4A12C3374395F1485844B9DCF";
break;
case ALEX_5:
name = "Alex Braithwaite";
user_id = "ALEX";
email = "pep.test.alexander5@darthmama.org";
key_prefix = "pep.test.alexander5-0x0773CD29";
fpr = "58BCC2BF2AE1E3C4FBEAB89AD7838ACA0773CD29";
break;
case ALEX_6A:
name = "Alex Braithwaite";
user_id = "ALEX";
email = "pep.test.alexander6@darthmama.org";
key_prefix = "pep.test.alexander6-0x0019697D";
fpr = "74D79B4496E289BD8A71B70BA8E2C4530019697D";
break;
case ALEX_6B:
name = "Alex Braithwaite";
user_id = "ALEX";
email = "pep.test.alexander6@darthmama.org";
key_prefix = "pep.test.alexander6-0x503B14D8";
fpr = "2E21325D202A44BFD9C607FCF095B202503B14D8";
break;
case ALEX_6C:
name = "Alex Braithwaite";
user_id = "ALEX";
email = "pep.test.alexander6@darthmama.org";
key_prefix = "pep.test.alexander6-0xA216E95A";
fpr = "3C1E713D8519D7F907E3142D179EAA24A216E95A";
break;
case ALEX_6D:
name = "Alex Braithwaite";
user_id = "ALEX";
email = "pep.test.alexander6@darthmama.org";
key_prefix = "pep.test.alexander6-0xBDA17020";
fpr = "B4CE2F6947B6947C500F0687AEFDE530BDA17020";
break;
case BELLA:
name = "Bella Cat";
user_id = "BELLA";
email = "pep.test.bella@peptest.ch";
key_prefix = "pep.test.bella-0xAF516AAE";
fpr = "5631BF1357326A02AA470EEEB815EF7FA4516AAE";
break;
case FENRIS:
name = "Fenris Leto Hawke";
user_id = "FENRIS";
email = "pep.test.fenris@thisstilldoesntwork.lu";
key_prefix = "pep.test.fenris-0x4F3D2900";
fpr = "0969FA229DF21C832A64A04711B1B9804F3D2900";
break;
case SERCULLEN:
name = "Cullen Rutherford";
user_id = "CULLEN";
email = "sercullen-test@darthmama.org";
key_prefix = "sercullen-0x3CEAADED4"; // NB expired on purpose
fpr = "1C9666D8B3E28F4AA3847DA89A6E75E3CEAADED4";
break;
case INQUISITOR:
name = "Inquisitor Claire Trevelyan";
user_id = "INQUISITOR";
email = "inquisitor@darthmama.org";
key_prefix = "inquisitor-0xA4728718_renewed";
fpr = "8E8D2381AE066ABE1FEE509821BA977CA4728718";
break;
case BERND:
name = "Bernd das Brot";
user_id = "BERNDI";
email = "bernd.das.brot@darthmama.org";
key_prefix = "bernd.das.brot-0xCAFAA422";
fpr = "F8CE0F7E24EB190A2FCBFD38D4B088A7CAFAA422";
break;
default:
return PEP_CANNOT_SET_IDENTITY;
}
if (preset_name >= PRESETS_LEN)
return PEP_ILLEGAL_VALUE;
const TestUtilsPreset::IdentityInfo& preset = presets[preset_name];
string pubkey_file = pubkey_dir + key_prefix + "_pub.asc";
string privkey_file = privkey_dir + key_prefix + "_priv.asc";
string pubkey_file = pubkey_dir + preset.key_prefix + "_pub.asc";
string privkey_file = privkey_dir + preset.key_prefix + "_priv.asc";
if (!slurp_and_import_key(session, pubkey_file.c_str()))
return PEP_KEY_NOT_FOUND;
@ -1083,19 +903,19 @@ PEP_STATUS set_up_preset(PEP_SESSION session,
return PEP_KEY_NOT_FOUND;
}
retval = new_identity(email, NULL, user_id, name);
retval = new_identity(preset.email, NULL, preset.user_id, preset.name);
if (!retval)
return PEP_OUT_OF_MEMORY;
// honestly probably happens anyway
if (set_ident && status == PEP_STATUS_OK) {
retval->fpr = set_fpr ? strdup(fpr) : NULL;
retval->fpr = set_fpr ? strdup(preset.fpr) : NULL;
status = set_identity(session, retval);
}
if (set_own) {
retval->me = true;
status = set_own_key(session, retval, fpr);
status = set_own_key(session, retval, preset.fpr);
}
if (set_pep && status == PEP_STATUS_OK)
@ -1110,7 +930,6 @@ PEP_STATUS set_up_preset(PEP_SESSION session,
}
}
if (ident)
*ident = retval;
else


+ 93
- 34
test/src/TestUtilities.h View File

@ -45,47 +45,106 @@ extern std::ostream output_stream;
#define output_stream std::cerr
#endif
std::string get_main_test_home_dir();
std::string random_string( size_t length );
class TestUtilsPreset {
public:
typedef enum _pEp_test_ident_preset {
ALICE,
APPLE,
BOB,
CAROL,
DAVE,
ERIN,
FRANK,
GABRIELLE,
JOHN,
ALEX,
ALEX_0,
ALEX_1,
ALEX_2,
ALEX_3,
ALEX_4,
ALEX_5,
ALEX_6A,
ALEX_6B,
ALEX_6C,
ALEX_6D,
BELLA,
FENRIS,
SERCULLEN,
INQUISITOR,
BERND
} pEp_test_ident_preset;
PEP_STATUS set_up_preset(PEP_SESSION session,
pEp_test_ident_preset preset_name,
class IdentityInfo {
public:
// instance stuff
char* name;
char* user_id;
char* email;
char* key_prefix;
char* fpr;
IdentityInfo(const char* name, const char* user_id, const char* email, const char* key_prefix, const char* fpr) {
this->name = strdup(name);
this->user_id = strdup(user_id);
this->email = strdup(email);
this->key_prefix = strdup(key_prefix);
this->fpr = strdup(fpr);
}
~IdentityInfo() {
free(name);
free(user_id);
free(email);
free(key_prefix);
free(fpr);
}
};
// static stuff
typedef enum _ident_preset {
ALICE = 0,
APPLE = 1,
BOB = 2,
CAROL = 3,
DAVE = 4,
ERIN = 5,
FRANK = 6,
GABRIELLE = 7,
JOHN = 8,
ALEX = 9,
ALEX_0 = 10,
ALEX_1 = 11,
ALEX_2 = 12,
ALEX_3 = 13,
ALEX_4 = 14,
ALEX_5 = 15,
ALEX_6A = 16,
ALEX_6B = 17,
ALEX_6C = 18,
ALEX_6D = 19,
BELLA = 20,
FENRIS = 21,
SERCULLEN = 22,
INQUISITOR = 23,
BERND = 24
} ident_preset;
static PEP_STATUS set_up_preset(PEP_SESSION session,
ident_preset preset_name,
bool set_identity,
bool set_fpr,
bool set_pep,
bool trust,
bool set_own,
bool setup_private,
bool set_own,
bool setup_private,
pEp_identity** ident);
private:
static inline const IdentityInfo presets[] = {
IdentityInfo("Alice Spivak Hyatt", "ALICE", "pep.test.alice@pep-project.org", "pep-test-alice-0x6FF00E97", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97"),
IdentityInfo("Apple of my Computer", "APPLE", "pep.test.apple@pep-project.org", "pep-test-apple-0x1CCBC7D7", "3D8D9423D03DDF61B60161150313D94A1CCBC7D7"),
IdentityInfo("Bob Dog", "BOB", "pep.test.bob@pep-project.org", "pep-test-bob-0xC9C2EE39", "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39"),
IdentityInfo("Carol Burnett", "CAROL", "pep-test-carol@pep-project.org", "pep-test-carol-0x42A85A42", "8DD4F5827B45839E9ACCA94687BDDFFB42A85A42"),
IdentityInfo("The Hoff", "DAVE", "pep-test-dave@pep-project.org", "pep-test-dave-0xBB5BCCF6", "E8AC9779A2D13A15D8D55C84B049F489BB5BCCF6"),
IdentityInfo("Erin Ireland", "ERIN", "pep-test-erin@pep-project.org", "pep-test-erin-0x9F8D7CBA", "1B0E197E8AE66277B8A024B9AEA69F509F8D7CBA"),
IdentityInfo("Frank N. Furter", "FRANK", "pep-test-frank@pep-project.org", "pep-test-frank-0x9A7FC670", "B022B74476D8A8E1F01E55FBAB6972569A7FC670"), // currently expired
IdentityInfo("Gabrielle Gonzales", "GABI", "pep-test-gabrielle@pep-project.org", "pep-test-gabrielle-0xE203586C", "906C9B8349954E82C5623C3C8C541BD4E203586C"),
IdentityInfo("John Denver", "JOHN", "pep.test.john@pep-project.org", "pep-test-john-0x70DCF575", "AA2E4BEB93E5FE33DEFD8BE1135CD6D170DCF575"),
IdentityInfo("Alex Braithwaite", "ALEX", "pep.test.alexander@peptest.ch", "pep.test.alexander-0x26B54E4E", "3AD9F60FAEB22675DB873A1362D6981326B54E4E"),
IdentityInfo("Alex Braithwaite", "ALEX", "pep.test.alexander0@darthmama.org", "pep.test.alexander0-0x3B7302DB", "F4598A17D4690EB3B5B0F6A344F04E963B7302DB"),
IdentityInfo("Alex Braithwaite", "ALEX", "pep.test.alexander1@darthmama.org", "pep.test.alexander1-0x541260F6", "59AF4C51492283522F6904531C09730A541260F6"),
IdentityInfo("Alex Braithwaite", "ALEX", "pep.test.alexander2@darthmama.org", "pep.test.alexander2-0xA6512F30", "46A994F19077C05610870273C4B8AB0BA6512F30"),
IdentityInfo("Alex Braithwaite", "ALEX", "pep.test.alexander3@darthmama.org", "pep.test.alexander3-0x724B3975", "5F7076BBD92E14EA49F0DF7C2CE49419724B3975"),
IdentityInfo("Alex Braithwaite", "ALEX", "pep.test.alexander4@darthmama.org", "pep.test.alexander4-0x844B9DCF", "E95FFF95B8E2FDD4A12C3374395F1485844B9DCF"),
IdentityInfo("Alex Braithwaite", "ALEX", "pep.test.alexander5@darthmama.org", "pep.test.alexander5-0x0773CD29", "58BCC2BF2AE1E3C4FBEAB89AD7838ACA0773CD29"),
IdentityInfo("Alex Braithwaite", "ALEX", "pep.test.alexander6@darthmama.org", "pep.test.alexander6-0x0019697D", "74D79B4496E289BD8A71B70BA8E2C4530019697D"),
IdentityInfo("Alex Braithwaite", "ALEX", "pep.test.alexander6@darthmama.org", "pep.test.alexander6-0x503B14D8", "2E21325D202A44BFD9C607FCF095B202503B14D8"),
IdentityInfo("Alex Braithwaite", "ALEX", "pep.test.alexander6@darthmama.org", "pep.test.alexander6-0xA216E95A", "3C1E713D8519D7F907E3142D179EAA24A216E95A"),
IdentityInfo("Alex Braithwaite", "ALEX", "pep.test.alexander6@darthmama.org", "pep.test.alexander6-0xBDA17020", "B4CE2F6947B6947C500F0687AEFDE530BDA17020"),
IdentityInfo("Bella Cat", "BELLA", "pep.test.bella@peptest.ch", "pep.test.bella-0xAF516AAE", "5631BF1357326A02AA470EEEB815EF7FA4516AAE"),
IdentityInfo("Fenris Leto Hawke", "FENRIS", "pep.test.fenris@thisstilldoesntwork.lu", "pep.test.fenris-0x4F3D2900", "0969FA229DF21C832A64A04711B1B9804F3D2900"),
IdentityInfo("Cullen Rutherford", "CULLEN", "sercullen-test@darthmama.org", "sercullen-0x3CEAADED4", "1C9666D8B3E28F4AA3847DA89A6E75E3CEAADED4"), // NB expired on purpose
IdentityInfo("Inquisitor Claire Trevelyan", "INQUISITOR", "inquisitor@darthmama.org", "inquisitor-0xA4728718_renewed", "8E8D2381AE066ABE1FEE509821BA977CA4728718"),
IdentityInfo("Bernd das Brot", "BERNDI", "bernd.das.brot@darthmama.org", "bernd.das.brot-0xCAFAA422", "F8CE0F7E24EB190A2FCBFD38D4B088A7CAFAA422")
};
static constexpr int PRESETS_LEN = sizeof(presets);
};
std::string get_main_test_home_dir();
std::string random_string( size_t length );
PEP_STATUS read_file_and_import_key(PEP_SESSION session, const char* fname);
PEP_STATUS set_up_ident_from_scratch(PEP_SESSION session,


+ 5
- 5
test/src/UnencryptedPepMailTest.cc View File

@ -85,14 +85,14 @@ TEST_F(UnencryptedPepMailTest, check_unencrypted_pep_mail_outgoing) {
pEp_identity* alice = NULL;
pEp_identity* dave = NULL;
PEP_STATUS status = set_up_preset(session, ALICE,
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALICE,
true, true, true, true, true, true, &alice);
ASSERT_EQ(status, PEP_STATUS_OK);
ASSERT_NOTNULL(alice);
/*
PEP_STATUS set_up_preset(PEP_SESSION session,
pEp_test_ident_preset preset_name,
ident_preset preset_name,
bool set_ident,
bool set_pep,
bool trust,
@ -134,14 +134,14 @@ TEST_F(UnencryptedPepMailTest, check_unencrypted_pep_mail_outgoing_MIME) {
pEp_identity* alice = NULL;
pEp_identity* dave = NULL;
PEP_STATUS status = set_up_preset(session, ALICE,
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::ALICE,
true, true, true, true, true, true, &alice);
ASSERT_EQ(status, PEP_STATUS_OK);
ASSERT_NOTNULL(alice);
/*
PEP_STATUS set_up_preset(PEP_SESSION session,
pEp_test_ident_preset preset_name,
ident_preset preset_name,
bool set_ident,
bool set_pep,
bool trust,
@ -185,7 +185,7 @@ PEP_STATUS set_up_preset(PEP_SESSION session,
TEST_F(UnencryptedPepMailTest, check_unencrypted_pep_message_rcpt) {
string msgstr = slurp("test_mails/unenc_pep_msg_test_1.eml");
PEP_STATUS status = set_up_preset(session, DAVE,
PEP_STATUS status = TestUtilsPreset::set_up_preset(session, TestUtilsPreset::DAVE,
true, true, true, true, true, true, NULL);
ASSERT_EQ(status, PEP_STATUS_OK);
message* dec_msg = NULL;


Loading…
Cancel
Save