Changed pgp_sequoia.c not to assert out on signature case for import key, but rather to return PEP_NO_KEY_IMPORTED (whatever is there still needs to be implemented, but it was doing this in a case which was not in fact a revocation cert, but a plaintext file we try to import as a key (which is not one), which is valid for the engine. Also broke up monolithic test file so we can test the one remaining test that fails, and removed error.h import on pgp_sequoia.c, which is both unnecessary and not portable. sync
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Mon, 25 Mar 2019 15:16:50 +0100
branchsync
changeset 3396d5d64124bb10
parent 3378 7f1e1775d946
child 3397 837e7a550111
Changed pgp_sequoia.c not to assert out on signature case for import key, but rather to return PEP_NO_KEY_IMPORTED (whatever is there still needs to be implemented, but it was doing this in a case which was not in fact a revocation cert, but a plaintext file we try to import as a key (which is not one), which is valid for the engine. Also broke up monolithic test file so we can test the one remaining test that fails, and removed error.h import on pgp_sequoia.c, which is both unnecessary and not portable.
src/pgp_sequoia.c
test/include/NewUpdateIdAndMyselfTests.h
test/src/engine_tests/NewUpdateIdAndMyselfTests.cc
     1.1 --- a/src/pgp_sequoia.c	Fri Mar 22 12:56:31 2019 +0100
     1.2 +++ b/src/pgp_sequoia.c	Mon Mar 25 15:16:50 2019 +0100
     1.3 @@ -10,7 +10,6 @@
     1.4  #include <limits.h>
     1.5  #include <sys/stat.h>
     1.6  #include <sys/types.h>
     1.7 -#include <error.h>
     1.8  
     1.9  #include <sqlite3.h>
    1.10  
    1.11 @@ -1582,7 +1581,8 @@
    1.12      switch (tag) {
    1.13      case PGP_TAG_SIGNATURE:
    1.14          // XXX: Implement me.
    1.15 -        assert(!"Have possible revocation certificate!");
    1.16 +        // assert(!"Have possible revocation certificate!");
    1.17 +		ERROR_OUT(NULL, PEP_NO_KEY_IMPORTED, "Implement me: Have possible revocation certificate!");
    1.18          break;
    1.19  
    1.20      case PGP_TAG_PUBLIC_KEY:
     2.1 --- a/test/include/NewUpdateIdAndMyselfTests.h	Fri Mar 22 12:56:31 2019 +0100
     2.2 +++ b/test/include/NewUpdateIdAndMyselfTests.h	Mon Mar 25 15:16:50 2019 +0100
     2.3 @@ -12,8 +12,40 @@
     2.4  class NewUpdateIdAndMyselfTests : public EngineTestSessionSuite {
     2.5      public:
     2.6          NewUpdateIdAndMyselfTests(string test_suite, string test_home_dir);
     2.7 +	protected:
     2.8 +		char* uniqname;
     2.9 +		char* own_user_id;
    2.10 +		char* start_username;
    2.11 +		char* generated_fpr;
    2.12 +		char* default_own_id;
    2.13 +		char* alias_id;
    2.14 +        char* new_fpr;
    2.15 +        const char* alex_address;
    2.16 +        const char* alex_fpr;
    2.17 +        const char* alex_userid;
    2.18 +        const char* alex_username;
    2.19 +        const char* new_username;
    2.20 +    
    2.21 +        void setup();
    2.22 +        void tear_down();
    2.23      private:
    2.24 -        void check_new_update_id_and_myself();
    2.25 +        void myself_no_record_no_input_fpr();
    2.26 +        void myself_no_input_fpr_w_record();
    2.27 +        void myself_no_input_fpr_diff_user_id_w_record();
    2.28 +        void myself_replace_fpr();
    2.29 +        void myself_replace_fpr_revoke_key();
    2.30 +        void update_identity_w_matching_address_user_id_username();
    2.31 +        void update_identity_w_matching_address_user_id_new_username();
    2.32 +        void update_identity_w_matching_address_user_id_only();
    2.33 +        void update_identity_use_address_username_only();
    2.34 +        void update_identity_use_address_only();
    2.35 +        void update_identity_use_address_only_on_own_ident();
    2.36 +        void update_identity_non_existent_user_id_address();
    2.37 +        void update_identity_address_username_userid_no_record();
    2.38 +        void update_identity_address_username_no_record();
    2.39 +        void update_identity_address_only_multiple_records();
    2.40 +        void key_elect_expired_key();
    2.41 +        void key_elect_only_revoked_mistrusted();
    2.42  };
    2.43  
    2.44  #endif
     3.1 --- a/test/src/engine_tests/NewUpdateIdAndMyselfTests.cc	Fri Mar 22 12:56:31 2019 +0100
     3.2 +++ b/test/src/engine_tests/NewUpdateIdAndMyselfTests.cc	Mon Mar 25 15:16:50 2019 +0100
     3.3 @@ -21,55 +21,98 @@
     3.4  
     3.5  NewUpdateIdAndMyselfTests::NewUpdateIdAndMyselfTests(string suitename, string test_home_dir) :
     3.6      EngineTestSessionSuite::EngineTestSessionSuite(suitename, test_home_dir) {
     3.7 -    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("NewUpdateIdAndMyselfTests::check_new_update_id_and_myself"),
     3.8 -                                                                      static_cast<Func>(&NewUpdateIdAndMyselfTests::check_new_update_id_and_myself)));
     3.9 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("NewUpdateIdAndMyselfTests::myself_no_record_no_input_fpr"),
    3.10 +                                                                      static_cast<Func>(&NewUpdateIdAndMyselfTests::myself_no_record_no_input_fpr)));
    3.11 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("NewUpdateIdAndMyselfTests::myself_no_input_fpr_w_record"),
    3.12 +                                                                      static_cast<Func>(&NewUpdateIdAndMyselfTests::myself_no_input_fpr_w_record)));
    3.13 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("NewUpdateIdAndMyselfTests::myself_no_input_fpr_diff_user_id_w_record"),
    3.14 +                                                                      static_cast<Func>(&NewUpdateIdAndMyselfTests::myself_no_input_fpr_diff_user_id_w_record)));
    3.15 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("NewUpdateIdAndMyselfTests::myself_replace_fpr"),
    3.16 +                                                                      static_cast<Func>(&NewUpdateIdAndMyselfTests::myself_replace_fpr)));
    3.17 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("NewUpdateIdAndMyselfTests::myself_replace_fpr_revoke_key"),
    3.18 +                                                                      static_cast<Func>(&NewUpdateIdAndMyselfTests::myself_replace_fpr_revoke_key)));
    3.19 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("NewUpdateIdAndMyselfTests::update_identity_w_matching_address_user_id_username"),
    3.20 +                                                                      static_cast<Func>(&NewUpdateIdAndMyselfTests::update_identity_w_matching_address_user_id_username)));
    3.21 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("NewUpdateIdAndMyselfTests::update_identity_w_matching_address_user_id_new_username"),
    3.22 +                                                                      static_cast<Func>(&NewUpdateIdAndMyselfTests::update_identity_w_matching_address_user_id_new_username)));
    3.23 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("NewUpdateIdAndMyselfTests::update_identity_w_matching_address_user_id_only"),
    3.24 +                                                                      static_cast<Func>(&NewUpdateIdAndMyselfTests::update_identity_w_matching_address_user_id_only)));
    3.25 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("NewUpdateIdAndMyselfTests::update_identity_use_address_username_only"),
    3.26 +                                                                      static_cast<Func>(&NewUpdateIdAndMyselfTests::update_identity_use_address_username_only)));
    3.27 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("NewUpdateIdAndMyselfTests::update_identity_use_address_only"),
    3.28 +                                                                      static_cast<Func>(&NewUpdateIdAndMyselfTests::update_identity_use_address_only)));
    3.29 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("NewUpdateIdAndMyselfTests::update_identity_use_address_only_on_own_ident"),
    3.30 +                                                                      static_cast<Func>(&NewUpdateIdAndMyselfTests::update_identity_use_address_only_on_own_ident)));
    3.31 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("NewUpdateIdAndMyselfTests::update_identity_non_existent_user_id_address"),
    3.32 +                                                                      static_cast<Func>(&NewUpdateIdAndMyselfTests::update_identity_non_existent_user_id_address)));
    3.33 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("NewUpdateIdAndMyselfTests::update_identity_address_username_userid_no_record"),
    3.34 +                                                                      static_cast<Func>(&NewUpdateIdAndMyselfTests::update_identity_address_username_userid_no_record)));
    3.35 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("NewUpdateIdAndMyselfTests::update_identity_address_username_no_record"),
    3.36 +                                                                      static_cast<Func>(&NewUpdateIdAndMyselfTests::update_identity_address_username_no_record)));
    3.37 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("NewUpdateIdAndMyselfTests::update_identity_address_only_multiple_records"),
    3.38 +                                                                      static_cast<Func>(&NewUpdateIdAndMyselfTests::update_identity_address_only_multiple_records)));
    3.39 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("NewUpdateIdAndMyselfTests::key_elect_expired_key"),
    3.40 +                                                                      static_cast<Func>(&NewUpdateIdAndMyselfTests::key_elect_expired_key)));
    3.41 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("NewUpdateIdAndMyselfTests::key_elect_only_revoked_mistrusted"),
    3.42 +                                                                      static_cast<Func>(&NewUpdateIdAndMyselfTests::key_elect_only_revoked_mistrusted)));
    3.43  }
    3.44  
    3.45 -void NewUpdateIdAndMyselfTests::check_new_update_id_and_myself() {
    3.46 -    
    3.47 +void NewUpdateIdAndMyselfTests::setup() {
    3.48 +    EngineTestSessionSuite::setup();
    3.49 +    if (on_test_number == 1) {
    3.50 +        uniqname = strdup("AAAAtestuser@testdomain.org");
    3.51 +        srandom(time(NULL));
    3.52 +        for(int i=0; i < 4;i++)
    3.53 +        uniqname[i] += random() & 0xf;
    3.54 +        
    3.55 +        own_user_id = get_new_uuid();
    3.56 +        start_username = strdup("Unser Testkandidat");
    3.57 +        generated_fpr = NULL;
    3.58 +        default_own_id = NULL;
    3.59 +        alias_id = NULL;
    3.60 +        new_fpr = NULL;
    3.61 +        alex_address = "pep.test.alexander@peptest.ch";
    3.62 +        alex_fpr = "3AD9F60FAEB22675DB873A1362D6981326B54E4E";
    3.63 +        alex_userid = "Alex";
    3.64 +        alex_username = "SuperDuperAlex";
    3.65 +    }    
    3.66 +}
    3.67 +
    3.68 +void NewUpdateIdAndMyselfTests::tear_down() {
    3.69 +    if (on_test_number == number_of_tests) {
    3.70 +        free(uniqname);
    3.71 +        free(own_user_id);
    3.72 +        free(start_username);
    3.73 +        free(generated_fpr);
    3.74 +        free(default_own_id);
    3.75 +        free(alias_id);
    3.76 +        free(new_fpr);
    3.77 +    }
    3.78 +    EngineTestSessionSuite::tear_down();
    3.79 +}
    3.80 +
    3.81 +void NewUpdateIdAndMyselfTests::myself_no_record_no_input_fpr() {
    3.82      PEP_STATUS status = PEP_STATUS_OK;
    3.83      
    3.84 -    cout << "***********************************************************************" << endl;
    3.85 -    cout << "* Section I. myself()" << endl;
    3.86 -    cout << "***********************************************************************" << endl << endl;
    3.87 -
    3.88 -    // Create id with no key
    3.89 -    cout << "Creating new own id with no key for : ";
    3.90 -    char *uniqname = strdup("AAAAtestuser@testdomain.org");
    3.91 -    srandom(time(NULL));
    3.92 -    for(int i=0; i < 4;i++)
    3.93 -        uniqname[i] += random() & 0xf;
    3.94 -    
    3.95 -    cout << uniqname << "\n";
    3.96 -    
    3.97 -    const char* own_user_id = get_new_uuid();
    3.98 -    const char* start_username = "Unser Testkandidat";
    3.99 -
   3.100      pEp_identity * new_me = new_identity(uniqname, NULL, own_user_id, start_username);
   3.101      
   3.102 -    cout << "***********************************************************************" << endl;
   3.103 -    cout << "* I: 1. myself() on id with no record in the DB and no input fpr" << endl;
   3.104 -    cout << "***********************************************************************" << endl << endl;
   3.105      status = myself(session, new_me);
   3.106 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.107 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.108      TEST_ASSERT_MSG((new_me->fpr), "new_me->fpr");
   3.109      
   3.110 -    cout << "PASS: myself() generated fingerprint ";
   3.111 -    cout << new_me->fpr << endl << endl;
   3.112 -
   3.113 -    char* generated_fpr = strdup(new_me->fpr);
   3.114 +    generated_fpr = strdup(new_me->fpr);
   3.115      
   3.116      TEST_ASSERT_MSG((new_me->comm_type == PEP_ct_pEp), "new_me->comm_type == PEP_ct_pEp");
   3.117      
   3.118      free_identity(new_me);
   3.119 +}
   3.120  
   3.121 -    cout << "***********************************************************************" << endl;
   3.122 -    cout << "* I: 2. myself() on id with no input fpr and a record in the DB" << endl;
   3.123 -    cout << "***********************************************************************" << endl << endl;
   3.124 -
   3.125 -    new_me = new_identity(uniqname, NULL, own_user_id, NULL);
   3.126 +void NewUpdateIdAndMyselfTests::myself_no_input_fpr_w_record() {
   3.127 +    PEP_STATUS status = PEP_STATUS_OK;
   3.128 +    
   3.129 +    pEp_identity* new_me = new_identity(uniqname, NULL, own_user_id, NULL);
   3.130      status = myself(session, new_me);
   3.131 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.132 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.133      
   3.134      TEST_ASSERT_MSG((new_me->fpr), "new_me->fpr");
   3.135      TEST_ASSERT_MSG((strcmp(new_me->fpr, generated_fpr) == 0), "strcmp(new_me->fpr, generated_fpr) == 0");
   3.136 @@ -78,7 +121,7 @@
   3.137      TEST_ASSERT_MSG((new_me->user_id), "new_me->user_id");
   3.138      TEST_ASSERT_MSG((new_me->comm_type == PEP_ct_pEp), "new_me->comm_type == PEP_ct_pEp");
   3.139      
   3.140 -    char* default_own_id = NULL;
   3.141 +    default_own_id = NULL;
   3.142      status = get_userid_alias_default(session, own_user_id, &default_own_id);
   3.143      if (status == PEP_CANNOT_FIND_ALIAS) {
   3.144          // Ok, we presume our own id above is the default (should be true if there was no existing DB as in test env)
   3.145 @@ -90,16 +133,15 @@
   3.146      cout << "PASS: myself() retrieved the correct fpr, username and default user id" << endl << endl;
   3.147  
   3.148      free_identity(new_me);
   3.149 -     
   3.150 -    cout << "****************************************************************************************" << endl;
   3.151 -    cout << "* I: 3. myself() on id with no input fpr, a different user_id, and a record in the DB" << endl;
   3.152 -    cout << "****************************************************************************************" << endl << endl;
   3.153 +}
   3.154  
   3.155 -    const char* alias_id = "Huss Es El Mejor Presidente Del Mundo!";
   3.156 +void NewUpdateIdAndMyselfTests::myself_no_input_fpr_diff_user_id_w_record() {
   3.157 +    PEP_STATUS status = PEP_STATUS_OK;
   3.158 +    alias_id = strdup("Huss Es El Mejor Presidente Del Mundo!");
   3.159  
   3.160 -    new_me = new_identity(uniqname, NULL, alias_id, NULL);
   3.161 +    pEp_identity* new_me = new_identity(uniqname, NULL, alias_id, NULL);
   3.162      status = myself(session, new_me);
   3.163 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.164 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.165      
   3.166      TEST_ASSERT_MSG((new_me->fpr), "new_me->fpr");
   3.167      TEST_ASSERT_MSG((strcmp(new_me->fpr, generated_fpr) == 0), "strcmp(new_me->fpr, generated_fpr) == 0");
   3.168 @@ -112,30 +154,29 @@
   3.169      char* tmp_def = NULL;
   3.170      
   3.171      status = get_userid_alias_default(session, alias_id, &tmp_def);
   3.172 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.173 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.174      TEST_ASSERT_MSG((strcmp(tmp_def, default_own_id) == 0), "strcmp(tmp_def, default_own_id) == 0");
   3.175  
   3.176      cout << "PASS: myself() retrieved the correct fpr, username and default user id, and put the right alias in for the default";
   3.177      cout << endl << endl;
   3.178      
   3.179      free(tmp_def);
   3.180 -    free_identity(new_me);
   3.181 +    free_identity(new_me); 
   3.182 +}
   3.183  
   3.184 -    cout << "****************************************************************************************" << endl;
   3.185 -    cout << "* I: 4. myself(), replace fpr" << endl;
   3.186 -    cout << "****************************************************************************************" << endl << endl;
   3.187 -
   3.188 -    new_me = new_identity(uniqname, NULL, alias_id, start_username);
   3.189 +void NewUpdateIdAndMyselfTests::myself_replace_fpr() {
   3.190 +    PEP_STATUS status = PEP_STATUS_OK;
   3.191 +    pEp_identity* new_me = new_identity(uniqname, NULL, alias_id, start_username);
   3.192      status = generate_keypair(session, new_me);
   3.193      TEST_ASSERT_MSG((new_me->fpr), "new_me->fpr");
   3.194      
   3.195      cout << "Generated fingerprint ";
   3.196      cout << new_me->fpr << "\n";
   3.197  
   3.198 -    char* new_fpr = strdup(new_me->fpr);
   3.199 +    new_fpr = strdup(new_me->fpr);
   3.200  
   3.201      status = set_own_key(session, new_me, new_fpr);
   3.202 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.203 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.204      TEST_ASSERT_MSG((new_me->fpr), "new_me->fpr");
   3.205      TEST_ASSERT_MSG((strcmp(new_me->fpr, generated_fpr) != 0), "strcmp(new_me->fpr, generated_fpr) != 0");
   3.206      TEST_ASSERT_MSG((strcmp(new_me->fpr, new_fpr) == 0), "strcmp(new_me->fpr, new_fpr) == 0");
   3.207 @@ -154,21 +195,21 @@
   3.208      new_me->fpr = strdup(generated_fpr);
   3.209      new_me->comm_type = PEP_ct_unknown;
   3.210      status = set_own_key(session, new_me, generated_fpr);
   3.211 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.212 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.213      TEST_ASSERT_MSG((strcmp(new_me->fpr, generated_fpr) == 0), "strcmp(new_me->fpr, generated_fpr) == 0");
   3.214 -    TEST_ASSERT_MSG((new_me->comm_type == PEP_ct_pEp), "new_me->comm_type == PEP_ct_pEp");
   3.215 -    
   3.216 -    cout << "****************************************************************************************" << endl;
   3.217 -    cout << "* I: 5. myself(), replace fpr, revoke key" << endl;
   3.218 -    cout << "****************************************************************************************" << endl << endl;
   3.219 +    TEST_ASSERT_MSG((new_me->comm_type == PEP_ct_pEp), "new_me->comm_type == PEP_ct_pEp");    
   3.220 +    free_identity(new_me);
   3.221 +}
   3.222  
   3.223 +void NewUpdateIdAndMyselfTests::myself_replace_fpr_revoke_key() {
   3.224 +    PEP_STATUS status = PEP_STATUS_OK;
   3.225      status = revoke_key(session, generated_fpr, "Because it's fun");
   3.226      TEST_ASSERT (status == PEP_STATUS_OK);
   3.227      
   3.228 -    new_me = new_identity(uniqname, NULL, alias_id, start_username);
   3.229 +    pEp_identity* new_me = new_identity(uniqname, NULL, alias_id, start_username);
   3.230      
   3.231      status = set_own_key(session, new_me, new_fpr);
   3.232 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.233 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.234      TEST_ASSERT_MSG((new_me->fpr), "new_me->fpr");
   3.235      TEST_ASSERT_MSG((strcmp(new_me->fpr, generated_fpr) != 0), "strcmp(new_me->fpr, generated_fpr) != 0");
   3.236      TEST_ASSERT_MSG((new_me->username), "new_me->username");
   3.237 @@ -180,14 +221,10 @@
   3.238      
   3.239      cout << "PASS: myself() retrieved the new fpr, username and default user id, and put the right alias in for the default";
   3.240      cout << endl << endl;
   3.241 -        
   3.242 -    cout << "***********************************************************************" << endl;
   3.243 -    cout << "* Section II. update_identity()" << endl;
   3.244 -    cout << "***********************************************************************" << endl << endl;
   3.245 +    free_identity(new_me);
   3.246 +}
   3.247  
   3.248 -    cout << "****************************************************************************************" << endl;
   3.249 -    cout << "* II: 1. update_identity() - get identity with matching address and user_id and username" << endl;
   3.250 -    cout << "****************************************************************************************" << endl << endl;    
   3.251 +void NewUpdateIdAndMyselfTests::update_identity_w_matching_address_user_id_username() {
   3.252      // 1. create original identity
   3.253      const char* alex_address = "pep.test.alexander@peptest.ch";
   3.254      const char* alex_fpr = "3AD9F60FAEB22675DB873A1362D6981326B54E4E";
   3.255 @@ -201,13 +238,13 @@
   3.256      pEp_identity* alex = new_identity(alex_address, alex_fpr, alex_userid, alex_username);
   3.257  
   3.258      // 2. set identity
   3.259 -    status = set_identity(session, alex);
   3.260 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.261 +    PEP_STATUS status = set_identity(session, alex);
   3.262 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.263      free_identity(alex);
   3.264              
   3.265      alex = new_identity(alex_address, NULL, alex_userid, alex_username); 
   3.266      status = update_identity(session, alex);
   3.267 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.268 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.269      TEST_ASSERT_MSG((alex->fpr), "alex->fpr");
   3.270      TEST_ASSERT_MSG((strcmp(alex->fpr, alex_fpr) == 0), "strcmp(alex->fpr, alex_fpr) == 0");
   3.271      TEST_ASSERT_MSG((alex->username), "alex->username");
   3.272 @@ -220,17 +257,47 @@
   3.273  
   3.274      cout << "PASS: update_identity() correctly retrieved extant record with matching address, id, and username" << endl << endl;
   3.275      free_identity(alex);
   3.276 +}
   3.277  
   3.278 -    cout << "****************************************************************************************" << endl;
   3.279 -    cout << "* II: 2. update_identity() - get identity with matching address and user_id and new username" << endl;
   3.280 -    cout << "****************************************************************************************" << endl << endl;    
   3.281 +void NewUpdateIdAndMyselfTests::update_identity_w_matching_address_user_id_new_username() {
   3.282 +    PEP_STATUS status = PEP_STATUS_OK;
   3.283 +        
   3.284 +    const string alex_pub_key = slurp("test_keys/pub/pep.test.alexander-0x26B54E4E_pub.asc");
   3.285 +    
   3.286 +    PEP_STATUS statuspub = import_key(session, alex_pub_key.c_str(), alex_pub_key.length(), NULL);
   3.287 +    TEST_ASSERT_MSG((statuspub == PEP_TEST_KEY_IMPORT_SUCCESS), "statuspub == PEP_STATUS_OK");
   3.288  
   3.289 -    const char* new_username = "Test Patchy";
   3.290 +    pEp_identity* alex = new_identity(alex_address, alex_fpr, alex_userid, alex_username);
   3.291 +
   3.292 +    // 2. set identity
   3.293 +    status = set_identity(session, alex);
   3.294 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.295 +    free_identity(alex);
   3.296              
   3.297 -    alex = new_identity(alex_address, NULL, alex_userid, new_username);
   3.298 -    cout << "Timing is everything" << endl; 
   3.299 +    alex = new_identity(alex_address, NULL, alex_userid, alex_username); 
   3.300      status = update_identity(session, alex);
   3.301 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.302 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.303 +    TEST_ASSERT_MSG((alex->fpr), "alex->fpr");
   3.304 +    TEST_ASSERT_MSG((strcmp(alex->fpr, alex_fpr) == 0), "strcmp(alex->fpr, alex_fpr) == 0");
   3.305 +    TEST_ASSERT_MSG((alex->username), "alex->username");
   3.306 +    TEST_ASSERT_MSG((strcmp(alex->username, alex_username) == 0), "strcmp(alex->username, alex_username) == 0");
   3.307 +    TEST_ASSERT_MSG((alex->user_id), "alex->user_id");
   3.308 +    TEST_ASSERT_MSG((strcmp(alex->user_id, alex_userid) == 0), "strcmp(alex->user_id, alex_userid) == 0");
   3.309 +    TEST_ASSERT_MSG((!alex->me), "!alex->me"); 
   3.310 +    TEST_ASSERT_MSG((alex->comm_type == PEP_ct_OpenPGP_unconfirmed), "alex->comm_type == PEP_ct_OpenPGP_unconfirmed");
   3.311 +    TEST_ASSERT_MSG((strcmp(alex->address, alex_address) == 0), "strcmp(alex->address, alex_address) == 0");
   3.312 +
   3.313 +    cout << "PASS: update_identity() correctly retrieved extant record with matching address, id, and username" << endl << endl;
   3.314 +    free_identity(alex);
   3.315 +}
   3.316 +
   3.317 +void NewUpdateIdAndMyselfTests::update_identity_w_matching_address_user_id_only() {
   3.318 +    PEP_STATUS status = PEP_STATUS_OK;
   3.319 +    new_username = "Test Patchy";
   3.320 +            
   3.321 +    pEp_identity* alex = new_identity(alex_address, NULL, alex_userid, new_username);
   3.322 +    status = update_identity(session, alex);
   3.323 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.324      TEST_ASSERT_MSG((alex->fpr), "alex->fpr");
   3.325      TEST_ASSERT_MSG((strcmp(alex->fpr, alex_fpr) == 0), "strcmp(alex->fpr, alex_fpr) == 0");
   3.326      TEST_ASSERT_MSG((alex->username), "alex->username");
   3.327 @@ -241,36 +308,13 @@
   3.328      TEST_ASSERT_MSG((alex->comm_type == PEP_ct_OpenPGP_unconfirmed), "alex->comm_type == PEP_ct_OpenPGP_unconfirmed");
   3.329      TEST_ASSERT_MSG((strcmp(alex->address, alex_address) == 0), "strcmp(alex->address, alex_address) == 0");
   3.330  
   3.331 -    cout << "PASS: update_identity() correctly retrieved extant record with matching address and id, and patched username" << endl << endl;
   3.332      free_identity(alex);
   3.333 +}
   3.334  
   3.335 -    cout << "****************************************************************************************" << endl;
   3.336 -    cout << "* II: 3. update_identity() - get identity with matching address and user_id only" << endl;
   3.337 -    cout << "****************************************************************************************" << endl << endl;    
   3.338 -        
   3.339 -    alex = new_identity(alex_address, NULL, alex_userid, NULL); 
   3.340 -    status = update_identity(session, alex);
   3.341 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.342 -    TEST_ASSERT_MSG((alex->fpr), "alex->fpr");
   3.343 -    TEST_ASSERT_MSG((strcmp(alex->fpr, alex_fpr) == 0), "strcmp(alex->fpr, alex_fpr) == 0");
   3.344 -    TEST_ASSERT_MSG((alex->username), "alex->username");
   3.345 -    TEST_ASSERT_MSG((strcmp(alex->username, new_username) == 0), "strcmp(alex->username, new_username) == 0");
   3.346 -    TEST_ASSERT_MSG((alex->user_id), "alex->user_id");
   3.347 -    TEST_ASSERT_MSG((strcmp(alex->user_id, alex_userid) == 0), "strcmp(alex->user_id, alex_userid) == 0");
   3.348 -    TEST_ASSERT_MSG((!alex->me), "!alex->me"); 
   3.349 -    TEST_ASSERT_MSG((alex->comm_type == PEP_ct_OpenPGP_unconfirmed), "alex->comm_type == PEP_ct_OpenPGP_unconfirmed");
   3.350 -    TEST_ASSERT_MSG((strcmp(alex->address, alex_address) == 0), "strcmp(alex->address, alex_address) == 0");
   3.351 -
   3.352 -    cout << "PASS: update_identity() correctly retrieved extant record with matching address and id, and patched username" << endl << endl;
   3.353 -    free_identity(alex);
   3.354 -
   3.355 -    cout << "****************************************************************************************" << endl;
   3.356 -    cout << "* II: 4. update_identity() - get identity with just address and username" << endl;
   3.357 -    cout << "****************************************************************************************" << endl << endl;    
   3.358 -
   3.359 -    alex = new_identity(alex_address, NULL, NULL, new_username); 
   3.360 -    status = update_identity(session, alex);
   3.361 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.362 +void NewUpdateIdAndMyselfTests::update_identity_use_address_username_only() {
   3.363 +    pEp_identity* alex = new_identity(alex_address, NULL, NULL, new_username); 
   3.364 +    PEP_STATUS status = update_identity(session, alex);
   3.365 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.366      TEST_ASSERT_MSG((alex->fpr), "alex->fpr");
   3.367      TEST_ASSERT_MSG((strcmp(alex->fpr, alex_fpr) == 0), "strcmp(alex->fpr, alex_fpr) == 0");
   3.368      TEST_ASSERT_MSG((alex->username), "alex->username");
   3.369 @@ -283,14 +327,12 @@
   3.370  
   3.371      cout << "PASS: update_identity() correctly retrieved extant record with matching address and username" << endl << endl;
   3.372      free_identity(alex);
   3.373 +}
   3.374  
   3.375 -    cout << "****************************************************************************************" << endl;
   3.376 -    cout << "* II: 5. update_identity() with just address " << endl;
   3.377 -    cout << "****************************************************************************************" << endl << endl;
   3.378 -    
   3.379 -    alex = new_identity(alex_address, NULL, NULL, NULL); 
   3.380 -    status = update_identity(session, alex);
   3.381 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.382 +void NewUpdateIdAndMyselfTests::update_identity_use_address_only() {
   3.383 +    pEp_identity* alex = new_identity(alex_address, NULL, NULL, NULL); 
   3.384 +    PEP_STATUS status = update_identity(session, alex);
   3.385 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.386      TEST_ASSERT_MSG((alex->fpr), "alex->fpr");
   3.387      TEST_ASSERT_MSG((strcmp(alex->fpr, alex_fpr) == 0), "strcmp(alex->fpr, alex_fpr) == 0");
   3.388      TEST_ASSERT_MSG((alex->username), "alex->username");
   3.389 @@ -303,15 +345,12 @@
   3.390  
   3.391      cout << "PASS: update_identity() correctly retrieved extant record with just matching address. Retrieved previously patched username." << endl << endl;
   3.392      free_identity(alex);
   3.393 +}
   3.394  
   3.395 -
   3.396 -    cout << "****************************************************************************************" << endl;
   3.397 -    cout << "* II: 6. update_identity() with just address on own identity (only case where this is legal)" << endl;
   3.398 -    cout << "****************************************************************************************" << endl << endl;
   3.399 -    
   3.400 +void NewUpdateIdAndMyselfTests::update_identity_use_address_only_on_own_ident() {
   3.401      pEp_identity* somebody = new_identity(uniqname, NULL, NULL, NULL); 
   3.402 -    status = update_identity(session, somebody);
   3.403 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.404 +    PEP_STATUS status = update_identity(session, somebody);
   3.405 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.406      myself(session, somebody);
   3.407      TEST_ASSERT_MSG((somebody->fpr), "somebody->fpr");
   3.408      TEST_ASSERT_MSG((strcmp(somebody->fpr, new_fpr) == 0), "strcmp(somebody->fpr, new_fpr) == 0");
   3.409 @@ -327,71 +366,28 @@
   3.410      cout << endl << endl;
   3.411  
   3.412      free_identity(somebody);
   3.413 +}
   3.414  
   3.415 -    cout << "****************************************************************************************" << endl;
   3.416 -    cout << "* II: 7. update_identity() for address and user_id that don't exist" << endl;
   3.417 -    cout << "****************************************************************************************" << endl << endl;
   3.418 -
   3.419 -    somebody = new_identity("nope@nope.nope", NULL, "some_user_id", NULL); 
   3.420 -    status = update_identity(session, somebody);
   3.421 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.422 +void NewUpdateIdAndMyselfTests::update_identity_non_existent_user_id_address() {
   3.423 +    pEp_identity* somebody = new_identity("nope@nope.nope", NULL, "some_user_id", NULL); 
   3.424 +    PEP_STATUS status = update_identity(session, somebody);
   3.425 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.426      TEST_ASSERT_MSG((!somebody->fpr), "!somebody->fpr");
   3.427      TEST_ASSERT_MSG((somebody->comm_type == PEP_ct_key_not_found), "somebody->comm_type == PEP_ct_key_not_found");
   3.428      
   3.429      cout << "PASS: update_identity() returns identity with no key and unknown comm type" << endl << endl;
   3.430  
   3.431      free_identity(somebody);
   3.432 -    
   3.433 -    cout << "****************************************************************************************" << endl;
   3.434 -    cout << "* II: 8. update_identity() for address and and username, but non-matching temp user_id" << endl;
   3.435 -    cout << "****************************************************************************************" << endl << endl;
   3.436 +}
   3.437  
   3.438 -    // 1. create identity
   3.439 -    const char* bella_address = "pep.test.bella@peptest.ch";
   3.440 -    const char* bella_fpr = "5631BF1357326A02AA470EEEB815EF7FA4516AAE";
   3.441 -    const char* bella_userid = "TOFU_pep.test.bella@peptest.ch"; // simulate temp ID
   3.442 -    const char* bella_username = "Annabella the Great";
   3.443 -    const string bella_pub_key = slurp("test_keys/pub/pep.test.bella-0xAF516AAE_pub.asc");
   3.444 -    
   3.445 -    statuspub = import_key(session, bella_pub_key.c_str(), bella_pub_key.length(), NULL);
   3.446 -    TEST_ASSERT_MSG((statuspub == PEP_TEST_KEY_IMPORT_SUCCESS), "statuspub == PEP_STATUS_OK");
   3.447 -
   3.448 -    pEp_identity* bella = new_identity(bella_address, bella_fpr, bella_userid, bella_username);
   3.449 -    
   3.450 -    // 2. set identity
   3.451 -    status = set_identity(session, bella);
   3.452 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.453 -    free_identity(bella);
   3.454 -    
   3.455 -    const char* not_my_userid = "Bad Company";
   3.456 -            
   3.457 -    bella = new_identity(bella_address, NULL, not_my_userid, bella_username); 
   3.458 -    status = update_identity(session, bella);
   3.459 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.460 -    TEST_ASSERT_MSG((bella->fpr), "bella->fpr");
   3.461 -    TEST_ASSERT_MSG((strcmp(bella->fpr, bella_fpr) == 0), "strcmp(bella->fpr, bella_fpr) == 0");
   3.462 -    TEST_ASSERT_MSG((bella->username), "bella->username");
   3.463 -    TEST_ASSERT_MSG((strcmp(bella->username, bella_username) == 0), "strcmp(bella->username, bella_username) == 0");
   3.464 -    TEST_ASSERT_MSG((bella->user_id), "bella->user_id");
   3.465 -    TEST_ASSERT_MSG((strcmp(bella->user_id, not_my_userid) == 0), "strcmp(bella->user_id, not_my_userid) == 0"); // ???
   3.466 -    TEST_ASSERT_MSG((!bella->me), "!bella->me"); 
   3.467 -    TEST_ASSERT_MSG((bella->comm_type == PEP_ct_OpenPGP_unconfirmed), "bella->comm_type == PEP_ct_OpenPGP_unconfirmed");
   3.468 -    TEST_ASSERT_MSG((strcmp(bella->address, bella_address) == 0), "strcmp(bella->address, bella_address) == 0");
   3.469 -
   3.470 -    cout << "PASS: update_identity() correctly retrieved extant record with matching address and username; temp user_id in DB patched" << endl << endl;
   3.471 -    free_identity(bella);
   3.472 -
   3.473 -    cout << "****************************************************************************************" << endl;
   3.474 -    cout << "* II: 9. update_identity() for address, username, and user_id, but no matching record" << endl;
   3.475 -    cout << "****************************************************************************************" << endl << endl;
   3.476 -    
   3.477 +void NewUpdateIdAndMyselfTests::update_identity_address_username_userid_no_record() {
   3.478      const char* rando_name = "Pickley BoofBoof";
   3.479      const char* rando_userid = "Boofy";
   3.480      const char* rando_address = "boof@pickles.org";
   3.481 -    somebody = new_identity(rando_address, NULL, rando_userid, rando_name);
   3.482 -    status = update_identity(session, somebody);
   3.483 +    pEp_identity* somebody = new_identity(rando_address, NULL, rando_userid, rando_name);
   3.484 +    PEP_STATUS status = update_identity(session, somebody);
   3.485  
   3.486 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.487 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.488      TEST_ASSERT_MSG((!somebody->fpr || somebody->fpr[0] == '\0'), "!somebody->fpr || somebody->fpr[0] == '\0'");
   3.489      TEST_ASSERT_MSG((somebody->username), "somebody->username");
   3.490      TEST_ASSERT_MSG((strcmp(somebody->username, rando_name) == 0), "strcmp(somebody->username, rando_name) == 0");
   3.491 @@ -403,18 +399,16 @@
   3.492  
   3.493      cout << "PASS: update_identity() correctly created record with no key" << endl << endl;
   3.494      free_identity(somebody);
   3.495 -    
   3.496 -    cout << "****************************************************************************************" << endl;
   3.497 -    cout << "* II: 10. update_identity() for address, username, but no matching record" << endl;
   3.498 -    cout << "****************************************************************************************" << endl << endl;
   3.499 +}
   3.500  
   3.501 +void NewUpdateIdAndMyselfTests::update_identity_address_username_no_record() {
   3.502      const char* rando2_name = "Pickles BoofyBoof";
   3.503      const char* rando2_address = "boof2@pickles.org";
   3.504 -    somebody = new_identity(rando2_address, NULL, NULL, rando2_name);
   3.505 -    status = update_identity(session, somebody);
   3.506 +    pEp_identity* somebody = new_identity(rando2_address, NULL, NULL, rando2_name);
   3.507 +    PEP_STATUS status = update_identity(session, somebody);
   3.508      const char* expected_rando2_userid = "TOFU_boof2@pickles.org";
   3.509  
   3.510 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.511 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.512      TEST_ASSERT_MSG((!somebody->fpr || somebody->fpr[0] == '\0'), "!somebody->fpr || somebody->fpr[0] == '\0'");
   3.513      TEST_ASSERT_MSG((somebody->username), "somebody->username");
   3.514      TEST_ASSERT_MSG((strcmp(somebody->username, rando2_name) == 0), "strcmp(somebody->username, rando2_name) == 0");
   3.515 @@ -426,33 +420,60 @@
   3.516  
   3.517      cout << "PASS: update_identity() correctly created record with no key" << endl << endl;
   3.518      free_identity(somebody);
   3.519 +}
   3.520  
   3.521 -    cout << "****************************************************************************************" << endl;
   3.522 -    cout << "* II: 11. update_identity() for address only, but multiple matching records" << endl;
   3.523 -    cout << "****************************************************************************************" << endl << endl;
   3.524  
   3.525 +void NewUpdateIdAndMyselfTests::update_identity_address_only_multiple_records() {
   3.526 +    PEP_STATUS status = PEP_STATUS_OK;
   3.527 +    // 1. create identity
   3.528 +    const char* bella_address = "pep.test.bella@peptest.ch";
   3.529 +    const char* bella_fpr = "5631BF1357326A02AA470EEEB815EF7FA4516AAE";
   3.530 +    const char* bella_userid = "TOFU_pep.test.bella@peptest.ch"; // simulate temp ID
   3.531 +    const char* bella_username = "Annabella the Great";
   3.532 +    const string bella_pub_key = slurp("test_keys/pub/pep.test.bella-0xAF516AAE_pub.asc");
   3.533 +    
   3.534 +    PEP_STATUS statuspub = import_key(session, bella_pub_key.c_str(), bella_pub_key.length(), NULL);
   3.535 +    TEST_ASSERT_MSG((statuspub == PEP_TEST_KEY_IMPORT_SUCCESS), "statuspub == PEP_STATUS_OK");
   3.536 +
   3.537 +    pEp_identity* bella = new_identity(bella_address, bella_fpr, bella_userid, bella_username);
   3.538 +    
   3.539 +    // 2. set identity
   3.540 +    status = set_identity(session, bella);
   3.541 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.542 +    free_identity(bella);
   3.543 +    
   3.544 +    const char* not_my_userid = "Bad Company";
   3.545 +            
   3.546 +    bella = new_identity(bella_address, NULL, not_my_userid, bella_username); 
   3.547 +    status = update_identity(session, bella);
   3.548 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.549 +    TEST_ASSERT_MSG((bella->fpr), "bella->fpr");
   3.550 +    TEST_ASSERT_MSG((strcmp(bella->fpr, bella_fpr) == 0), "strcmp(bella->fpr, bella_fpr) == 0");
   3.551 +    TEST_ASSERT_MSG((bella->username), "bella->username");
   3.552 +    TEST_ASSERT_MSG((strcmp(bella->username, bella_username) == 0), "strcmp(bella->username, bella_username) == 0");
   3.553 +    TEST_ASSERT_MSG((bella->user_id), "bella->user_id");
   3.554 +    TEST_ASSERT_MSG((strcmp(bella->user_id, not_my_userid) == 0), "strcmp(bella->user_id, not_my_userid) == 0"); // ???
   3.555 +    TEST_ASSERT_MSG((!bella->me), "!bella->me"); 
   3.556 +    TEST_ASSERT_MSG((bella->comm_type == PEP_ct_OpenPGP_unconfirmed), "bella->comm_type == PEP_ct_OpenPGP_unconfirmed");
   3.557 +    TEST_ASSERT_MSG((strcmp(bella->address, bella_address) == 0), "strcmp(bella->address, bella_address) == 0");
   3.558 +
   3.559 +    free_identity(bella);
   3.560 +    
   3.561 +    // ???? 
   3.562      const char* bella_id_2 = "Bella2";
   3.563      bella = new_identity(bella_address, NULL, bella_id_2, bella_username);
   3.564      
   3.565 -    // 2. set identity
   3.566      status = set_identity(session, bella);
   3.567 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.568 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.569      free_identity(bella);
   3.570                  
   3.571      bella = new_identity(bella_address, NULL, NULL, NULL); 
   3.572      status = update_identity(session, bella);
   3.573 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.574 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.575  
   3.576 -//    cout << "PASS: update_identity() correctly failed with no matching records (too little info)" << endl << endl;
   3.577 -    
   3.578 -    cout << "****************************************************************************************" << endl;
   3.579 -    cout << "* III: key election " << endl;
   3.580 -    cout << "****************************************************************************************" << endl << endl;
   3.581 +}
   3.582  
   3.583 -    cout << "****************************************************************************************" << endl;
   3.584 -    cout << "* III: 1. key election: get identity for user with expired key" << endl;
   3.585 -    cout << "****************************************************************************************" << endl << endl;
   3.586 -
   3.587 +void NewUpdateIdAndMyselfTests::key_elect_expired_key() {
   3.588      // 1. create identity
   3.589      const char* bernd_address = "bernd.das.brot@darthmama.org";
   3.590      const char* bernd_fpr = "F8CE0F7E24EB190A2FCBFD38D4B088A7CAFAA422";
   3.591 @@ -460,14 +481,14 @@
   3.592      const char* bernd_username = "Bernd das Brot der Ultimative Testkandidat";
   3.593      const string bernd_pub_key = slurp("test_keys/pub/bernd.das.brot-0xCAFAA422_pub.asc");
   3.594      
   3.595 -    statuspub = import_key(session, bernd_pub_key.c_str(), bernd_pub_key.length(), NULL);
   3.596 +    PEP_STATUS statuspub = import_key(session, bernd_pub_key.c_str(), bernd_pub_key.length(), NULL);
   3.597      TEST_ASSERT_MSG((statuspub == PEP_TEST_KEY_IMPORT_SUCCESS), "statuspub == PEP_STATUS_OK");
   3.598  
   3.599      pEp_identity* bernd = new_identity(bernd_address, bernd_fpr, bernd_userid, bernd_username);
   3.600      
   3.601      // 2. set identity
   3.602 -    status = set_identity(session, bernd);
   3.603 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.604 +    PEP_STATUS status = set_identity(session, bernd);
   3.605 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.606      free_identity(bernd);
   3.607                  
   3.608      bernd = new_identity(bernd_address, NULL, bernd_userid, bernd_username); 
   3.609 @@ -484,12 +505,10 @@
   3.610  
   3.611      cout << "PASS: update_identity() correctly rejected expired key with PEP_KEY_UNSUITABLE and PEP_ct_key_expired" << endl << endl;
   3.612      free_identity(bernd);
   3.613 +    
   3.614 +}
   3.615  
   3.616 -
   3.617 -    cout << "****************************************************************************************" << endl;
   3.618 -    cout << "* III: 2. key election: get identity for user with only revoked or mistrusted keys " << endl;
   3.619 -    cout << "****************************************************************************************" << endl << endl;
   3.620 -
   3.621 +void NewUpdateIdAndMyselfTests::key_elect_only_revoked_mistrusted() {
   3.622      // Create id with no key
   3.623      cout << "Creating new id with no key for : ";
   3.624      char *uniqname_10000 = strdup("AAAAtestuser@testdomain.org");
   3.625 @@ -507,20 +526,20 @@
   3.626  
   3.627      char* revoke_fpr_arr[3];
   3.628      
   3.629 -    status = generate_keypair(session, revokemaster_3000);
   3.630 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK && revokemaster_3000->fpr), "status == PEP_STATUS_OK && revokemaster_3000->fpr");
   3.631 +    PEP_STATUS status = generate_keypair(session, revokemaster_3000);
   3.632 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK && revokemaster_3000->fpr), (string(tl_status_string(status)) + " " + revokemaster_3000->fpr).c_str());
   3.633      revoke_fpr_arr[0] = strdup(revokemaster_3000->fpr);
   3.634      free(revokemaster_3000->fpr);
   3.635      revokemaster_3000->fpr = NULL;
   3.636      
   3.637      status = generate_keypair(session, revokemaster_3000);
   3.638 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK && revokemaster_3000->fpr), "status == PEP_STATUS_OK && revokemaster_3000->fpr");
   3.639 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK && revokemaster_3000->fpr), (string(tl_status_string(status)) + " " + revokemaster_3000->fpr).c_str());
   3.640      revoke_fpr_arr[1] = strdup(revokemaster_3000->fpr);
   3.641      free(revokemaster_3000->fpr);
   3.642      revokemaster_3000->fpr = NULL;
   3.643      
   3.644      status = generate_keypair(session, revokemaster_3000);
   3.645 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK && revokemaster_3000->fpr), "status == PEP_STATUS_OK && revokemaster_3000->fpr");
   3.646 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK && revokemaster_3000->fpr), (string(tl_status_string(status)) + " " + revokemaster_3000->fpr).c_str());
   3.647      revoke_fpr_arr[2] = strdup(revokemaster_3000->fpr);
   3.648      free(revokemaster_3000->fpr);
   3.649      revokemaster_3000->fpr = NULL;
   3.650 @@ -530,24 +549,24 @@
   3.651      free(revokemaster_3000->fpr);
   3.652      revokemaster_3000->fpr = strdup(revoke_fpr_arr[2]);
   3.653      status = trust_personal_key(session, revokemaster_3000);
   3.654 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.655 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.656      status = get_trust(session, revokemaster_3000);
   3.657 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.658 -    TEST_ASSERT_MSG((revokemaster_3000->comm_type & PEP_ct_confirmed), "revokemaster_3000->comm_type & PEP_ct_confirmed");
   3.659 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.660 +    TEST_ASSERT_MSG((revokemaster_3000->comm_type & PEP_ct_confirmed), tl_ct_string(revokemaster_3000->comm_type));
   3.661  
   3.662      free(revokemaster_3000->fpr);
   3.663      revokemaster_3000->fpr = strdup(revoke_fpr_arr[0]);
   3.664      status = trust_personal_key(session, revokemaster_3000);
   3.665 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.666 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.667      status = get_trust(session, revokemaster_3000);
   3.668 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.669 -    TEST_ASSERT_MSG((revokemaster_3000->comm_type & PEP_ct_confirmed), "revokemaster_3000->comm_type & PEP_ct_confirmed");
   3.670 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.671 +    TEST_ASSERT_MSG((revokemaster_3000->comm_type & PEP_ct_confirmed), tl_ct_string(revokemaster_3000->comm_type));
   3.672      
   3.673      status = update_identity(session, revokemaster_3000);
   3.674 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.675 -    TEST_ASSERT_MSG((revokemaster_3000->fpr), "revokemaster_3000->fpr");
   3.676 -    TEST_ASSERT_MSG((strcmp(revokemaster_3000->fpr, revoke_fpr_arr[2]) == 0), "strcmp(revokemaster_3000->fpr, revoke_fpr_arr[2]) == 0");
   3.677 -    TEST_ASSERT_MSG((revokemaster_3000->comm_type & PEP_ct_confirmed), "revokemaster_3000->comm_type & PEP_ct_confirmed");
   3.678 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.679 +    TEST_ASSERT_MSG((revokemaster_3000->fpr), revokemaster_3000->fpr);
   3.680 +    TEST_ASSERT_MSG((strcmp(revokemaster_3000->fpr, revoke_fpr_arr[2]) == 0), (string("Expected ") + revoke_fpr_arr[2] + ", Got " + revokemaster_3000->fpr).c_str());
   3.681 +    TEST_ASSERT_MSG((revokemaster_3000->comm_type & PEP_ct_confirmed), tl_ct_string(revokemaster_3000->comm_type));
   3.682  
   3.683      cout << "update_identity returns the correct identity default." << endl;
   3.684      
   3.685 @@ -560,36 +579,36 @@
   3.686  
   3.687      bool is_revoked;
   3.688      status = key_revoked(session, revokemaster_3000->fpr, &is_revoked);    
   3.689 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.690 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.691      TEST_ASSERT_MSG((is_revoked), "is_revoked");
   3.692  
   3.693      cout << "Success revoking " << revoke_fpr_arr[2] << "!!! get_trust for this fpr gives us " << revokemaster_3000->comm_type << endl;
   3.694      
   3.695      cout << "Now see if update_identity gives us " << revoke_fpr_arr[0] << ", the only trusted key left." << endl;
   3.696      status = update_identity(session, revokemaster_3000);
   3.697 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.698 -    TEST_ASSERT_MSG((revokemaster_3000->fpr), "revokemaster_3000->fpr");
   3.699 -    TEST_ASSERT_MSG((strcmp(revokemaster_3000->fpr, revoke_fpr_arr[0]) == 0), "strcmp(revokemaster_3000->fpr, revoke_fpr_arr[0]) == 0");
   3.700 -    TEST_ASSERT_MSG((revokemaster_3000->comm_type & PEP_ct_confirmed), "revokemaster_3000->comm_type & PEP_ct_confirmed");    
   3.701 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.702 +    TEST_ASSERT_MSG((revokemaster_3000->fpr), revokemaster_3000->fpr);
   3.703 +    TEST_ASSERT_MSG((strcmp(revokemaster_3000->fpr, revoke_fpr_arr[0]) == 0), (string("Expected ") + revoke_fpr_arr[0] + ", Got " + revokemaster_3000->fpr).c_str());
   3.704 +    TEST_ASSERT_MSG((revokemaster_3000->comm_type & PEP_ct_confirmed), tl_ct_string(revokemaster_3000->comm_type));    
   3.705      
   3.706      cout << "Success! So let's mistrust it, because seriously, that key was so uncool." << endl;
   3.707      
   3.708      status = key_mistrusted(session, revokemaster_3000);
   3.709 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.710 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.711  
   3.712      status = get_trust(session, revokemaster_3000);
   3.713 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.714 -    TEST_ASSERT_MSG((revokemaster_3000->comm_type == PEP_ct_mistrusted), "revokemaster_3000->comm_type == PEP_ct_mistrusted");
   3.715 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.716 +    TEST_ASSERT_MSG((revokemaster_3000->comm_type == PEP_ct_mistrusted), tl_ct_string(revokemaster_3000->comm_type));
   3.717      
   3.718      cout << "Success! get_trust for this fpr gives us " << revokemaster_3000->comm_type << endl;
   3.719  
   3.720      cout << "The only fpr left is an untrusted one - let's make sure this is what we get from update_identity." << endl;
   3.721  
   3.722      status = update_identity(session, revokemaster_3000);
   3.723 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.724 -    TEST_ASSERT_MSG((revokemaster_3000->fpr), "revokemaster_3000->fpr");
   3.725 -    TEST_ASSERT_MSG((strcmp(revokemaster_3000->fpr, revoke_fpr_arr[1]) == 0), "strcmp(revokemaster_3000->fpr, revoke_fpr_arr[1]) == 0");
   3.726 -    TEST_ASSERT_MSG((!(revokemaster_3000->comm_type & PEP_ct_confirmed)), "!(revokemaster_3000->comm_type & PEP_ct_confirmed)");    
   3.727 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.728 +    TEST_ASSERT_MSG((revokemaster_3000->fpr), revokemaster_3000->fpr);
   3.729 +    TEST_ASSERT_MSG((strcmp(revokemaster_3000->fpr, revoke_fpr_arr[1]) == 0), (string("Expected ") + revoke_fpr_arr[1] + ", Got " + revokemaster_3000->fpr).c_str());
   3.730 +    TEST_ASSERT_MSG((!(revokemaster_3000->comm_type & PEP_ct_confirmed)), tl_ct_string(revokemaster_3000->comm_type));    
   3.731  
   3.732      cout << "Success! We got " << revoke_fpr_arr[1] << "as the fpr with comm_type " << revokemaster_3000->comm_type << endl;
   3.733      
   3.734 @@ -599,7 +618,7 @@
   3.735      TEST_ASSERT (status == PEP_STATUS_OK);
   3.736  
   3.737      status = key_revoked(session, revokemaster_3000->fpr, &is_revoked);    
   3.738 -    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   3.739 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
   3.740      TEST_ASSERT_MSG((is_revoked), "is_revoked");
   3.741      
   3.742      cout << "Success! get_trust for this fpr gives us " << revokemaster_3000->comm_type << endl;
   3.743 @@ -607,17 +626,12 @@
   3.744      cout << "Call update_identity - we expect nothing, plus an error comm type." << endl;
   3.745  
   3.746      status = update_identity(session, revokemaster_3000);
   3.747 -    TEST_ASSERT_MSG((status != PEP_STATUS_OK), "status != PEP_STATUS_OK");
   3.748 -    TEST_ASSERT_MSG((!revokemaster_3000->fpr), "!revokemaster_3000->fpr");
   3.749 -    TEST_ASSERT_MSG((revokemaster_3000->username), "revokemaster_3000->username");
   3.750 -    TEST_ASSERT_MSG((strcmp(revokemaster_3000->user_id, revoke_uuid) == 0), "strcmp(revokemaster_3000->user_id, revoke_uuid) == 0");
   3.751 -    TEST_ASSERT_MSG((revokemaster_3000->comm_type == PEP_ct_key_not_found), "revokemaster_3000->comm_type == PEP_ct_key_not_found");
   3.752 +    TEST_ASSERT_MSG((status != PEP_STATUS_OK), tl_status_string(status));
   3.753 +    TEST_ASSERT_MSG((!revokemaster_3000->fpr), revokemaster_3000->fpr);
   3.754 +    TEST_ASSERT_MSG((revokemaster_3000->username), "No revokemaster_3000->username");
   3.755 +    TEST_ASSERT_MSG((strcmp(revokemaster_3000->user_id, revoke_uuid) == 0), (string("Expected ") + revoke_uuid + ", Got " + revokemaster_3000->user_id).c_str());
   3.756 +    TEST_ASSERT_MSG((revokemaster_3000->comm_type == PEP_ct_key_not_found), tl_ct_string(revokemaster_3000->comm_type));
   3.757      cout << "Success! No key found. The comm_status error was " << revokemaster_3000->comm_type << "and the return status was " << tl_status_string(status) << endl;
   3.758  
   3.759 -    free_identity(revokemaster_3000);
   3.760 -
   3.761 -    cout << "****************************************************************************************" << endl;
   3.762 -    cout << "* III: 100000000. key election: more to come " << endl;
   3.763 -    cout << "****************************************************************************************" << endl << endl;
   3.764 -
   3.765 +    free_identity(revokemaster_3000);    
   3.766  }