Browse Source

clean_own_key_defaults moved to DYNAMIC_API - to be called by adapter on first session and not by init()

test-README.md Release_2.1.0-RC17
parent
commit
868d5d188b
4 changed files with 38 additions and 17 deletions
  1. +1
    -1
      src/keymanagement.c
  2. +19
    -2
      src/keymanagement.h
  3. +6
    -5
      src/pEpEngine.c
  4. +12
    -9
      test/src/CleanInvalidOwnKeysTest.cc

+ 1
- 1
src/keymanagement.c View File

@ -2072,7 +2072,7 @@ static PEP_STATUS _wipe_default_key_if_invalid(PEP_SESSION session,
return status;
}
PEP_STATUS clean_own_key_defaults(PEP_SESSION session) {
DYNAMIC_API PEP_STATUS clean_own_key_defaults(PEP_SESSION session) {
identity_list* idents = NULL;
PEP_STATUS status = own_identities_retrieve(session, &idents);
if (status != PEP_STATUS_OK)


+ 19
- 2
src/keymanagement.h View File

@ -381,6 +381,25 @@ DYNAMIC_API PEP_STATUS set_own_key(
const char *fpr
);
//
// clean_own_key_defaults()
//
// Remove any broken, unrenewable expired, or revoked
// own keys from identity and user defaults in the database.
//
// parameters:
// session (in) session to use
//
// return value:
// PEP_STATUS_OK if all went well
// PEP_PASSPHRASE_REQUIRED if a key needs to be renewed
// but cached passphrase isn't present
// PEP_WRONG_PASSPHRASE if passphrase required for expired key renewal
// but passphrase is the wrong one
// Otherwise, database and keyring errors as appropriate
//
DYNAMIC_API PEP_STATUS clean_own_key_defaults(PEP_SESSION session);
PEP_STATUS get_all_keys_for_user(PEP_SESSION session,
const char* user_id,
stringlist_t** keys);
@ -408,8 +427,6 @@ PEP_STATUS get_valid_pubkey(PEP_SESSION session,
bool* is_address_default,
bool check_blacklist);
PEP_STATUS clean_own_key_defaults(PEP_SESSION session);
#ifdef __cplusplus
}
#endif

+ 6
- 5
src/pEpEngine.c View File

@ -2099,11 +2099,12 @@ DYNAMIC_API PEP_STATUS init(
goto pEp_error;
// runtime config
// clean up invalid keys
status = clean_own_key_defaults(_session);
if (status != PEP_STATUS_OK)
goto pEp_error;
// Will now be called by adapter.
// // clean up invalid keys
// status = clean_own_key_defaults(_session);
// if (status != PEP_STATUS_OK)
// goto pEp_error;
*session = _session;


+ 12
- 9
test/src/CleanInvalidOwnKeysTest.cc View File

@ -82,10 +82,11 @@ namespace {
TEST_F(CleanInvalidOwnKeysTest, check_clean_invalid_own_keys_no_alts_revoked) {
// 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_STATUS status = clean_own_key_defaults(session);
ASSERT_EQ(status, PEP_STATUS_OK);
pEp_identity* alice = NULL;
PEP_STATUS status = get_identity(session, "pep.test.alice@pep-project.org", "ALICE", &alice);
status = get_identity(session, "pep.test.alice@pep-project.org", "ALICE", &alice);
ASSERT_EQ(status, PEP_STATUS_OK);
ASSERT_STRNE(alice->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97");
char* fpr = NULL;
@ -95,10 +96,11 @@ TEST_F(CleanInvalidOwnKeysTest, check_clean_invalid_own_keys_no_alts_revoked) {
}
TEST_F(CleanInvalidOwnKeysTest, check_clean_invalid_own_keys_no_alts_mistrusted) {
// 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_STATUS status = clean_own_key_defaults(session);
ASSERT_EQ(status, PEP_STATUS_OK);
pEp_identity* alice = NULL;
PEP_STATUS status = get_identity(session, "pep.test.alice@pep-project.org", "ALICE", &alice);
status = get_identity(session, "pep.test.alice@pep-project.org", "ALICE", &alice);
ASSERT_EQ(status, PEP_STATUS_OK);
ASSERT_STRNE(alice->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97");
char* fpr = NULL;
@ -108,10 +110,11 @@ TEST_F(CleanInvalidOwnKeysTest, check_clean_invalid_own_keys_no_alts_mistrusted)
}
TEST_F(CleanInvalidOwnKeysTest, check_clean_invalid_own_keys_no_alts_expired) {
// 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_STATUS status = clean_own_key_defaults(session);
ASSERT_EQ(status, PEP_STATUS_OK);
pEp_identity* bob = NULL;
PEP_STATUS status = get_identity(session, "expired_bob_0@darthmama.org", "BOB", &bob);
status = get_identity(session, "expired_bob_0@darthmama.org", "BOB", &bob);
ASSERT_EQ(status, PEP_STATUS_OK);
ASSERT_STREQ(bob->fpr, "E4A8CD51C25D0ED5BAD0834BD2FDE305A35FE3F5");
char* fpr = NULL;


Loading…
Cancel
Save