|
|
@ -83,7 +83,8 @@ namespace { |
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(CheckRenewedExpiredKeyTrustStatusTest, check_renewed_expired_key_trust_status) { |
|
|
|
// This is what happens if we receive a key renewal (e.g. by mail) before ever updating the OpenPGP identity after expiration.
|
|
|
|
TEST_F(CheckRenewedExpiredKeyTrustStatusTest, check_renewed_expired_key_trust_status_OpenPGP_no_update) { |
|
|
|
bool ok = false; |
|
|
|
ok = slurp_and_import_key(session, "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc"); |
|
|
|
ASSERT_TRUE(ok); |
|
|
@ -99,7 +100,11 @@ TEST_F(CheckRenewedExpiredKeyTrustStatusTest, check_renewed_expired_key_trust_st |
|
|
|
ASSERT_OK; |
|
|
|
|
|
|
|
const char* inq_fpr = "8E8D2381AE066ABE1FEE509821BA977CA4728718"; |
|
|
|
pEp_identity* expired_inquisitor = new_identity("inquisitor@darthmama.org", NULL, NULL, "Lady Claire Trevelyan"); |
|
|
|
// KEY ELECTION: It is clear that leaving an address we have a key for as a TOFU address is going to continue to have implications in the
|
|
|
|
// event that usernames differ. Here, we're losing the key that has been set for this identity. I am not sure we want this.
|
|
|
|
// pEp_identity* expired_inquisitor = new_identity("inquisitor@darthmama.org", NULL, "TOFU_inquisitor@darthmama.org", "Lady Claire Trevelyan");
|
|
|
|
pEp_identity* expired_inquisitor = new_identity("inquisitor@darthmama.org", NULL, "INQUISITOR", "Lady Claire Trevelyan"); |
|
|
|
|
|
|
|
status = set_fpr_preserve_ident(session, expired_inquisitor, inq_fpr, false); |
|
|
|
ASSERT_OK; |
|
|
|
|
|
|
@ -108,17 +113,19 @@ TEST_F(CheckRenewedExpiredKeyTrustStatusTest, check_renewed_expired_key_trust_st |
|
|
|
const string msg = slurp("test_mails/ENGINE-463-attempt-numero-dos.eml"); |
|
|
|
|
|
|
|
char* decrypted_msg = NULL; |
|
|
|
stringlist_t* keylist_used = nullptr; |
|
|
|
char* modified_src = NULL; |
|
|
|
stringlist_t* keylist = NULL; |
|
|
|
|
|
|
|
PEP_rating rating; |
|
|
|
PEP_decrypt_flags_t flags = 0; |
|
|
|
|
|
|
|
status = MIME_decrypt_message(session, msg.c_str(), msg.size(), &decrypted_msg, &keylist_used, &rating, &flags, &modified_src); |
|
|
|
ASSERT_EQ(status , PEP_DECRYPTED); |
|
|
|
message* dec_msg = NULL; |
|
|
|
message* enc_msg = NULL; |
|
|
|
status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg, NULL); |
|
|
|
ASSERT_OK; |
|
|
|
|
|
|
|
status = decrypt_message(session, enc_msg, &dec_msg, &keylist, &rating, &flags); |
|
|
|
ASSERT_EQ(status, PEP_DECRYPTED); // ???
|
|
|
|
|
|
|
|
free(decrypted_msg); |
|
|
|
decrypted_msg = NULL; |
|
|
|
ok = slurp_and_import_key(session, "test_keys/pub/inquisitor-0xA4728718_renewed_pub.asc"); |
|
|
|
ASSERT_TRUE(ok); |
|
|
|
|
|
|
@ -130,16 +137,79 @@ TEST_F(CheckRenewedExpiredKeyTrustStatusTest, check_renewed_expired_key_trust_st |
|
|
|
msg2->longmsg = strdup("Blahblahblah!"); |
|
|
|
msg2->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL); |
|
|
|
|
|
|
|
// We don't keep OpenPGP expired keys. We'll have to receive the new one via mail.
|
|
|
|
status = outgoing_message_rating(session, msg2, &rating); |
|
|
|
ASSERT_OK; |
|
|
|
ASSERT_EQ(rating , PEP_rating_reliable); |
|
|
|
ASSERT_EQ(rating, PEP_rating_reliable); |
|
|
|
} |
|
|
|
|
|
|
|
status = get_trust(session, expired_inquisitor); |
|
|
|
ASSERT_EQ(expired_inquisitor->comm_type , PEP_ct_OpenPGP_unconfirmed); |
|
|
|
free_message(msg2); |
|
|
|
// If we updated an OpenPGP identity in the meantime, we will have removed the key. Too bad.
|
|
|
|
TEST_F(CheckRenewedExpiredKeyTrustStatusTest, check_renewed_expired_key_trust_status_OpenPGP_with_update) { |
|
|
|
bool ok = false; |
|
|
|
ok = slurp_and_import_key(session, "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc"); |
|
|
|
ASSERT_TRUE(ok); |
|
|
|
ok = slurp_and_import_key(session, "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc"); |
|
|
|
ASSERT_TRUE(ok); |
|
|
|
ok = slurp_and_import_key(session, "test_keys/pub/inquisitor-0xA4728718_full_expired.pub.asc"); |
|
|
|
ASSERT_TRUE(ok); |
|
|
|
|
|
|
|
const char* alice_fpr = "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97"; |
|
|
|
pEp_identity* alice_from = new_identity("pep.test.alice@pep-project.org", alice_fpr, PEP_OWN_USERID, "Alice Cooper"); |
|
|
|
|
|
|
|
PEP_STATUS status = set_own_key(session, alice_from, alice_fpr); |
|
|
|
ASSERT_OK; |
|
|
|
|
|
|
|
const char* inq_fpr = "8E8D2381AE066ABE1FEE509821BA977CA4728718"; |
|
|
|
// KEY ELECTION: It is clear that leaving an address we have a key for as a TOFU address is going to continue to have implications in the
|
|
|
|
// event that usernames differ. Here, we're losing the key that has been set for this identity. I am not sure we want this.
|
|
|
|
// pEp_identity* expired_inquisitor = new_identity("inquisitor@darthmama.org", NULL, "TOFU_inquisitor@darthmama.org", "Lady Claire Trevelyan");
|
|
|
|
pEp_identity* expired_inquisitor = new_identity("inquisitor@darthmama.org", NULL, "INQUISITOR", "Lady Claire Trevelyan"); |
|
|
|
|
|
|
|
status = set_fpr_preserve_ident(session, expired_inquisitor, inq_fpr, false); |
|
|
|
ASSERT_OK; |
|
|
|
|
|
|
|
// Ok, so I want to make sure we make an entry, so I'll try to decrypt the message WITH
|
|
|
|
// the expired key:
|
|
|
|
const string msg = slurp("test_mails/ENGINE-463-attempt-numero-dos.eml"); |
|
|
|
|
|
|
|
status = update_identity(session, expired_inquisitor); |
|
|
|
ASSERT_EQ(status, PEP_KEY_UNSUITABLE); |
|
|
|
ASSERT_NULL(expired_inquisitor->fpr); |
|
|
|
|
|
|
|
char* decrypted_msg = NULL; |
|
|
|
stringlist_t* keylist = NULL; |
|
|
|
|
|
|
|
PEP_rating rating; |
|
|
|
PEP_decrypt_flags_t flags = 0; |
|
|
|
|
|
|
|
message* dec_msg = NULL; |
|
|
|
message* enc_msg = NULL; |
|
|
|
status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg, NULL); |
|
|
|
ASSERT_OK; |
|
|
|
|
|
|
|
status = decrypt_message(session, enc_msg, &dec_msg, &keylist, &rating, &flags); |
|
|
|
ASSERT_EQ(status, PEP_DECRYPTED); // ???
|
|
|
|
|
|
|
|
ok = slurp_and_import_key(session, "test_keys/pub/inquisitor-0xA4728718_renewed_pub.asc"); |
|
|
|
ASSERT_TRUE(ok); |
|
|
|
|
|
|
|
message* msg2 = new_message(PEP_dir_outgoing); |
|
|
|
|
|
|
|
msg2->from = alice_from; |
|
|
|
msg2->to = new_identity_list(expired_inquisitor); |
|
|
|
msg2->shortmsg = strdup("Blah!"); |
|
|
|
msg2->longmsg = strdup("Blahblahblah!"); |
|
|
|
msg2->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL); |
|
|
|
|
|
|
|
// We don't keep OpenPGP expired keys. We'll have to receive the new one via mail.
|
|
|
|
status = outgoing_message_rating(session, msg2, &rating); |
|
|
|
ASSERT_OK; |
|
|
|
ASSERT_EQ(rating, PEP_rating_unencrypted); |
|
|
|
} |
|
|
|
|
|
|
|
TEST_F(CheckRenewedExpiredKeyTrustStatusTest, check_renewed_expired_key_trust_status_trusted_user) { |
|
|
|
// If we updated an OpenPGP identity in the meantime, we will have removed the key. Too bad.
|
|
|
|
// Trust will have to be redone.
|
|
|
|
TEST_F(CheckRenewedExpiredKeyTrustStatusTest, check_renewed_expired_key_trust_status_trusted_user_OpenPGP) { |
|
|
|
bool ok = false; |
|
|
|
ok = slurp_and_import_key(session, "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc"); |
|
|
|
ASSERT_TRUE(ok); |
|
|
@ -155,13 +225,11 @@ TEST_F(CheckRenewedExpiredKeyTrustStatusTest, check_renewed_expired_key_trust_st |
|
|
|
ASSERT_OK; |
|
|
|
|
|
|
|
const char* inquisitor_fpr = "8E8D2381AE066ABE1FEE509821BA977CA4728718"; |
|
|
|
pEp_identity* expired_inquisitor = new_identity("inquisitor@darthmama.org", "8E8D2381AE066ABE1FEE509821BA977CA4728718", "TOFU_inquisitor@darthmama.org", "Lady Claire Trevelyan"); |
|
|
|
pEp_identity* expired_inquisitor = new_identity("inquisitor@darthmama.org", "8E8D2381AE066ABE1FEE509821BA977CA4728718", "INQUISITOR", "Lady Claire Trevelyan"); |
|
|
|
|
|
|
|
status = set_fpr_preserve_ident(session, expired_inquisitor, inquisitor_fpr, false); |
|
|
|
ASSERT_OK; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PEP_comm_type key_ct; |
|
|
|
status = get_key_rating(session, inquisitor_fpr, &key_ct); |
|
|
|
ASSERT_EQ(status, PEP_STATUS_OK); |
|
|
@ -193,26 +261,29 @@ TEST_F(CheckRenewedExpiredKeyTrustStatusTest, check_renewed_expired_key_trust_st |
|
|
|
const string msg = slurp("test_mails/ENGINE-463-attempt-numero-dos.eml"); |
|
|
|
|
|
|
|
char* decrypted_msg = NULL; |
|
|
|
stringlist_t* keylist_used = nullptr; |
|
|
|
char* modified_src = NULL; |
|
|
|
stringlist_t* keylist = NULL; |
|
|
|
// char* modified_src = NULL;
|
|
|
|
|
|
|
|
PEP_rating rating; |
|
|
|
PEP_decrypt_flags_t flags = 0; |
|
|
|
|
|
|
|
status = MIME_decrypt_message(session, msg.c_str(), msg.size(), &decrypted_msg, &keylist_used, &rating, &flags, &modified_src); |
|
|
|
ASSERT_EQ(status , PEP_DECRYPTED); |
|
|
|
message* dec_msg = NULL; |
|
|
|
message* enc_msg = NULL; |
|
|
|
status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg, NULL); |
|
|
|
ASSERT_OK; |
|
|
|
|
|
|
|
status = decrypt_message(session, enc_msg, &dec_msg, &keylist, &rating, &flags); |
|
|
|
ASSERT_EQ(status, PEP_DECRYPTED); // ???
|
|
|
|
|
|
|
|
free(decrypted_msg); |
|
|
|
decrypted_msg = NULL; |
|
|
|
ok = slurp_and_import_key(session, "test_keys/pub/inquisitor-0xA4728718_renewed_pub.asc"); |
|
|
|
ASSERT_TRUE(ok); |
|
|
|
|
|
|
|
pEp_identity* expired_inquisitor1 = new_identity("inquisitor@darthmama.org", NULL, NULL, "Lady Claire Trevelyan"); |
|
|
|
pEp_identity* expired_inquisitor1 = new_identity("inquisitor@darthmama.org", NULL, "INQUISITOR", "Lady Claire Trevelyan"); |
|
|
|
|
|
|
|
status = update_identity(session, expired_inquisitor1); |
|
|
|
ASSERT_OK; |
|
|
|
status = get_trust(session, expired_inquisitor1); |
|
|
|
ASSERT_EQ(expired_inquisitor1->comm_type , PEP_ct_OpenPGP); |
|
|
|
ASSERT_EQ(expired_inquisitor1->comm_type, PEP_ct_key_not_found); |
|
|
|
|
|
|
|
message* msg2 = new_message(PEP_dir_outgoing); |
|
|
|
|
|
|
@ -224,7 +295,7 @@ TEST_F(CheckRenewedExpiredKeyTrustStatusTest, check_renewed_expired_key_trust_st |
|
|
|
|
|
|
|
status = outgoing_message_rating(session, msg2, &rating); |
|
|
|
ASSERT_OK; |
|
|
|
ASSERT_GE(rating, PEP_rating_trusted); |
|
|
|
ASSERT_EQ(rating, PEP_rating_unencrypted); |
|
|
|
|
|
|
|
free_message(msg2); |
|
|
|
} |
|
|
@ -262,17 +333,18 @@ TEST_F(CheckRenewedExpiredKeyTrustStatusTest, check_renewed_expired_key_trust_st |
|
|
|
const string msg = slurp("test_mails/ENGINE-463-attempt-numero-dos.eml"); |
|
|
|
|
|
|
|
char* decrypted_msg = NULL; |
|
|
|
stringlist_t* keylist_used = nullptr; |
|
|
|
char* modified_src = NULL; |
|
|
|
|
|
|
|
stringlist_t* keylist = nullptr; |
|
|
|
PEP_rating rating; |
|
|
|
PEP_decrypt_flags_t flags = 0; |
|
|
|
|
|
|
|
status = MIME_decrypt_message(session, msg.c_str(), msg.size(), &decrypted_msg, &keylist_used, &rating, &flags, &modified_src); |
|
|
|
ASSERT_EQ(status , PEP_DECRYPTED); |
|
|
|
message* dec_msg = NULL; |
|
|
|
message* enc_msg = NULL; |
|
|
|
status = mime_decode_message(msg.c_str(), msg.size(), &enc_msg, NULL); |
|
|
|
ASSERT_OK; |
|
|
|
|
|
|
|
status = decrypt_message(session, enc_msg, &dec_msg, &keylist, &rating, &flags); |
|
|
|
ASSERT_EQ(status, PEP_DECRYPTED); |
|
|
|
|
|
|
|
free(decrypted_msg); |
|
|
|
decrypted_msg = NULL; |
|
|
|
ok = slurp_and_import_key(session, "test_keys/pub/inquisitor-0xA4728718_renewed_pub.asc"); |
|
|
|
ASSERT_TRUE(ok); |
|
|
|
|
|
|
|