ENGINE-633: Hrmph, fixed part of a bug, but strange things are afoot at the Circle K. Committing to get tasty branch diff editing action.

doxygen_doc
parent ace0856641
commit 97156fcbe4

@ -0,0 +1,61 @@
#!/usr/bin/env python3
# Note to python wizzes - I am not trying to be clever or efficient here. This
# is a convenience tool for ridiculous engine debugging fun, and I don't write
# python often. I am definitely not a member of the religion. YMMV, etc.
#
# If you break this, you buy it.
#
import sys
def parse_enum_line(line):
line = line.strip()
parts = line.split()
if len(parts) != 3 or parts[1] != '=' or not parts[0].startswith("PEP_"):
return
key = int(parts[2].strip(','), 0)
value = parts[0]
valueDict[key] = value
def get_error(code):
try:
error = valueDict[code]
except:
print("Hah buddy! You wish!")
exit(-1)
print(str(code) + " -> " + error)
error_val = int(sys.argv[1], 0)
if error_val == None:
print("No error code, no error status!")
exit(-1)
input_fname = "src/pEpEngine.h"
file = open(input_fname, 'r')
content = file.readlines()
file.close()
inStruct = False
valueDict = dict()
# This is super fragile. C'est la vie.
# If another struct is added first, expect chaos! ;)
#
for line in content:
if line.startswith("} PEP_STATUS;"):
break
if not line.startswith("typedef enum {") and not inStruct:
continue
if not inStruct:
inStruct = True
continue
parse_enum_line(line)
get_error(error_val)

@ -780,9 +780,9 @@ DYNAMIC_API PEP_STATUS update_identity(
break;
}
}
else if (!input_is_TOFU) { // can only be true when has_user_id is true
else if (!input_is_TOFU) {
bool name_unset = false;
name_unset = EMPTYSTR(db_list_id->address) || strcasecmp(db_list_id->username, db_list_id->address) == 0;
name_unset = EMPTYSTR(db_list_id->username) || strcasecmp(db_list_id->username, db_list_id->address) == 0;
if (name_unset || names_match) {
// Ok, we have a temp ID. We have to replace this
// with the real ID in the DB.

@ -89,6 +89,7 @@ namespace {
TEST_F(BlacklistAcceptNewKeyTest, check_blacklist_accept_new_key) {
PEP_STATUS status = PEP_STATUS_OK;
// blacklist test code
@ -100,27 +101,37 @@ TEST_F(BlacklistAcceptNewKeyTest, check_blacklist_accept_new_key) {
const string keytext = slurp("test_keys/pub/blacklisted_pub.asc");
/* import it into pep */
PEP_STATUS status7 = import_key(session, keytext.c_str(), keytext.length(), NULL);
status = import_key(session, keytext.c_str(), keytext.length(), NULL);
ASSERT_EQ(status, PEP_KEY_IMPORTED);
const char* bl_fpr_1 = "279765A2FEB5B7C731B861D93E4CEFD9F7AF4684";
bool is_blacklisted = false;
pEp_identity* blacklisted_identity = new_identity("blacklistedkeys@kgrothoff.org",
bl_fpr_1,
NULL,
"TOFU_blacklistedkeys@kgrothoff.org",
"Blacklist Keypair");
PEP_STATUS status8 = update_identity(session, blacklisted_identity);
PEP_STATUS status9 = blacklist_add(session, bl_fpr_1);
PEP_STATUS status10 = blacklist_is_listed(session, bl_fpr_1, &is_blacklisted);
// Explicitly set identity, since we need the key in there
status = set_identity(session, blacklisted_identity);
ASSERT_OK;
status = update_identity(session, blacklisted_identity);
ASSERT_OK;
status = blacklist_add(session, bl_fpr_1);
ASSERT_OK;
status = blacklist_is_listed(session, bl_fpr_1, &is_blacklisted);
ASSERT_OK;
ASSERT_TRUE(is_blacklisted);
PEP_STATUS status11 = update_identity(session, blacklisted_identity);
ASSERT_EQ(status11 , PEP_STATUS_OK);
status = update_identity(session, blacklisted_identity);
ASSERT_OK;
ASSERT_STREQ(bl_fpr_1, blacklisted_identity->fpr);
bool id_def, us_def, addr_def;
status11 = get_valid_pubkey(session, blacklisted_identity,
status = get_valid_pubkey(session, blacklisted_identity,
&id_def, &us_def, &addr_def, true);
ASSERT_EQ(blacklisted_identity->comm_type , PEP_ct_unknown);
ASSERT_EQ(status, PEP_KEY_BLACKLISTED);
ASSERT_EQ(blacklisted_identity->comm_type , PEP_ct_key_not_found);
if (!(blacklisted_identity->fpr))
output_stream << "OK! blacklisted_identity->fpr is empty. Yay!" << endl;
@ -133,9 +144,9 @@ TEST_F(BlacklistAcceptNewKeyTest, check_blacklist_accept_new_key) {
const char* new_key = "634FAC4417E9B2A5DC2BD4AAC4AEEBBE7E62701B";
const string mailtext = slurp("test_mails/blacklist_new_key_attached.eml");
pEp_identity * me1 = new_identity("blacklist_test@kgrothoff.org", NULL, PEP_OWN_USERID, "Blacklisted Key Message Recipient");
pEp_identity * me1 = new_identity("blacklist_test@kgrothoff.org", "634FAC4417E9B2A5DC2BD4AAC4AEEBBE7E62701B", PEP_OWN_USERID, "Blacklisted Key Message Recipient");
PEP_STATUS status = update_identity(session, me1);
status = update_identity(session, me1);
message* msg_ptr = nullptr;
message* dest_msg = nullptr;
stringlist_t* keylist = nullptr;
@ -146,13 +157,18 @@ TEST_F(BlacklistAcceptNewKeyTest, check_blacklist_accept_new_key) {
ASSERT_EQ(status , PEP_STATUS_OK);
status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
PEP_STATUS status12 = get_valid_pubkey(session, blacklisted_identity,
&id_def, &us_def, &addr_def, true);
// Key election is gone, but getting it via mail should set a default!
status = get_valid_pubkey(session, blacklisted_identity,
&id_def, &us_def, &addr_def, true);
ASSERT_STRCASEEQ(blacklisted_identity->fpr, new_key);
PEP_STATUS status13 = blacklist_delete(session, bl_fpr_1);
PEP_STATUS status14 = update_identity(session, blacklisted_identity);
// Now, that
status = blacklist_delete(session, bl_fpr_1);
ASSERT_OK;
status = update_identity(session, blacklisted_identity);
ASSERT_OK;
free_message(msg_ptr);
free_message(dest_msg);

Loading…
Cancel
Save