rest of the tests sync
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Tue, 30 Apr 2019 18:04:39 +0200
branchsync
changeset 35890627024f0184
parent 3588 e00a6dfd1fc2
child 3590 69969ad8d4af
child 3596 37f68fb62406
rest of the tests
test/src/engine_tests/OwnKeysRetrieveTests.cc
     1.1 --- a/test/src/engine_tests/OwnKeysRetrieveTests.cc	Tue Apr 30 17:53:12 2019 +0200
     1.2 +++ b/test/src/engine_tests/OwnKeysRetrieveTests.cc	Tue Apr 30 18:04:39 2019 +0200
     1.3 @@ -439,12 +439,9 @@
     1.4      free_identity(a_pub);
     1.5      a_pub = NULL;
     1.6  
     1.7 -
     1.8 -    // Own pub key
     1.9      TEST_ASSERT_MSG(slurp_and_import_key(session, "test_keys/pub/pep.test.alexander5-0x0773CD29_pub.asc"),
    1.10                      "Unable to import test_keys/pub/pep.test.alexander5-0x0773CD29_pub.asc");
    1.11      
    1.12 -    // Make it an own identity in the DB
    1.13      a_pub = new_identity("pep.test.alexander0@darthmama.org", "58BCC2BF2AE1E3C4FBEAB89AD7838ACA0773CD29", "NotMe", NULL);
    1.14      a_pub->comm_type = PEP_ct_pEp;
    1.15      status = set_trust(session, a_pub);
    1.16 @@ -452,11 +449,9 @@
    1.17      free_identity(a_pub);
    1.18      a_pub = NULL;
    1.19  
    1.20 -    // Own pub key
    1.21      TEST_ASSERT_MSG(slurp_and_import_key(session, "test_keys/pub/pep.test.alexander6-0x0019697D_pub.asc"),
    1.22                      "Unable to import test_keys/pub/pep.test.alexander6-0x0019697D_pub.asc");
    1.23      
    1.24 -    // Make it an own identity in the DB
    1.25      a_pub = new_identity("pep.test.alexander0@darthmama.org", "74D79B4496E289BD8A71B70BA8E2C4530019697D", "NotMe", NULL);
    1.26      a_pub->comm_type = PEP_ct_pEp;
    1.27      status = set_trust(session, a_pub);
    1.28 @@ -464,11 +459,9 @@
    1.29      free_identity(a_pub);
    1.30      a_pub = NULL;
    1.31  
    1.32 -    // Own pub key
    1.33      TEST_ASSERT_MSG(slurp_and_import_key(session, "test_keys/pub/pep.test.alexander6-0x503B14D8_pub.asc"),
    1.34                      "Unable to import test_keys/pub/pep.test.alexander6-0x503B14D8_pub.asc");
    1.35      
    1.36 -    // Make it an own identity in the DB
    1.37      a_pub = new_identity("pep.test.alexander0@darthmama.org", "2E21325D202A44BFD9C607FCF095B202503B14D8", "NotMe", NULL);
    1.38      a_pub->comm_type = PEP_ct_pEp;
    1.39      status = set_trust(session, a_pub);
    1.40 @@ -476,11 +469,9 @@
    1.41      free_identity(a_pub);
    1.42      a_pub = NULL;
    1.43  
    1.44 -    // Own pub key
    1.45      TEST_ASSERT_MSG(slurp_and_import_key(session, "test_keys/pub/pep.test.alexander6-0xA216E95A_pub.asc"),
    1.46                      "Unable to import test_keys/pub/pep.test.alexander6-0xA216E95A_pub.asc");
    1.47      
    1.48 -    // Make it an own identity in the DB
    1.49      a_pub = new_identity("pep.test.alexander0@darthmama.org", "3C1E713D8519D7F907E3142D179EAA24A216E95A", "NotMe", NULL);
    1.50      a_pub->comm_type = PEP_ct_pEp;
    1.51      status = set_trust(session, a_pub);
    1.52 @@ -499,9 +490,150 @@
    1.53  }
    1.54  
    1.55  void OwnKeysRetrieveTests::check_own_keys_retrieve_multi_idents_one_key() {
    1.56 -    TEST_ASSERT(true);
    1.57 +    // Setup own identity
    1.58 +    PEP_STATUS status = read_file_and_import_key(session,
    1.59 +                "test_keys/pub/pep.test.alexander0-0x3B7302DB_pub.asc");
    1.60 +    TEST_ASSERT(status == PEP_KEY_IMPORTED);
    1.61 +    status = set_up_ident_from_scratch(session,
    1.62 +                "test_keys/priv/pep.test.alexander0-0x3B7302DB_priv.asc",
    1.63 +                "pep.test.xander@pep-project.org", "F4598A17D4690EB3B5B0F6A344F04E963B7302DB", 
    1.64 +                PEP_OWN_USERID, "Xander in Wonderland", NULL, true
    1.65 +            );
    1.66 +    TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
    1.67 +
    1.68 +    // Setup own identity
    1.69 +    status = read_file_and_import_key(session,
    1.70 +                "test_keys/pub/pep.test.alexander0-0x3B7302DB_pub.asc");
    1.71 +    TEST_ASSERT(status == PEP_KEY_IMPORTED);
    1.72 +    status = set_up_ident_from_scratch(session,
    1.73 +                "test_keys/priv/pep.test.alexander0-0x3B7302DB_priv.asc",
    1.74 +                "pep.test.xander1@pep-project.org", "F4598A17D4690EB3B5B0F6A344F04E963B7302DB", 
    1.75 +                PEP_OWN_USERID, "Xander in Wonderland", NULL, true
    1.76 +            );
    1.77 +    TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
    1.78 +
    1.79 +    // Setup own identity
    1.80 +    status = read_file_and_import_key(session,
    1.81 +                "test_keys/pub/pep.test.alexander0-0x3B7302DB_pub.asc");
    1.82 +    TEST_ASSERT(status == PEP_KEY_IMPORTED);
    1.83 +    status = set_up_ident_from_scratch(session,
    1.84 +                "test_keys/priv/pep.test.alexander0-0x3B7302DB_priv.asc",
    1.85 +                "pep.test.xander2@pep-project.org", "F4598A17D4690EB3B5B0F6A344F04E963B7302DB", 
    1.86 +                PEP_OWN_USERID, "Xander in Wonderland", NULL, true
    1.87 +            );
    1.88 +    TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
    1.89 +
    1.90 +    // Ok, see if we get one back.
    1.91 +    stringlist_t* keylist = NULL;
    1.92 +    
    1.93 +    status = _own_keys_retrieve(session, &keylist, 0, true);
    1.94 +    TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
    1.95 +    TEST_ASSERT(keylist);
    1.96 +    TEST_ASSERT(keylist->value);
    1.97 +    TEST_ASSERT(!keylist->next);
    1.98 +
    1.99 +    TEST_ASSERT(strcmp(keylist->value, "F4598A17D4690EB3B5B0F6A344F04E963B7302DB") == 0);
   1.100 +
   1.101  }
   1.102  
   1.103  void OwnKeysRetrieveTests::check_own_keys_retrieve_multi_idents_one_priv_key_multi_pub() {
   1.104 -    TEST_ASSERT(true);
   1.105 +    PEP_STATUS status = set_up_ident_from_scratch(session,
   1.106 +                "test_keys/pub/pep.test.alexander5-0x0773CD29_pub.asc",
   1.107 +                "pep.test.alexander5@darthmama.org", "58BCC2BF2AE1E3C4FBEAB89AD7838ACA0773CD29", 
   1.108 +                PEP_OWN_USERID, "Xander in Wonderland", NULL, false
   1.109 +            );
   1.110 +    TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
   1.111 +    // Make it an own identity in the DB
   1.112 +    pEp_identity* me_pub = new_identity("pep.test.alexander5@darthmama.org", NULL, PEP_OWN_USERID, NULL);
   1.113 +    status = update_identity(session, me_pub);
   1.114 +    TEST_ASSERT(status == PEP_STATUS_OK);
   1.115 +    TEST_ASSERT(strcmp(me_pub->fpr, "58BCC2BF2AE1E3C4FBEAB89AD7838ACA0773CD29") == 0);
   1.116 +    status = trust_personal_key(session, me_pub);
   1.117 +    TEST_ASSERT(status == PEP_STATUS_OK);
   1.118 +    
   1.119 +    me_pub->me = true;
   1.120 +    status = set_identity(session, me_pub);
   1.121 +    free_identity(me_pub);
   1.122 +    me_pub = NULL;
   1.123 +    TEST_ASSERT(status == PEP_STATUS_OK);
   1.124 +    
   1.125 +    // Own pub key
   1.126 +    TEST_ASSERT_MSG(slurp_and_import_key(session, "test_keys/pub/pep.test.alexander6-0x0019697D_pub.asc"),
   1.127 +                    "Unable to import test_keys/pub/pep.test.alexander6-0x0019697D_pub.asc");
   1.128 +    
   1.129 +    // Make it an own identity in the DB
   1.130 +    me_pub = new_identity("pep.test.alexander5@darthmama.org", "74D79B4496E289BD8A71B70BA8E2C4530019697D", PEP_OWN_USERID, NULL);
   1.131 +    me_pub->comm_type = PEP_ct_pEp;
   1.132 +    status = set_trust(session, me_pub);
   1.133 +    TEST_ASSERT(status == PEP_STATUS_OK);    
   1.134 +    free_identity(me_pub);
   1.135 +    me_pub = NULL;
   1.136 +
   1.137 +    // Own pub key
   1.138 +    TEST_ASSERT_MSG(slurp_and_import_key(session, "test_keys/pub/pep.test.alexander6-0x503B14D8_pub.asc"),
   1.139 +                    "Unable to import test_keys/pub/pep.test.alexander6-0x503B14D8_pub.asc");
   1.140 +    
   1.141 +    // Make it an own identity in the DB
   1.142 +    me_pub = new_identity("pep.test.alexander5@darthmama.org", "2E21325D202A44BFD9C607FCF095B202503B14D8", PEP_OWN_USERID, NULL);
   1.143 +    me_pub->comm_type = PEP_ct_pEp;
   1.144 +    status = set_trust(session, me_pub);
   1.145 +    TEST_ASSERT(status == PEP_STATUS_OK);    
   1.146 +    free_identity(me_pub);
   1.147 +    me_pub = NULL;
   1.148 +
   1.149 +    // Own pub key
   1.150 +    TEST_ASSERT_MSG(slurp_and_import_key(session, "test_keys/pub/pep.test.alexander6-0xA216E95A_pub.asc"),
   1.151 +                    "Unable to import test_keys/pub/pep.test.alexander6-0xA216E95A_pub.asc");
   1.152 +    
   1.153 +    // Make it an own identity in the DB
   1.154 +    me_pub = new_identity("pep.test.alexander5@darthmama.org", "3C1E713D8519D7F907E3142D179EAA24A216E95A", PEP_OWN_USERID, NULL);
   1.155 +    me_pub->comm_type = PEP_ct_pEp;
   1.156 +    status = set_trust(session, me_pub);
   1.157 +    TEST_ASSERT(status == PEP_STATUS_OK);    
   1.158 +    free_identity(me_pub);
   1.159 +    me_pub = NULL;
   1.160 +
   1.161 +    // Setup own identity
   1.162 +    status = read_file_and_import_key(session,
   1.163 +                "test_keys/pub/pep.test.alexander0-0x3B7302DB_pub.asc");
   1.164 +    TEST_ASSERT(status == PEP_KEY_IMPORTED);
   1.165 +    status = set_up_ident_from_scratch(session,
   1.166 +                "test_keys/priv/pep.test.alexander0-0x3B7302DB_priv.asc",
   1.167 +                "pep.test.xander@pep-project.org", "F4598A17D4690EB3B5B0F6A344F04E963B7302DB", 
   1.168 +                PEP_OWN_USERID, "Xander in Wonderland", NULL, true
   1.169 +            );
   1.170 +    TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
   1.171 +
   1.172 +    // Setup own identity
   1.173 +    status = read_file_and_import_key(session,
   1.174 +                "test_keys/pub/pep.test.alexander0-0x3B7302DB_pub.asc");
   1.175 +    TEST_ASSERT(status == PEP_KEY_IMPORTED);
   1.176 +    status = set_up_ident_from_scratch(session,
   1.177 +                "test_keys/priv/pep.test.alexander0-0x3B7302DB_priv.asc",
   1.178 +                "pep.test.xander1@pep-project.org", "F4598A17D4690EB3B5B0F6A344F04E963B7302DB", 
   1.179 +                PEP_OWN_USERID, "Xander in Wonderland", NULL, true
   1.180 +            );
   1.181 +    TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
   1.182 +
   1.183 +    // Setup own identity
   1.184 +    status = read_file_and_import_key(session,
   1.185 +                "test_keys/pub/pep.test.alexander0-0x3B7302DB_pub.asc");
   1.186 +    TEST_ASSERT(status == PEP_KEY_IMPORTED);
   1.187 +    status = set_up_ident_from_scratch(session,
   1.188 +                "test_keys/priv/pep.test.alexander0-0x3B7302DB_priv.asc",
   1.189 +                "pep.test.xander2@pep-project.org", "F4598A17D4690EB3B5B0F6A344F04E963B7302DB", 
   1.190 +                PEP_OWN_USERID, "Xander in Wonderland", NULL, true
   1.191 +            );
   1.192 +    TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
   1.193 +
   1.194 +    // Ok, see if we get one back.
   1.195 +    stringlist_t* keylist = NULL;
   1.196 +    
   1.197 +    status = _own_keys_retrieve(session, &keylist, 0, true);
   1.198 +    TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
   1.199 +    TEST_ASSERT(keylist);
   1.200 +    TEST_ASSERT(keylist->value);
   1.201 +    TEST_ASSERT(!keylist->next);
   1.202 +
   1.203 +    TEST_ASSERT(strcmp(keylist->value, "F4598A17D4690EB3B5B0F6A344F04E963B7302DB") == 0);
   1.204  }