clean_own_key_defaults moved to DYNAMIC_API - to be called by adapter on first session and not by init() Release_2.1.0-RC17
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Tue, 14 Jul 2020 00:11:15 +0200
changeset 485422153e06e4cd
parent 4852 308d29b0cac7
child 4855 60e332c4779f
clean_own_key_defaults moved to DYNAMIC_API - to be called by adapter on first session and not by init()
src/keymanagement.c
src/keymanagement.h
src/pEpEngine.c
test/src/CleanInvalidOwnKeysTest.cc
     1.1 --- a/src/keymanagement.c	Mon Jul 13 12:55:21 2020 +0200
     1.2 +++ b/src/keymanagement.c	Tue Jul 14 00:11:15 2020 +0200
     1.3 @@ -2072,7 +2072,7 @@
     1.4      return status;                                        
     1.5  }
     1.6  
     1.7 -PEP_STATUS clean_own_key_defaults(PEP_SESSION session) {
     1.8 +DYNAMIC_API PEP_STATUS clean_own_key_defaults(PEP_SESSION session) {
     1.9      identity_list* idents = NULL;
    1.10      PEP_STATUS status = own_identities_retrieve(session, &idents);
    1.11      if (status != PEP_STATUS_OK)
     2.1 --- a/src/keymanagement.h	Mon Jul 13 12:55:21 2020 +0200
     2.2 +++ b/src/keymanagement.h	Tue Jul 14 00:11:15 2020 +0200
     2.3 @@ -381,6 +381,25 @@
     2.4         const char *fpr
     2.5      );
     2.6  
     2.7 +//
     2.8 +// clean_own_key_defaults()
     2.9 +//
    2.10 +// Remove any broken, unrenewable expired, or revoked 
    2.11 +// own keys from identity and user defaults in the database.
    2.12 +//  
    2.13 +//  parameters:
    2.14 +//      session (in)          session to use
    2.15 +//
    2.16 +//  return value:
    2.17 +//      PEP_STATUS_OK if all went well
    2.18 +//      PEP_PASSPHRASE_REQUIRED if a key needs to be renewed 
    2.19 +//                              but cached passphrase isn't present 
    2.20 +//      PEP_WRONG_PASSPHRASE if passphrase required for expired key renewal 
    2.21 +//                           but passphrase is the wrong one
    2.22 +//      Otherwise, database and keyring errors as appropriate 
    2.23 +//
    2.24 +DYNAMIC_API PEP_STATUS clean_own_key_defaults(PEP_SESSION session);
    2.25 +
    2.26  PEP_STATUS get_all_keys_for_user(PEP_SESSION session, 
    2.27                                   const char* user_id,
    2.28                                   stringlist_t** keys);
    2.29 @@ -408,8 +427,6 @@
    2.30                              bool* is_address_default,
    2.31                              bool check_blacklist);
    2.32  
    2.33 -PEP_STATUS clean_own_key_defaults(PEP_SESSION session);
    2.34 -
    2.35  #ifdef __cplusplus
    2.36  }
    2.37  #endif
     3.1 --- a/src/pEpEngine.c	Mon Jul 13 12:55:21 2020 +0200
     3.2 +++ b/src/pEpEngine.c	Tue Jul 14 00:11:15 2020 +0200
     3.3 @@ -2099,11 +2099,12 @@
     3.4          goto pEp_error;
     3.5  
     3.6      // runtime config
     3.7 -    
     3.8 -    // clean up invalid keys 
     3.9 -    status = clean_own_key_defaults(_session);
    3.10 -    if (status != PEP_STATUS_OK)
    3.11 -        goto pEp_error;
    3.12 +
    3.13 +    // Will now be called by adapter.
    3.14 +    // // clean up invalid keys 
    3.15 +    // status = clean_own_key_defaults(_session);
    3.16 +    // if (status != PEP_STATUS_OK)
    3.17 +    //     goto pEp_error;
    3.18  
    3.19      *session = _session;
    3.20      
     4.1 --- a/test/src/CleanInvalidOwnKeysTest.cc	Mon Jul 13 12:55:21 2020 +0200
     4.2 +++ b/test/src/CleanInvalidOwnKeysTest.cc	Tue Jul 14 00:11:15 2020 +0200
     4.3 @@ -82,10 +82,11 @@
     4.4  
     4.5  
     4.6  TEST_F(CleanInvalidOwnKeysTest, check_clean_invalid_own_keys_no_alts_revoked) {
     4.7 -    // This is just a dummy test case. The convention is check_whatever_you_are_checking
     4.8 -    // so for multiple test cases in a suite, be more explicit ;)   
     4.9 +    PEP_STATUS status = clean_own_key_defaults(session);
    4.10 +    ASSERT_EQ(status, PEP_STATUS_OK);    
    4.11 +
    4.12      pEp_identity* alice = NULL;
    4.13 -    PEP_STATUS status = get_identity(session, "pep.test.alice@pep-project.org", "ALICE", &alice);
    4.14 +    status = get_identity(session, "pep.test.alice@pep-project.org", "ALICE", &alice);
    4.15      ASSERT_EQ(status, PEP_STATUS_OK);
    4.16      ASSERT_STRNE(alice->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97");
    4.17      char* fpr = NULL;
    4.18 @@ -95,10 +96,11 @@
    4.19  }
    4.20  
    4.21  TEST_F(CleanInvalidOwnKeysTest, check_clean_invalid_own_keys_no_alts_mistrusted) {
    4.22 -    // This is just a dummy test case. The convention is check_whatever_you_are_checking
    4.23 -    // so for multiple test cases in a suite, be more explicit ;)   
    4.24 +    PEP_STATUS status = clean_own_key_defaults(session);
    4.25 +    ASSERT_EQ(status, PEP_STATUS_OK);    
    4.26 +
    4.27      pEp_identity* alice = NULL;
    4.28 -    PEP_STATUS status = get_identity(session, "pep.test.alice@pep-project.org", "ALICE", &alice);
    4.29 +    status = get_identity(session, "pep.test.alice@pep-project.org", "ALICE", &alice);
    4.30      ASSERT_EQ(status, PEP_STATUS_OK);
    4.31      ASSERT_STRNE(alice->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97");
    4.32      char* fpr = NULL;
    4.33 @@ -108,10 +110,11 @@
    4.34  }
    4.35  
    4.36  TEST_F(CleanInvalidOwnKeysTest, check_clean_invalid_own_keys_no_alts_expired) {
    4.37 -    // This is just a dummy test case. The convention is check_whatever_you_are_checking
    4.38 -    // so for multiple test cases in a suite, be more explicit ;)   
    4.39 +    PEP_STATUS status = clean_own_key_defaults(session);
    4.40 +    ASSERT_EQ(status, PEP_STATUS_OK);    
    4.41 +
    4.42      pEp_identity* bob = NULL;
    4.43 -    PEP_STATUS status = get_identity(session, "expired_bob_0@darthmama.org", "BOB", &bob);
    4.44 +    status = get_identity(session, "expired_bob_0@darthmama.org", "BOB", &bob);
    4.45      ASSERT_EQ(status, PEP_STATUS_OK);
    4.46      ASSERT_STREQ(bob->fpr, "E4A8CD51C25D0ED5BAD0834BD2FDE305A35FE3F5");
    4.47      char* fpr = NULL;