some test cleanup - removed delete_keypair, making everyone happy, since we do not use it and do not let the outside world do it either. (Key delete dialog still appears on Debian for some reason, so this has been axed because it is a constant irritant.)
authorKrista Bennett <krista@pep-project.org>
Fri, 12 Oct 2018 13:11:41 +0200
changeset 3049edbd93b17440
parent 3039 dffc1122c9c9
child 3050 f62ab227276f
some test cleanup - removed delete_keypair, making everyone happy, since we do not use it and do not let the outside world do it either. (Key delete dialog still appears on Debian for some reason, so this has been axed because it is a constant irritant.)
test/include/AppleMailTests.h
test/src/engine_tests/AppleMailTests.cc
test/src/engine_tests/BlacklistAcceptNewKeyTests.cc
test/src/engine_tests/BlacklistTests.cc
test/src/engine_tests/EncryptMissingPrivateKeyTests.cc
test/src/engine_tests/ExternalRevokeTests.cc
test/src/engine_tests/KeyeditTests.cc
     1.1 --- a/test/include/AppleMailTests.h	Wed Oct 10 08:53:44 2018 +0200
     1.2 +++ b/test/include/AppleMailTests.h	Fri Oct 12 13:11:41 2018 +0200
     1.3 @@ -5,15 +5,16 @@
     1.4  #define APPLE_MAIL_TESTS_H
     1.5  
     1.6  #include <string.h>
     1.7 -#include "EngineTestSessionSuite.h"
     1.8 +#include "EngineTestIndividualSuite.h"
     1.9  
    1.10  using namespace std;
    1.11  
    1.12 -class AppleMailTests : public EngineTestSessionSuite {
    1.13 +class AppleMailTests : public EngineTestIndividualSuite {
    1.14      public:
    1.15          AppleMailTests(string suitename, string test_home_dir);
    1.16      private:
    1.17 -        void check_apple_mail();
    1.18 +        void check_apple_mail_text_signed_encrypted();
    1.19 +        void check_apple_mail_html_signed_encrypted();
    1.20  };
    1.21  
    1.22  #endif
     2.1 --- a/test/src/engine_tests/AppleMailTests.cc	Wed Oct 10 08:53:44 2018 +0200
     2.2 +++ b/test/src/engine_tests/AppleMailTests.cc	Fri Oct 12 13:11:41 2018 +0200
     2.3 @@ -20,18 +20,21 @@
     2.4  #include "test_util.h" // for slurp()
     2.5  
     2.6  #include "EngineTestSuite.h"
     2.7 -#include "EngineTestSessionSuite.h"
     2.8 +#include "EngineTestIndividualSuite.h"
     2.9  #include "AppleMailTests.h"
    2.10  
    2.11  using namespace std;
    2.12  
    2.13  AppleMailTests::AppleMailTests(string suitename, string test_home_dir) : 
    2.14 -    EngineTestSessionSuite::EngineTestSessionSuite(suitename, test_home_dir) {            
    2.15 -    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("AppleMailTests::check_apple_mail"),
    2.16 -                                                                      static_cast<Func>(&AppleMailTests::check_apple_mail)));
    2.17 +    EngineTestIndividualSuite::EngineTestIndividualSuite(suitename, test_home_dir) {            
    2.18 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("AppleMailTests::check_apple_mail_text_signed_encrypted"),
    2.19 +                                                                      static_cast<Func>(&AppleMailTests::check_apple_mail_text_signed_encrypted)));
    2.20 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("AppleMailTests::check_apple_mail_html_signed_encrypted"),
    2.21 +                                                                      static_cast<Func>(&AppleMailTests::check_apple_mail_html_signed_encrypted)));
    2.22 +                                                                  
    2.23  }
    2.24  
    2.25 -void AppleMailTests::check_apple_mail() {
    2.26 +void AppleMailTests::check_apple_mail_text_signed_encrypted() {
    2.27      
    2.28      const char* mailfile = "test_mails/apple_mail_TC_signed_encrypted.eml";
    2.29      
    2.30 @@ -58,11 +61,11 @@
    2.31      
    2.32      message* msg_ptr = nullptr;
    2.33      message* dest_msg = nullptr;
    2.34 -    message* final_ptr = nullptr;
    2.35      stringlist_t* keylist = nullptr;
    2.36      PEP_rating rating;
    2.37      PEP_decrypt_flags_t flags = 0;
    2.38      
    2.39 +    message* final_ptr = nullptr;
    2.40      status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
    2.41      TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
    2.42      TEST_ASSERT_MSG((msg_ptr), "msg_ptr");
    2.43 @@ -85,14 +88,43 @@
    2.44      	free_message(dest_msg);
    2.45      free_message(msg_ptr);
    2.46      free_stringlist(keylist);
    2.47 +}
    2.48  
    2.49 -    msg_ptr = nullptr;
    2.50 -    dest_msg = nullptr;
    2.51 -    final_ptr = nullptr;
    2.52 -    keylist = nullptr;
    2.53 -    rating = PEP_rating_unreliable;
    2.54 -    flags = 0;
    2.55 +void AppleMailTests::check_apple_mail_html_signed_encrypted() {
    2.56 +
    2.57 +    // Start state copy
    2.58 +    // N.B. As part of breaking up formerly monolith tests into individual tests, I've copied state setup from the
    2.59 +    // original functions into many functions. It should, when there's time, either be refactored (if necessary for this 
    2.60 +    // test) or removed (if not).
    2.61 +    const string keytextkey1 = slurp("test_keys/pub/pep-test-apple-0x1CCBC7D7_pub.asc");
    2.62 +    const string keytextkey2 = slurp("test_keys/priv/pep-test-recip-0x08DB0AEE_priv.asc");
    2.63 +    const string keytextkey3 = slurp("test_keys/pub/pep-test-recip-0x08DB0AEE_pub.asc");
    2.64 +
    2.65 +    PEP_STATUS statuskey1 = import_key(session, keytextkey1.c_str(), keytextkey1.length(), NULL);
    2.66 +    PEP_STATUS statuskey2 = import_key(session, keytextkey2.c_str(), keytextkey2.length(), NULL);
    2.67 +    PEP_STATUS statuskey3 = import_key(session, keytextkey3.c_str(), keytextkey3.length(), NULL);
    2.68 +
    2.69 +    pEp_identity * me = new_identity("pep.test.recip@kgrothoff.org", "93D19F24AD6F4C4BA9134AAF84D9217908DB0AEE", PEP_OWN_USERID, "pEp Test Recipient");    
    2.70 +    me->me = true;    
    2.71 +    PEP_STATUS status = set_own_key(session, me, "93D19F24AD6F4C4BA9134AAF84D9217908DB0AEE");
    2.72      
    2.73 +    pEp_identity * you = new_identity("pep.test.apple@pep-project.org", NULL, "pep.test.apple@pep-project.org", "pEp Apple Test");    
    2.74 +    you->me = false;    
    2.75 +    status = update_identity(session, you);
    2.76 +
    2.77 +    trust_personal_key(session, you);
    2.78 +    
    2.79 +    status = update_identity(session, you);
    2.80 +
    2.81 +    // End state copy
    2.82 +    
    2.83 +    message* msg_ptr = nullptr;
    2.84 +    message* dest_msg = nullptr;
    2.85 +    message* final_ptr = nullptr;
    2.86 +    stringlist_t* keylist = nullptr;
    2.87 +    PEP_rating rating;
    2.88 +    PEP_decrypt_flags_t flags = 0;
    2.89 +     
    2.90      const char* mailfile2 = "test_mails/apple_mail_TC_html_signed_encrypted.eml";
    2.91      const string mailtext2 = slurp(mailfile2);
    2.92      
     3.1 --- a/test/src/engine_tests/BlacklistAcceptNewKeyTests.cc	Wed Oct 10 08:53:44 2018 +0200
     3.2 +++ b/test/src/engine_tests/BlacklistAcceptNewKeyTests.cc	Fri Oct 12 13:11:41 2018 +0200
     3.3 @@ -91,11 +91,6 @@
     3.4      PEP_STATUS status13 = blacklist_delete(session, bl_fpr_1);
     3.5      PEP_STATUS status14 = update_identity(session, blacklisted_identity);
     3.6  
     3.7 -    status = delete_keypair(session, new_key);
     3.8 -    update_identity(session, blacklisted_identity);
     3.9 -    status = delete_keypair(session, bl_fpr_1);
    3.10 -    update_identity(session, blacklisted_identity);
    3.11 -    
    3.12      free_message(msg_ptr);
    3.13      free_message(dest_msg);
    3.14      free_stringlist(keylist);
     4.1 --- a/test/src/engine_tests/BlacklistTests.cc	Wed Oct 10 08:53:44 2018 +0200
     4.2 +++ b/test/src/engine_tests/BlacklistTests.cc	Fri Oct 12 13:11:41 2018 +0200
     4.3 @@ -170,12 +170,7 @@
     4.4      // 
     4.5      // // FIXME
     4.6      // // TEST_ASSERT_MSG((stored_identity->comm_type == PEP_ct_pEp), "stored_identity->comm_type == PEP_ct_pEp");    
     4.7 -    
     4.8 -    PEP_STATUS status16 = delete_keypair(session, bl_fpr_1);
     4.9 -    update_identity(session, blacklisted_identity);
    4.10 -    PEP_STATUS status17 = delete_keypair(session, bl_fpr_2);
    4.11 -    update_identity(session, blacklisted_identity2);
    4.12 -        
    4.13 +            
    4.14      free_identity(blacklisted_identity);
    4.15      free_identity(blacklisted_identity2);
    4.16  }
     5.1 --- a/test/src/engine_tests/EncryptMissingPrivateKeyTests.cc	Wed Oct 10 08:53:44 2018 +0200
     5.2 +++ b/test/src/engine_tests/EncryptMissingPrivateKeyTests.cc	Fri Oct 12 13:11:41 2018 +0200
     5.3 @@ -80,9 +80,6 @@
     5.4      char* new_key = enc_msg->from->fpr;
     5.5      cout << "Encrypted with key " << new_key << endl;
     5.6      
     5.7 -    status = delete_keypair(session, new_key);
     5.8 -    PEP_STATUS status14 = myself(session, no_key_identity);
     5.9 -
    5.10      free_message(tmp_msg);    
    5.11      free_message(enc_msg);
    5.12  }
     6.1 --- a/test/src/engine_tests/ExternalRevokeTests.cc	Wed Oct 10 08:53:44 2018 +0200
     6.2 +++ b/test/src/engine_tests/ExternalRevokeTests.cc	Fri Oct 12 13:11:41 2018 +0200
     6.3 @@ -297,10 +297,7 @@
     6.4      free_identity(me);
     6.5      free_identity(recip1);
     6.6      free(uniqname);
     6.7 -    
     6.8 -    delete_keypair(session, fprs[0]);    
     6.9 -    delete_keypair(session, fprs[1]);
    6.10 -    
    6.11 +        
    6.12      free(fprs[0]);
    6.13      free(fprs[1]);
    6.14      
     7.1 --- a/test/src/engine_tests/KeyeditTests.cc	Wed Oct 10 08:53:44 2018 +0200
     7.2 +++ b/test/src/engine_tests/KeyeditTests.cc	Fri Oct 12 13:11:41 2018 +0200
     7.3 @@ -63,8 +63,12 @@
     7.4      
     7.5      cout << "key revoked.\n";
     7.6  
     7.7 -    cout << "deleting key pair " << key.c_str() << "\n";
     7.8 -    PEP_STATUS delete_status = delete_keypair(session, key.c_str());
     7.9 -    cout << "delete_keypair() exits with " << delete_status << "\n";
    7.10 -    TEST_ASSERT_MSG((delete_status == PEP_STATUS_OK), "delete_status == PEP_STATUS_OK");
    7.11 +    // Because pEp's policy is never to delete keys from the keyring and delete_keypair
    7.12 +    // though gnupg makes responding to a dialog mandatory under Debian, we will not test
    7.13 +    // this anymore.
    7.14 +    
    7.15 +    // cout << "deleting key pair " << key.c_str() << "\n";
    7.16 +    // PEP_STATUS delete_status = delete_keypair(session, key.c_str());
    7.17 +    // cout << "delete_keypair() exits with " << delete_status << "\n";
    7.18 +    // TEST_ASSERT_MSG((delete_status == PEP_STATUS_OK), "delete_status == PEP_STATUS_OK");
    7.19  }