ENGINE-209: asserts put into tests. Still have question about PEP_ct_pEp ENGINE-209
authorKrista Bennett <krista@pep-project.org>
Wed, 31 May 2017 17:47:42 +0200
branchENGINE-209
changeset 181104d2a7abcfa2
parent 1810 0beaab16a32c
child 1812 925ad845e3ec
ENGINE-209: asserts put into tests. Still have question about PEP_ct_pEp
test/Makefile
test/external_revoke_test.cc
     1.1 --- a/test/Makefile	Wed May 31 15:52:30 2017 +0200
     1.2 +++ b/test/Makefile	Wed May 31 17:47:42 2017 +0200
     1.3 @@ -4,7 +4,8 @@
     1.4  
     1.5  include ../Makefile.conf
     1.6  
     1.7 -export GNUPGHOME=.
     1.8 +export GNUPGHOME=/home/krista/.gnupg/.
     1.9 +#export GNUPGHOME=.
    1.10  
    1.11  CC?=g++ -std=gnu++11 -pthread
    1.12  CXX?=g++ -std=gnu++11 -pthread
     2.1 --- a/test/external_revoke_test.cc	Wed May 31 15:52:30 2017 +0200
     2.2 +++ b/test/external_revoke_test.cc	Wed May 31 17:47:42 2017 +0200
     2.3 @@ -79,12 +79,12 @@
     2.4  
     2.5      // check comm_type
     2.6      cout << "comm_type: " << encrypted_outgoing_msg->to->ident->comm_type << endl;
     2.7 -
     2.8      assert(encrypted_outgoing_msg->to->ident->comm_type == PEP_ct_OpenPGP);
     2.9 +    
    2.10      status = get_trust(session, recip1);
    2.11      
    2.12      cout << "Recip's trust DB comm_type = " << hex << recip1->comm_type << endl;
    2.13 -    assert(recip1->comm_type == PEP_ct_OpenPGP);
    2.14 +    assert(recip1->comm_type == PEP_ct_OpenPGP); // FIXME: PEP_ct_pEp???
    2.15  
    2.16      // decrypt message
    2.17      free_message(outgoing_message);
    2.18 @@ -96,15 +96,17 @@
    2.19  
    2.20      status = decrypt_message(session, encrypted_outgoing_msg, &outgoing_message, &keylist, &rating, &flags);
    2.21      assert(status == PEP_STATUS_OK);
    2.22 -    assert(rating >= PEP_rating_trusted);
    2.23 +    assert(rating == PEP_rating_trusted);
    2.24  
    2.25      // check rating
    2.26      cout << "Rating of decrypted message to trusted recip: " << rating << endl;
    2.27 -
    2.28 +    assert(rating == PEP_rating_trusted); // FIXME: trusted and anonymised?
    2.29 +    
    2.30      // check comm_type
    2.31      status = get_trust(session, recip1);
    2.32 -    
    2.33 +
    2.34      cout << "Recip's trust DB comm_type = " << recip1->comm_type << endl;
    2.35 +    assert(recip1->comm_type == PEP_ct_OpenPGP); // FIXME: PEP_ct_pEp???
    2.36  
    2.37      // externally revoke key
    2.38      // (note - as of 23.5.17, revoke_key() doesn't touch the trust db, just the keyring, so we can do this)
    2.39 @@ -112,7 +114,6 @@
    2.40      status = get_identity(session, uniqname, r1_userid, &recip1);
    2.41      
    2.42      status = revoke_key(session, recip1->fpr, "encrypt_for_identity_test");
    2.43 -
    2.44      
    2.45      // free messages
    2.46      free_message(outgoing_message);
    2.47 @@ -137,34 +138,37 @@
    2.48  
    2.49      status = encrypt_message(session, outgoing_message, NULL, &encrypted_outgoing_msg, PEP_enc_PGP_MIME, 0);
    2.50  
    2.51 +    PEP_comm_type ct = (encrypted_outgoing_msg ? encrypted_outgoing_msg->to->ident->comm_type : outgoing_message->to->ident->comm_type);
    2.52 +
    2.53      // check comm_type
    2.54 -    if (encrypted_outgoing_msg)
    2.55 -        cout << "comm_type: " << encrypted_outgoing_msg->to->ident->comm_type << endl;
    2.56 -    else
    2.57 -        cout << "comm_type: " << outgoing_message->to->ident->comm_type << endl;
    2.58 -        
    2.59 +    cout << "comm_type: " << ct << endl;
    2.60 +    assert(ct == PEP_ct_key_revoked);
    2.61 +    
    2.62      status = get_trust(session, recip1);
    2.63  
    2.64      cout << "Recip's trust DB comm_type = " << hex << recip1->comm_type << endl;
    2.65 +    assert(recip1->comm_type == PEP_ct_key_revoked);
    2.66  
    2.67      // decrypt message
    2.68  //    free_message(outgoing_message);
    2.69  //    outgoing_message = NULL;
    2.70  
    2.71      status = decrypt_message(session, outgoing_message, &decrypted_msg, &keylist, &rating, &flags);
    2.72 +    assert(status == PEP_UNENCRYPTED);
    2.73  
    2.74      // check rating
    2.75      cout << "Rating of decrypted message to trusted recip: " << rating << endl;
    2.76 +    assert(rating == PEP_rating_unencrypted);
    2.77  
    2.78 -    // check comm_type
    2.79 -    if (decrypted_msg)
    2.80 -        cout << "comm_type: " << decrypted_msg->to->ident->comm_type << endl;
    2.81 -    else
    2.82 -        cout << "comm_type: " << outgoing_message->to->ident->comm_type << endl;
    2.83 +    ct = (decrypted_msg ? decrypted_msg->to->ident->comm_type : outgoing_message->to->ident->comm_type);
    2.84 +
    2.85 +    cout << "comm_type: " << ct << endl;
    2.86 +    assert(ct == PEP_ct_key_revoked);
    2.87      
    2.88      status = get_trust(session, recip1);
    2.89      
    2.90      cout << "Recip's trust DB comm_type = " << hex << recip1->comm_type << endl;
    2.91 +    assert(recip1->comm_type == PEP_ct_key_revoked);
    2.92  
    2.93      // generate new key
    2.94      status = generate_keypair(session, recip1);