more tests sync
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Tue, 30 Apr 2019 17:47:53 +0200
branchsync
changeset 358728eaa98bc5b0
parent 3586 60a1999238bb
child 3588 e00a6dfd1fc2
more tests
test/src/engine_tests/OwnKeysRetrieveTests.cc
     1.1 --- a/test/src/engine_tests/OwnKeysRetrieveTests.cc	Tue Apr 30 17:25:11 2019 +0200
     1.2 +++ b/test/src/engine_tests/OwnKeysRetrieveTests.cc	Tue Apr 30 17:47:53 2019 +0200
     1.3 @@ -78,7 +78,7 @@
     1.4      
     1.5      me_bob->me = true;
     1.6      status = set_identity(session, me_bob);
     1.7 -    free(me_bob);
     1.8 +    free_identity(me_bob);
     1.9      me_bob = NULL;
    1.10      TEST_ASSERT(status == PEP_STATUS_OK);
    1.11      
    1.12 @@ -342,7 +342,84 @@
    1.13  }
    1.14  
    1.15  void OwnKeysRetrieveTests::check_own_keys_retrieve_multi_pub_only() {
    1.16 -    TEST_ASSERT(true);
    1.17 +        
    1.18 +    PEP_STATUS status = set_up_ident_from_scratch(session,
    1.19 +                "test_keys/pub/pep.test.alexander0-0x3B7302DB_pub.asc",
    1.20 +                "pep.test.alexander0@darthmama.org", "F4598A17D4690EB3B5B0F6A344F04E963B7302DB", 
    1.21 +                PEP_OWN_USERID, "Xander in Wonderland", NULL, false
    1.22 +            );
    1.23 +    TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
    1.24 +    // Make it an own identity in the DB
    1.25 +    pEp_identity* me_pub = new_identity("pep.test.alexander0@darthmama.org", NULL, PEP_OWN_USERID, NULL);
    1.26 +    status = update_identity(session, me_pub);
    1.27 +    TEST_ASSERT(status == PEP_STATUS_OK);
    1.28 +    TEST_ASSERT(strcmp(me_pub->fpr, "F4598A17D4690EB3B5B0F6A344F04E963B7302DB") == 0);
    1.29 +    status = trust_personal_key(session, me_pub);
    1.30 +    TEST_ASSERT(status == PEP_STATUS_OK);
    1.31 +    
    1.32 +    me_pub->me = true;
    1.33 +    status = set_identity(session, me_pub);
    1.34 +    free_identity(me_pub);
    1.35 +    me_pub = NULL;
    1.36 +    TEST_ASSERT(status == PEP_STATUS_OK);
    1.37 +
    1.38 +
    1.39 +    // Own pub key
    1.40 +    TEST_ASSERT_MSG(slurp_and_import_key(session, "test_keys/pub/pep.test.alexander5-0x0773CD29_pub.asc"),
    1.41 +                    "Unable to import test_keys/pub/pep.test.alexander5-0x0773CD29_pub.asc");
    1.42 +    
    1.43 +    // Make it an own identity in the DB
    1.44 +    me_pub = new_identity("pep.test.alexander0@darthmama.org", "58BCC2BF2AE1E3C4FBEAB89AD7838ACA0773CD29", PEP_OWN_USERID, NULL);
    1.45 +    me_pub->comm_type = PEP_ct_pEp;
    1.46 +    status = set_trust(session, me_pub);
    1.47 +    TEST_ASSERT(status == PEP_STATUS_OK);    
    1.48 +    free_identity(me_pub);
    1.49 +    me_pub = NULL;
    1.50 +
    1.51 +    // Own pub key
    1.52 +    TEST_ASSERT_MSG(slurp_and_import_key(session, "test_keys/pub/pep.test.alexander6-0x0019697D_pub.asc"),
    1.53 +                    "Unable to import test_keys/pub/pep.test.alexander6-0x0019697D_pub.asc");
    1.54 +    
    1.55 +    // Make it an own identity in the DB
    1.56 +    me_pub = new_identity("pep.test.alexander0@darthmama.org", "74D79B4496E289BD8A71B70BA8E2C4530019697D", PEP_OWN_USERID, NULL);
    1.57 +    me_pub->comm_type = PEP_ct_pEp;
    1.58 +    status = set_trust(session, me_pub);
    1.59 +    TEST_ASSERT(status == PEP_STATUS_OK);    
    1.60 +    free_identity(me_pub);
    1.61 +    me_pub = NULL;
    1.62 +
    1.63 +    // Own pub key
    1.64 +    TEST_ASSERT_MSG(slurp_and_import_key(session, "test_keys/pub/pep.test.alexander6-0x503B14D8_pub.asc"),
    1.65 +                    "Unable to import test_keys/pub/pep.test.alexander6-0x503B14D8_pub.asc");
    1.66 +    
    1.67 +    // Make it an own identity in the DB
    1.68 +    me_pub = new_identity("pep.test.alexander0@darthmama.org", "2E21325D202A44BFD9C607FCF095B202503B14D8", PEP_OWN_USERID, NULL);
    1.69 +    me_pub->comm_type = PEP_ct_pEp;
    1.70 +    status = set_trust(session, me_pub);
    1.71 +    TEST_ASSERT(status == PEP_STATUS_OK);    
    1.72 +    free_identity(me_pub);
    1.73 +    me_pub = NULL;
    1.74 +
    1.75 +    // Own pub key
    1.76 +    TEST_ASSERT_MSG(slurp_and_import_key(session, "test_keys/pub/pep.test.alexander6-0xA216E95A_pub.asc"),
    1.77 +                    "Unable to import test_keys/pub/pep.test.alexander6-0xA216E95A_pub.asc");
    1.78 +    
    1.79 +    // Make it an own identity in the DB
    1.80 +    me_pub = new_identity("pep.test.alexander0@darthmama.org", "3C1E713D8519D7F907E3142D179EAA24A216E95A", PEP_OWN_USERID, NULL);
    1.81 +    me_pub->comm_type = PEP_ct_pEp;
    1.82 +    status = set_trust(session, me_pub);
    1.83 +    TEST_ASSERT(status == PEP_STATUS_OK);    
    1.84 +    free_identity(me_pub);
    1.85 +    me_pub = NULL;
    1.86 +    
    1.87 +    // Ok, see if we get anything back.
    1.88 +    stringlist_t* keylist = NULL;
    1.89 +    
    1.90 +    status = _own_keys_retrieve(session, &keylist, 0, true);
    1.91 +    TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
    1.92 +    TEST_ASSERT(!keylist);
    1.93 +
    1.94 +    free_stringlist(keylist);
    1.95  }
    1.96  
    1.97  void OwnKeysRetrieveTests::check_own_keys_retrieve_no_own() {