ENGINE-463: now not bailing when sender has an invalid key (we never should have)
authorKrista Bennett <krista@pep-project.org>
Mon, 15 Oct 2018 13:05:30 +0200
changeset 3053ee4d6f347629
parent 3052 294647161f14
child 3063 33907822c832
ENGINE-463: now not bailing when sender has an invalid key (we never should have)
src/message_api.c
test/include/Engine463Tests.h
test/src/engine_tests/Engine463Tests.cc
     1.1 --- a/src/message_api.c	Mon Oct 15 10:42:44 2018 +0200
     1.2 +++ b/src/message_api.c	Mon Oct 15 13:05:30 2018 +0200
     1.3 @@ -3193,7 +3193,8 @@
     1.4          else
     1.5              status = myself(session, src->from);
     1.6          
     1.7 -        if (status != PEP_STATUS_OK)
     1.8 +        // We absolutely should NOT be bailing here unless it's a serious error
     1.9 +        if (status == PEP_OUT_OF_MEMORY)
    1.10              return status;
    1.11      }
    1.12      
     2.1 --- a/test/include/Engine463Tests.h	Mon Oct 15 10:42:44 2018 +0200
     2.2 +++ b/test/include/Engine463Tests.h	Mon Oct 15 13:05:30 2018 +0200
     2.3 @@ -15,6 +15,7 @@
     2.4      private:
     2.5          void check_engine_463_no_own_key();
     2.6          void check_engine_463_own_key();
     2.7 +        void check_engine_463_sender_expired_and_renewed();
     2.8  };
     2.9  
    2.10  #endif
     3.1 --- a/test/src/engine_tests/Engine463Tests.cc	Mon Oct 15 10:42:44 2018 +0200
     3.2 +++ b/test/src/engine_tests/Engine463Tests.cc	Mon Oct 15 13:05:30 2018 +0200
     3.3 @@ -19,6 +19,8 @@
     3.4                                                                        static_cast<Func>(&Engine463Tests::check_engine_463_no_own_key)));
     3.5      add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("Engine463Tests::check_engine_463_own_key"),
     3.6                                                                        static_cast<Func>(&Engine463Tests::check_engine_463_own_key)));                                                                  
     3.7 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("Engine463Tests::check_engine_463_sender_expired_and_renewed"),
     3.8 +                                                                      static_cast<Func>(&Engine463Tests::check_engine_463_sender_expired_and_renewed)));                                                                                                                                    
     3.9  }
    3.10  
    3.11  void Engine463Tests::check_engine_463_no_own_key() {
    3.12 @@ -42,7 +44,6 @@
    3.13       
    3.14      status = MIME_decrypt_message(session, msg.c_str(), msg.size(), &decrypted_msg, &keylist_used, &rating, &flags, &modified_src);
    3.15      TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
    3.16 -    cout << decrypted_msg << endl;        
    3.17  }
    3.18  
    3.19  void Engine463Tests::check_engine_463_own_key() {
    3.20 @@ -70,5 +71,42 @@
    3.21       
    3.22      status = MIME_decrypt_message(session, msg.c_str(), msg.size(), &decrypted_msg, &keylist_used, &rating, &flags, &modified_src);
    3.23      TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
    3.24 -    cout << decrypted_msg << endl;        
    3.25  }
    3.26 +
    3.27 +void Engine463Tests::check_engine_463_sender_expired_and_renewed() {
    3.28 +    // I am not entirely sure what the setup of this bug is tbh, but here goes.
    3.29 +    // 1. Import expired keys and own keys
    3.30 +    bool ok = false;
    3.31 +    ok = slurp_and_import_key(session, "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc");
    3.32 +    TEST_ASSERT(ok);    
    3.33 +    ok = slurp_and_import_key(session, "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc");    
    3.34 +    TEST_ASSERT(ok);
    3.35 +    ok = slurp_and_import_key(session, "test_keys/pub/inquisitor-0xA4728718_full_expired.pub.asc");    
    3.36 +    TEST_ASSERT(ok);
    3.37 +
    3.38 +    // Ok, so I want to make sure we make an entry, so I'll try to decrypt the message WITH
    3.39 +    // the expired key:
    3.40 +    const string msg = slurp("test_mails/ENGINE-463-attempt-numero-dos.eml");
    3.41 +    
    3.42 +    char* decrypted_msg = NULL;
    3.43 +    stringlist_t* keylist_used = nullptr;
    3.44 +    char* modified_src = NULL;
    3.45 +    
    3.46 +    PEP_rating rating;
    3.47 +    PEP_decrypt_flags_t flags;
    3.48 +     
    3.49 +    PEP_STATUS status = MIME_decrypt_message(session, msg.c_str(), msg.size(), &decrypted_msg, &keylist_used, &rating, &flags, &modified_src);
    3.50 +//    cout << decrypted_msg << endl;            
    3.51 +    TEST_ASSERT_MSG((status == PEP_DECRYPTED), tl_status_string(status));
    3.52 +
    3.53 +    free(decrypted_msg);
    3.54 +    decrypted_msg = NULL;
    3.55 +    ok = slurp_and_import_key(session, "test_keys/pub/inquisitor-0xA4728718_renewed_pub.asc");    
    3.56 +    TEST_ASSERT(ok);    
    3.57 +    
    3.58 +    status = MIME_decrypt_message(session, msg.c_str(), msg.size(), &decrypted_msg, &keylist_used, &rating, &flags, &modified_src);    
    3.59 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
    3.60 +//    cout << decrypted_msg << endl;            
    3.61 +
    3.62 +}
    3.63 +