Browse Source

Rest of key_reset tests

pEpMIME_windows
parent
commit
e0c62fba21
3 changed files with 446 additions and 1 deletions
  1. +9
    -1
      src/key_reset.h
  2. +6
    -0
      test/include/KeyResetMessageTests.h
  3. +431
    -0
      test/src/engine_tests/KeyResetMessageTests.cc

+ 9
- 1
src/key_reset.h View File

@ -57,7 +57,7 @@ DYNAMIC_API PEP_STATUS key_reset_identity(
// parameters:
// session (in) session handle
// user_id (in) user_id for which the key reset should occur. If this
// is the own user_id, for MUST NOT be NULL.
// is the own user_id, fpr MUST NOT be NULL.
// fpr (in) fingerprint of key to reset.
// If NULL, we reset all default
// keys for this user and all of its identities.
@ -76,6 +76,14 @@ DYNAMIC_API PEP_STATUS key_reset_user(
// own identities, and opportunistically communicate
// key reset information to people we have recently
// contacted.
//
// caveat: this will return PEP_CANNOT_FIND_IDENTITY if no own user yet exists.
// HOWEVER, apps and adapters must decide if this is a reasonable state;
// since the period where no own user exists will necessarily be very short
// in most implementations, PEP_CANNOT_FIND_IDENTITY may be returned when
// there is some sort of DB corruption and we expect there to be an own user.
// Apps are responsible for deciding whether or not this is an error condition;
// one would expect that it generally is (rather than the uninitialised DB case)
//
// parameters:
// session (in) session handle


+ 6
- 0
test/include/KeyResetMessageTests.h View File

@ -54,6 +54,12 @@ class KeyResetMessageTests : public EngineTestIndividualSuite {
void check_reset_ident_own_pub_fpr();
void check_reset_ident_own_priv_fpr();
void check_reset_ident_own_priv_no_fpr();
void check_reset_user_other_no_fpr();
void check_reset_user_other_fpr();
void check_reset_user_own_fpr();
void check_reset_user_no_fpr();
void check_reset_all_own_keys();
void check_reset_all_own_no_own();
void send_setup();
void receive_setup();


+ 431
- 0
test/src/engine_tests/KeyResetMessageTests.cc View File

@ -65,6 +65,19 @@ KeyResetMessageTests::KeyResetMessageTests(string suitename, string test_home_di
static_cast<Func>(&KeyResetMessageTests::check_reset_ident_own_priv_fpr)));
add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("KeyResetMessageTests::check_reset_ident_own_priv_no_fpr"),
static_cast<Func>(&KeyResetMessageTests::check_reset_ident_own_priv_no_fpr)));
add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("KeyResetMessageTests::check_reset_user_other_no_fpr"),
static_cast<Func>(&KeyResetMessageTests::check_reset_user_other_no_fpr)));
add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("KeyResetMessageTests::check_reset_user_other_fpr"),
static_cast<Func>(&KeyResetMessageTests::check_reset_user_other_fpr)));
add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("KeyResetMessageTests::check_reset_user_own_fpr"),
static_cast<Func>(&KeyResetMessageTests::check_reset_user_own_fpr)));
add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("KeyResetMessageTests::check_reset_user_no_fpr"),
static_cast<Func>(&KeyResetMessageTests::check_reset_user_no_fpr)));
add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("KeyResetMessageTests::check_reset_all_own_keys"),
static_cast<Func>(&KeyResetMessageTests::check_reset_all_own_keys)));
add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("KeyResetMessageTests::check_reset_all_own_no_own"),
static_cast<Func>(&KeyResetMessageTests::check_reset_all_own_no_own)));
fake_this = this;
cached_messageToSend = &KeyResetMessageTests::message_send_callback;
@ -761,3 +774,421 @@ void KeyResetMessageTests::check_reset_ident_own_priv_no_fpr() {
TEST_ASSERT(alice_new_fpr && alice_new_fpr[0]);
TEST_ASSERT_MSG(strcmp(alice_fpr, alice_new_fpr) != 0, alice_new_fpr);
}
void KeyResetMessageTests::check_reset_user_other_no_fpr() {
char* pubkey1 = strdup("74D79B4496E289BD8A71B70BA8E2C4530019697D");
char* pubkey2 = strdup("2E21325D202A44BFD9C607FCF095B202503B14D8");
char* pubkey3 = strdup("3C1E713D8519D7F907E3142D179EAA24A216E95A");
char* pubkey4 = strdup("B4CE2F6947B6947C500F0687AEFDE530BDA17020");
pEp_identity* alex_id = new_identity("pep.test.alexander@darthmama.org",
NULL,
"AlexID",
"Alexander Braithwaite");
/*
test_keys/pub/pep.test.alexander6-0x0019697D_pub.asc
test_keys/pub/pep.test.alexander6-0x503B14D8_pub.asc
test_keys/pub/pep.test.alexander6-0xA216E95A_pub.asc
test_keys/pub/pep.test.alexander6-0xBDA17020_pub.asc
*/
PEP_STATUS status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0x0019697D_pub.asc");
status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0x503B14D8_pub.asc");
status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0xA216E95A_pub.asc");
status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0xBDA17020_pub.asc");
alex_id->fpr = pubkey1;
status = trust_personal_key(session, alex_id);
alex_id->fpr = pubkey3;
status = trust_personal_key(session, alex_id);
status = set_as_pEp_user(session, alex_id);
alex_id->fpr = pubkey4;
status = trust_personal_key(session, alex_id);
status = key_reset_user(session, alex_id->user_id, NULL);
stringlist_t* keylist = NULL;
alex_id->fpr = pubkey1;
status = get_trust(session, alex_id);
TEST_ASSERT_MSG(alex_id->comm_type == PEP_ct_unknown, tl_ct_string(alex_id->comm_type));
status = find_keys(session, pubkey1, &keylist);
TEST_ASSERT_MSG(status == PEP_GET_KEY_FAILED || !keylist || EMPTYSTR(keylist->value),
(string(pubkey1) + " was unfortunately not deleted.").c_str());
alex_id->fpr = pubkey2;
status = get_trust(session, alex_id);
TEST_ASSERT_MSG(alex_id->comm_type == PEP_ct_unknown, tl_ct_string(alex_id->comm_type));
status = find_keys(session, pubkey2, &keylist);
TEST_ASSERT_MSG(status == PEP_STATUS_OK && keylist && !EMPTYSTR(keylist->value),
(string(pubkey2) + " was deleted and should not have been").c_str());
alex_id->fpr = pubkey3;
status = get_trust(session, alex_id);
TEST_ASSERT_MSG(alex_id->comm_type == PEP_ct_unknown, tl_ct_string(alex_id->comm_type));
status = find_keys(session, pubkey3, &keylist);
TEST_ASSERT_MSG(status == PEP_GET_KEY_FAILED || !keylist || EMPTYSTR(keylist->value),
(string(pubkey3) + " was unfortunately not deleted.").c_str());
alex_id->fpr = pubkey4;
status = get_trust(session, alex_id);
TEST_ASSERT_MSG(alex_id->comm_type == PEP_ct_unknown, tl_ct_string(alex_id->comm_type));
status = find_keys(session, pubkey4, &keylist);
TEST_ASSERT_MSG(status == PEP_GET_KEY_FAILED || !keylist || EMPTYSTR(keylist->value),
(string(pubkey4) + " was unfortunately not deleted.").c_str());
TEST_ASSERT(true);
}
void KeyResetMessageTests::check_reset_user_other_fpr() {
char* pubkey1 = strdup("74D79B4496E289BD8A71B70BA8E2C4530019697D");
char* pubkey2 = strdup("2E21325D202A44BFD9C607FCF095B202503B14D8");
char* pubkey3 = strdup("3C1E713D8519D7F907E3142D179EAA24A216E95A");
char* pubkey4 = strdup("B4CE2F6947B6947C500F0687AEFDE530BDA17020");
pEp_identity* alex_id = new_identity("pep.test.alexander@darthmama.org",
NULL,
"AlexID",
"Alexander Braithwaite");
/*
test_keys/pub/pep.test.alexander6-0x0019697D_pub.asc
test_keys/pub/pep.test.alexander6-0x503B14D8_pub.asc
test_keys/pub/pep.test.alexander6-0xA216E95A_pub.asc
test_keys/pub/pep.test.alexander6-0xBDA17020_pub.asc
*/
PEP_STATUS status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0x0019697D_pub.asc");
status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0x503B14D8_pub.asc");
status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0xA216E95A_pub.asc");
status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0xBDA17020_pub.asc");
alex_id->fpr = pubkey1;
status = trust_personal_key(session, alex_id);
alex_id->fpr = pubkey3;
status = trust_personal_key(session, alex_id);
status = set_as_pEp_user(session, alex_id);
alex_id->fpr = pubkey4;
status = trust_personal_key(session, alex_id);
status = key_reset_user(session, alex_id->user_id, pubkey3);
stringlist_t* keylist = NULL;
alex_id->fpr = pubkey1;
status = get_trust(session, alex_id);
TEST_ASSERT_MSG(alex_id->comm_type == PEP_ct_pEp, tl_ct_string(alex_id->comm_type));
status = find_keys(session, pubkey1, &keylist);
TEST_ASSERT_MSG(status == PEP_STATUS_OK && keylist && !EMPTYSTR(keylist->value),
(string(pubkey1) + " was deleted and should not have been").c_str());
free_stringlist(keylist);
keylist = NULL;
alex_id->fpr = pubkey2;
status = get_trust(session, alex_id);
TEST_ASSERT_MSG(alex_id->comm_type == PEP_ct_unknown, tl_ct_string(alex_id->comm_type));
status = find_keys(session, pubkey2, &keylist);
TEST_ASSERT_MSG(status == PEP_STATUS_OK && keylist && !EMPTYSTR(keylist->value),
(string(pubkey2) + " was deleted and should not have been").c_str());
alex_id->fpr = pubkey3;
status = get_trust(session, alex_id);
TEST_ASSERT_MSG(alex_id->comm_type == PEP_ct_unknown, tl_ct_string(alex_id->comm_type));
status = find_keys(session, pubkey3, &keylist);
TEST_ASSERT_MSG(status == PEP_GET_KEY_FAILED || !keylist || EMPTYSTR(keylist->value),
(string(pubkey3) + " was unfortunately not deleted.").c_str());
alex_id->fpr = pubkey4;
status = get_trust(session, alex_id);
TEST_ASSERT_MSG(alex_id->comm_type == PEP_ct_pEp, tl_ct_string(alex_id->comm_type));
status = find_keys(session, pubkey4, &keylist);
TEST_ASSERT_MSG(status == PEP_STATUS_OK && keylist && !EMPTYSTR(keylist->value),
(string(pubkey4) + " was deleted and should not have been").c_str());
// next line is for readability.
alex_id->fpr = NULL;
free_stringlist(keylist);
free(pubkey1);
free(pubkey2);
free(pubkey3);
free(pubkey4);
free_identity(alex_id);
}
void KeyResetMessageTests::check_reset_user_own_fpr() {
char* pubkey1 = strdup("74D79B4496E289BD8A71B70BA8E2C4530019697D");
char* pubkey2 = strdup("2E21325D202A44BFD9C607FCF095B202503B14D8");
char* pubkey3 = strdup("3C1E713D8519D7F907E3142D179EAA24A216E95A");
char* pubkey4 = strdup("B4CE2F6947B6947C500F0687AEFDE530BDA17020");
pEp_identity* alex_id = new_identity("pep.test.alexander@darthmama.org",
NULL,
"AlexID",
"Alexander Braithwaite");
/*
test_keys/pub/pep.test.alexander6-0x0019697D_pub.asc
test_keys/pub/pep.test.alexander6-0x503B14D8_pub.asc
test_keys/pub/pep.test.alexander6-0xA216E95A_pub.asc
test_keys/pub/pep.test.alexander6-0xBDA17020_pub.asc
*/
PEP_STATUS status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0x0019697D_pub.asc");
status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0x503B14D8_pub.asc");
status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0xA216E95A_pub.asc");
status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0xBDA17020_pub.asc");
status = read_file_and_import_key(session, "test_keys/priv/pep.test.alexander6-0x0019697D_priv.asc");
status = read_file_and_import_key(session, "test_keys/priv/pep.test.alexander6-0x503B14D8_priv.asc");
status = read_file_and_import_key(session, "test_keys/priv/pep.test.alexander6-0xA216E95A_priv.asc");
status = read_file_and_import_key(session, "test_keys/priv/pep.test.alexander6-0xBDA17020_priv.asc");
alex_id->me = true;
status = set_own_key(session, alex_id, pubkey1);
status = set_own_key(session, alex_id, pubkey3);
status = set_own_key(session, alex_id, pubkey4);
status = key_reset_user(session, alex_id->user_id, pubkey3);
alex_id->fpr = pubkey1;
status = get_trust(session, alex_id);
TEST_ASSERT_MSG(alex_id->comm_type == PEP_ct_pEp, tl_ct_string(alex_id->comm_type));
alex_id->fpr = pubkey2;
status = get_trust(session, alex_id);
TEST_ASSERT_MSG(alex_id->comm_type == PEP_ct_unknown, tl_ct_string(alex_id->comm_type));
stringlist_t* keylist = NULL;
alex_id->fpr = pubkey3;
status = get_trust(session, alex_id);
TEST_ASSERT_MSG(alex_id->comm_type == PEP_ct_mistrusted, tl_ct_string(alex_id->comm_type));
status = find_keys(session, pubkey4, &keylist);
TEST_ASSERT_MSG(status == PEP_STATUS_OK && keylist && !EMPTYSTR(keylist->value),
(string(pubkey3) + " was deleted and should not have been. Status is " + tl_status_string(status)).c_str());
free_stringlist(keylist);
keylist = NULL;
alex_id->fpr = pubkey4;
status = get_trust(session, alex_id);
TEST_ASSERT_MSG(alex_id->comm_type == PEP_ct_pEp, tl_ct_string(alex_id->comm_type));
// next line is for readability.
alex_id->fpr = NULL;
free_stringlist(keylist);
free(pubkey1);
free(pubkey2);
free(pubkey3);
free(pubkey4);
free_identity(alex_id);
}
void KeyResetMessageTests::check_reset_user_no_fpr() {
char* pubkey1 = strdup("74D79B4496E289BD8A71B70BA8E2C4530019697D");
char* pubkey2 = strdup("2E21325D202A44BFD9C607FCF095B202503B14D8");
char* pubkey3 = strdup("3C1E713D8519D7F907E3142D179EAA24A216E95A");
char* pubkey4 = strdup("B4CE2F6947B6947C500F0687AEFDE530BDA17020");
pEp_identity* alex_id = new_identity("pep.test.alexander@darthmama.org",
NULL,
"AlexID",
"Alexander Braithwaite");
/*
test_keys/pub/pep.test.alexander6-0x0019697D_pub.asc
test_keys/pub/pep.test.alexander6-0x503B14D8_pub.asc
test_keys/pub/pep.test.alexander6-0xA216E95A_pub.asc
test_keys/pub/pep.test.alexander6-0xBDA17020_pub.asc
*/
PEP_STATUS status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0x0019697D_pub.asc");
status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0x503B14D8_pub.asc");
status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0xA216E95A_pub.asc");
status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0xBDA17020_pub.asc");
status = read_file_and_import_key(session, "test_keys/priv/pep.test.alexander6-0x0019697D_priv.asc");
status = read_file_and_import_key(session, "test_keys/priv/pep.test.alexander6-0x503B14D8_priv.asc");
status = read_file_and_import_key(session, "test_keys/priv/pep.test.alexander6-0xA216E95A_priv.asc");
status = read_file_and_import_key(session, "test_keys/priv/pep.test.alexander6-0xBDA17020_priv.asc");
alex_id->me = true;
status = set_own_key(session, alex_id, pubkey1);
status = set_own_key(session, alex_id, pubkey3);
status = set_own_key(session, alex_id, pubkey4);
status = key_reset_user(session, alex_id->user_id, NULL);
TEST_ASSERT_MSG(status == PEP_ILLEGAL_VALUE, tl_status_string(status));
free(pubkey1);
free(pubkey2);
free(pubkey3);
free(pubkey4);
free_identity(alex_id);
}
void KeyResetMessageTests::check_reset_all_own_keys() {
char* pubkey1 = strdup("74D79B4496E289BD8A71B70BA8E2C4530019697D");
char* pubkey2 = strdup("2E21325D202A44BFD9C607FCF095B202503B14D8");
char* pubkey3 = strdup("3C1E713D8519D7F907E3142D179EAA24A216E95A");
char* pubkey4 = strdup("B4CE2F6947B6947C500F0687AEFDE530BDA17020");
pEp_identity* alex_id = new_identity("pep.test.alexander@darthmama.org",
NULL,
"AlexID",
"Alexander Braithwaite");
/*
test_keys/pub/pep.test.alexander6-0x0019697D_pub.asc
test_keys/pub/pep.test.alexander6-0x503B14D8_pub.asc
test_keys/pub/pep.test.alexander6-0xA216E95A_pub.asc
test_keys/pub/pep.test.alexander6-0xBDA17020_pub.asc
*/
PEP_STATUS status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0x0019697D_pub.asc");
status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0x503B14D8_pub.asc");
status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0xA216E95A_pub.asc");
status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0xBDA17020_pub.asc");
status = read_file_and_import_key(session, "test_keys/priv/pep.test.alexander6-0x0019697D_priv.asc");
status = read_file_and_import_key(session, "test_keys/priv/pep.test.alexander6-0x503B14D8_priv.asc");
status = read_file_and_import_key(session, "test_keys/priv/pep.test.alexander6-0xA216E95A_priv.asc");
status = read_file_and_import_key(session, "test_keys/priv/pep.test.alexander6-0xBDA17020_priv.asc");
alex_id->me = true;
status = set_own_key(session, alex_id, pubkey1);
status = set_own_key(session, alex_id, pubkey3);
status = set_own_key(session, alex_id, pubkey4);
status = key_reset_all_own_keys(session);
stringlist_t* keylist = NULL;
alex_id->fpr = pubkey1;
status = get_trust(session, alex_id);
TEST_ASSERT_MSG(alex_id->comm_type == PEP_ct_mistrusted, tl_ct_string(alex_id->comm_type));
status = find_keys(session, pubkey1, &keylist);
TEST_ASSERT_MSG(status == PEP_STATUS_OK && keylist && !EMPTYSTR(keylist->value),
(string(pubkey1) + " was deleted and should not have been. Status is " + tl_status_string(status)).c_str());
free_stringlist(keylist);
keylist = NULL;
alex_id->fpr = pubkey2;
status = get_trust(session, alex_id);
TEST_ASSERT_MSG(alex_id->comm_type == PEP_ct_unknown, tl_ct_string(alex_id->comm_type));
status = find_keys(session, pubkey2, &keylist);
TEST_ASSERT_MSG(status == PEP_STATUS_OK && keylist && !EMPTYSTR(keylist->value),
(string(pubkey2) + " was deleted and should not have been. Status is " + tl_status_string(status)).c_str());
free_stringlist(keylist);
keylist = NULL;
alex_id->fpr = pubkey3;
status = get_trust(session, alex_id);
TEST_ASSERT_MSG(alex_id->comm_type == PEP_ct_mistrusted, tl_ct_string(alex_id->comm_type));
status = find_keys(session, pubkey3, &keylist);
TEST_ASSERT_MSG(status == PEP_STATUS_OK && keylist && !EMPTYSTR(keylist->value),
(string(pubkey3) + " was deleted and should not have been. Status is " + tl_status_string(status)).c_str());
free_stringlist(keylist);
keylist = NULL;
alex_id->fpr = pubkey4;
status = get_trust(session, alex_id);
TEST_ASSERT_MSG(alex_id->comm_type == PEP_ct_mistrusted, tl_ct_string(alex_id->comm_type));
status = find_keys(session, pubkey4, &keylist);
TEST_ASSERT_MSG(status == PEP_STATUS_OK && keylist && !EMPTYSTR(keylist->value),
(string(pubkey4) + " was deleted and should not have been. Status is " + tl_status_string(status)).c_str());
free_stringlist(keylist);
keylist = NULL;
alex_id->fpr = NULL;
status = myself(session, alex_id);
TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
TEST_ASSERT(alex_id->fpr);
TEST_ASSERT(strcmp(alex_id->fpr, pubkey1));
TEST_ASSERT(strcmp(alex_id->fpr, pubkey2));
TEST_ASSERT(strcmp(alex_id->fpr, pubkey3));
TEST_ASSERT(strcmp(alex_id->fpr, pubkey4));
TEST_ASSERT_MSG(alex_id->comm_type == PEP_ct_pEp, tl_ct_string(alex_id->comm_type));
free(pubkey1);
free(pubkey2);
free(pubkey3);
free(pubkey4);
free_identity(alex_id);
}
void KeyResetMessageTests::check_reset_all_own_no_own() {
char* pubkey1 = strdup("74D79B4496E289BD8A71B70BA8E2C4530019697D");
char* pubkey2 = strdup("2E21325D202A44BFD9C607FCF095B202503B14D8");
char* pubkey3 = strdup("3C1E713D8519D7F907E3142D179EAA24A216E95A");
char* pubkey4 = strdup("B4CE2F6947B6947C500F0687AEFDE530BDA17020");
pEp_identity* alex_id = new_identity("pep.test.alexander@darthmama.org",
NULL,
"AlexID",
"Alexander Braithwaite");
/*
test_keys/pub/pep.test.alexander6-0x0019697D_pub.asc
test_keys/pub/pep.test.alexander6-0x503B14D8_pub.asc
test_keys/pub/pep.test.alexander6-0xA216E95A_pub.asc
test_keys/pub/pep.test.alexander6-0xBDA17020_pub.asc
*/
PEP_STATUS status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0x0019697D_pub.asc");
status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0x503B14D8_pub.asc");
status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0xA216E95A_pub.asc");
status = read_file_and_import_key(session, "test_keys/pub/pep.test.alexander6-0xBDA17020_pub.asc");
alex_id->fpr = pubkey1;
status = trust_personal_key(session, alex_id);
alex_id->fpr = pubkey3;
status = trust_personal_key(session, alex_id);
alex_id->fpr = pubkey4;
status = trust_personal_key(session, alex_id);
status = key_reset_all_own_keys(session);
TEST_ASSERT_MSG(status == PEP_CANNOT_FIND_IDENTITY, tl_status_string(status));
stringlist_t* keylist = NULL;
alex_id->fpr = pubkey1;
status = get_trust(session, alex_id);
TEST_ASSERT_MSG(alex_id->comm_type == PEP_ct_OpenPGP, tl_ct_string(alex_id->comm_type));
status = find_keys(session, pubkey1, &keylist);
TEST_ASSERT_MSG(status == PEP_STATUS_OK && keylist && !EMPTYSTR(keylist->value),
(string(pubkey1) + " was deleted and should not have been").c_str());
free_stringlist(keylist);
keylist = NULL;
alex_id->fpr = pubkey2;
status = get_trust(session, alex_id);
TEST_ASSERT_MSG(alex_id->comm_type == PEP_ct_unknown, tl_ct_string(alex_id->comm_type));
status = find_keys(session, pubkey2, &keylist);
TEST_ASSERT_MSG(status == PEP_STATUS_OK && keylist && !EMPTYSTR(keylist->value),
(string(pubkey2) + " was deleted and should not have been").c_str());
alex_id->fpr = pubkey3;
status = get_trust(session, alex_id);
TEST_ASSERT_MSG(alex_id->comm_type == PEP_ct_OpenPGP, tl_ct_string(alex_id->comm_type));
status = find_keys(session, pubkey3, &keylist);
TEST_ASSERT_MSG(status == PEP_STATUS_OK && keylist && !EMPTYSTR(keylist->value),
(string(pubkey3) + " was deleted and should not have been").c_str());
alex_id->fpr = pubkey4;
status = get_trust(session, alex_id);
TEST_ASSERT_MSG(alex_id->comm_type == PEP_ct_OpenPGP, tl_ct_string(alex_id->comm_type));
status = find_keys(session, pubkey4, &keylist);
TEST_ASSERT_MSG(status == PEP_STATUS_OK && keylist && !EMPTYSTR(keylist->value),
(string(pubkey4) + " was deleted and should not have been").c_str());
// next line is for readability.
alex_id->fpr = NULL;
free_stringlist(keylist);
free(pubkey1);
free(pubkey2);
free(pubkey3);
free(pubkey4);
free_identity(alex_id);
}

Loading…
Cancel
Save