Argh, cut-and-paste error broke all the things. sync
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Tue, 26 Mar 2019 19:14:46 +0100
branchsync
changeset 3400127abd38d1c2
parent 3399 97762a37bd0f
child 3401 9d9142a1490e
Argh, cut-and-paste error broke all the things.
src/keymanagement.c
test/include/OwnIdentitiesRetrieveTests.h
test/src/SuiteMaker.cc
test/src/engine_tests/NewUpdateIdAndMyselfTests.cc
test/src/engine_tests/OwnIdentitiesRetrieveTests.cc
     1.1 --- a/src/keymanagement.c	Mon Mar 25 17:02:10 2019 +0100
     1.2 +++ b/src/keymanagement.c	Tue Mar 26 19:14:46 2019 +0100
     1.3 @@ -1657,7 +1657,7 @@
     1.4      
     1.5      identity_list *_bl = _own_identities;
     1.6  
     1.7 -    sqlite3_bind_int(session->own_keys_retrieve, 1, excluded_flags);
     1.8 +    sqlite3_bind_int(session->own_identities_retrieve, 1, excluded_flags);
     1.9  
    1.10      do {
    1.11          result = sqlite3_step(session->own_identities_retrieve);
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/include/OwnIdentitiesRetrieveTests.h	Tue Mar 26 19:14:46 2019 +0100
     2.3 @@ -0,0 +1,19 @@
     2.4 +// This file is under GNU General Public License 3.0
     2.5 +// see LICENSE.txt
     2.6 +
     2.7 +#ifndef OWN_IDENTITIES_RETRIEVE_H
     2.8 +#define OWN_IDENTITIES_RETRIEVE_H
     2.9 +
    2.10 +#include <string>
    2.11 +#include "EngineTestIndividualSuite.h"
    2.12 +
    2.13 +using namespace std;
    2.14 +
    2.15 +class OwnIdentitiesRetrieveTests : public EngineTestIndividualSuite {
    2.16 +    public:
    2.17 +        OwnIdentitiesRetrieveTests(string test_suite, string test_home_dir);
    2.18 +    private:
    2.19 +        void check_own_identities_retrieve();
    2.20 +};
    2.21 +
    2.22 +#endif
     3.1 --- a/test/src/SuiteMaker.cc	Mon Mar 25 17:02:10 2019 +0100
     3.2 +++ b/test/src/SuiteMaker.cc	Tue Mar 26 19:14:46 2019 +0100
     3.3 @@ -13,6 +13,7 @@
     3.4  
     3.5  // Begin where we generate stuff
     3.6  #include "MimeTests.h"
     3.7 +#include "OwnIdentitiesRetrieveTests.h"
     3.8  #include "ExpiredSubkeyTests.h"
     3.9  #include "UserIdCollisionTests.h"
    3.10  #include "Engine463Tests.h"
    3.11 @@ -65,6 +66,7 @@
    3.12  
    3.13  const char* SuiteMaker::all_suites[] = {
    3.14      "MimeTests",
    3.15 +    "OwnIdentitiesRetrieveTests",
    3.16      "ExpiredSubkeyTests",
    3.17      "UserIdCollisionTests",
    3.18      "Engine463Tests",
    3.19 @@ -116,11 +118,13 @@
    3.20  };
    3.21  
    3.22  // This file is generated, so magic constants are ok.
    3.23 -int SuiteMaker::num_suites = 49;
    3.24 +int SuiteMaker::num_suites = 50;
    3.25  
    3.26  void SuiteMaker::suitemaker_build(const char* test_class_name, const char* test_home, Test::Suite** test_suite) {
    3.27      if (strcmp(test_class_name, "MimeTests") == 0)
    3.28          *test_suite = new MimeTests(test_class_name, test_home);
    3.29 +    else if (strcmp(test_class_name, "OwnIdentitiesRetrieveTests") == 0)
    3.30 +        *test_suite = new OwnIdentitiesRetrieveTests(test_class_name, test_home);
    3.31      else if (strcmp(test_class_name, "ExpiredSubkeyTests") == 0)
    3.32          *test_suite = new ExpiredSubkeyTests(test_class_name, test_home);
    3.33      else if (strcmp(test_class_name, "UserIdCollisionTests") == 0)
     4.1 --- a/test/src/engine_tests/NewUpdateIdAndMyselfTests.cc	Mon Mar 25 17:02:10 2019 +0100
     4.2 +++ b/test/src/engine_tests/NewUpdateIdAndMyselfTests.cc	Tue Mar 26 19:14:46 2019 +0100
     4.3 @@ -531,18 +531,21 @@
     4.4      revoke_fpr_arr[0] = strdup(revokemaster_3000->fpr);
     4.5      free(revokemaster_3000->fpr);
     4.6      revokemaster_3000->fpr = NULL;
     4.7 +    cout << "revoke_fpr_arr[0] is " << revoke_fpr_arr[0] << endl; 
     4.8      
     4.9      status = generate_keypair(session, revokemaster_3000);
    4.10      TEST_ASSERT_MSG((status == PEP_STATUS_OK && revokemaster_3000->fpr), (string(tl_status_string(status)) + " " + revokemaster_3000->fpr).c_str());
    4.11      revoke_fpr_arr[1] = strdup(revokemaster_3000->fpr);
    4.12      free(revokemaster_3000->fpr);
    4.13      revokemaster_3000->fpr = NULL;
    4.14 +    cout << "revoke_fpr_arr[1] is " << revoke_fpr_arr[1] << endl; 
    4.15      
    4.16      status = generate_keypair(session, revokemaster_3000);
    4.17      TEST_ASSERT_MSG((status == PEP_STATUS_OK && revokemaster_3000->fpr), (string(tl_status_string(status)) + " " + revokemaster_3000->fpr).c_str());
    4.18      revoke_fpr_arr[2] = strdup(revokemaster_3000->fpr);
    4.19      free(revokemaster_3000->fpr);
    4.20      revokemaster_3000->fpr = NULL;
    4.21 +    cout << "revoke_fpr_arr[2] is " << revoke_fpr_arr[2] << endl; 
    4.22      
    4.23      cout << "Trust "  << revoke_fpr_arr[2] << " (default for identity) and " << revoke_fpr_arr[0] << endl;
    4.24      
    4.25 @@ -583,16 +586,21 @@
    4.26      TEST_ASSERT_MSG((is_revoked), "is_revoked");
    4.27  
    4.28      cout << "Success revoking " << revoke_fpr_arr[2] << "!!! get_trust for this fpr gives us " << revokemaster_3000->comm_type << endl;
    4.29 -    
    4.30 -    cout << "Now see if update_identity gives us " << revoke_fpr_arr[0] << ", the only trusted key left." << endl;
    4.31 +
    4.32 +//  BAD ASSUMPTION - this only works if we query the trust DB in elect_pubkey, and we don't.    
    4.33 +//    cout << "Now see if update_identity gives us " << revoke_fpr_arr[0] << ", the only trusted key left." << endl;
    4.34      status = update_identity(session, revokemaster_3000);
    4.35      TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
    4.36      TEST_ASSERT_MSG((revokemaster_3000->fpr), revokemaster_3000->fpr);
    4.37 -    TEST_ASSERT_MSG((strcmp(revokemaster_3000->fpr, revoke_fpr_arr[0]) == 0), (string("Expected ") + revoke_fpr_arr[0] + ", Got " + revokemaster_3000->fpr).c_str());
    4.38 +    TEST_ASSERT_MSG((strcmp(revokemaster_3000->fpr, revoke_fpr_arr[0]) == 0
    4.39 +                    || (strcmp(revokemaster_3000->fpr, revoke_fpr_arr[0]) == 0)), 
    4.40 +                    (string("Expected ") + revoke_fpr_arr[0] + " or " + revoke_fpr_arr[1] + ", Got " + revokemaster_3000->fpr).c_str());
    4.41      TEST_ASSERT_MSG((revokemaster_3000->comm_type & PEP_ct_confirmed), tl_ct_string(revokemaster_3000->comm_type));    
    4.42      
    4.43 -    cout << "Success! So let's mistrust it, because seriously, that key was so uncool." << endl;
    4.44 +    cout << "Success! So let's mistrust " << revoke_fpr_arr[0] << ", because seriously, that key was so uncool." << endl;
    4.45      
    4.46 +    free(revokemaster_3000->fpr);
    4.47 +    revokemaster_3000->fpr = strdup(revoke_fpr_arr[0]);
    4.48      status = key_mistrusted(session, revokemaster_3000);
    4.49      TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
    4.50  
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/test/src/engine_tests/OwnIdentitiesRetrieveTests.cc	Tue Mar 26 19:14:46 2019 +0100
     5.3 @@ -0,0 +1,51 @@
     5.4 +// This file is under GNU General Public License 3.0
     5.5 +// see LICENSE.txt
     5.6 +
     5.7 +#include <stdlib.h>
     5.8 +#include <string>
     5.9 +
    5.10 +#include "pEpEngine.h"
    5.11 +#include "keymanagement.h"
    5.12 +
    5.13 +#include <cpptest.h>
    5.14 +#include "EngineTestIndividualSuite.h"
    5.15 +#include "OwnIdentitiesRetrieveTests.h"
    5.16 +
    5.17 +using namespace std;
    5.18 +
    5.19 +OwnIdentitiesRetrieveTests::OwnIdentitiesRetrieveTests(string suitename, string test_home_dir) :
    5.20 +    EngineTestIndividualSuite::EngineTestIndividualSuite(suitename, test_home_dir) {
    5.21 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("OwnIdentitiesRetrieveTests::check_own_identities_retrieve"),
    5.22 +                                                                      static_cast<Func>(&OwnIdentitiesRetrieveTests::check_own_identities_retrieve)));
    5.23 +}
    5.24 +
    5.25 +void OwnIdentitiesRetrieveTests::check_own_identities_retrieve() {
    5.26 +    stringlist_t* keylist = NULL;
    5.27 +    PEP_STATUS status = own_keys_retrieve(session, &keylist);
    5.28 +    TEST_ASSERT(keylist == NULL);
    5.29 +    TEST_ASSERT(status == PEP_STATUS_OK);
    5.30 +
    5.31 +    identity_list* id_list = NULL;
    5.32 +    status = own_identities_retrieve(session, &id_list);
    5.33 +    TEST_ASSERT(id_list == NULL || !(id_list->ident));
    5.34 +    TEST_ASSERT(status == PEP_STATUS_OK);
    5.35 +    
    5.36 +    pEp_identity* me = new_identity("krista_b@darthmama.cool", NULL, "MyOwnId", "Krista B.");
    5.37 +    status = myself(session, me);
    5.38 +    TEST_ASSERT(status == PEP_STATUS_OK);
    5.39 +    TEST_ASSERT(me->fpr);
    5.40 +    
    5.41 +    // Ok, there's a me identity in the DB.
    5.42 +    // Call the naughty function.
    5.43 +    
    5.44 +    status = own_keys_retrieve(session, &keylist);
    5.45 +    TEST_ASSERT(status == PEP_STATUS_OK);
    5.46 +    TEST_ASSERT(keylist);
    5.47 +    TEST_ASSERT(keylist->value);
    5.48 +    cout << keylist->value << endl;
    5.49 +
    5.50 +    status = own_identities_retrieve(session, &id_list);
    5.51 +    TEST_ASSERT(status == PEP_STATUS_OK);
    5.52 +    TEST_ASSERT(id_list);
    5.53 +    TEST_ASSERT(id_list->ident);    
    5.54 +}