Makefile googletest
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Mon, 26 Aug 2019 10:49:04 +0200
branchgoogletest
changeset 4011e8b3f8663f65
parent 4010 28bdbd0b27d0
parent 4006 f94802409ab4
child 4012 beb70e301d31
Makefile
.hgignore
gtest/gtest_firstpass.py
gtest/include/Engine.h
gtest/src/Engine.cc
gtest/src/Engine.h
gtest/src/ExportKeyTest.cc
gtest/src/engine_tests/ExportKeyTest.cc
test/include/test_util.h
     1.1 --- a/.hgignore	Fri Aug 23 09:02:09 2019 +0200
     1.2 +++ b/.hgignore	Mon Aug 26 10:49:04 2019 +0200
     1.3 @@ -84,3 +84,5 @@
     1.4  *.swo
     1.5  test/.scripts
     1.6  test/.suitemaker
     1.7 +gtest/EngineTests
     1.8 +gtest/googletest
     2.1 --- a/gtest/gtest_firstpass.py	Fri Aug 23 09:02:09 2019 +0200
     2.2 +++ b/gtest/gtest_firstpass.py	Mon Aug 26 10:49:04 2019 +0200
     2.3 @@ -70,7 +70,7 @@
     2.4                      newfile.write(tb(4) + "// You can do set-up work for each test here.\n")
     2.5                      newfile.write(tb(4) + "test_suite_name = ::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name();\n")
     2.6                      newfile.write(tb(4) + "test_name = ::testing::UnitTest::GetInstance()->current_test_info()->name();\n")
     2.7 -                    newfile.write(tb(4) + "string test_path = get_main_test_home_dir() + \"/\" + test_suite_name + \"/\" + test_name;\n")
     2.8 +                    newfile.write(tb(4) + "test_path = get_main_test_home_dir() + \"/\" + test_suite_name + \"/\" + test_name;\n")
     2.9                      newfile.write(tb(3) + "}\n\n")
    2.10                      newfile.write(tb(3) + "~" + modline + "() override {\n")
    2.11                      newfile.write(tb(4) + "// You can do clean-up work that doesn't throw exceptions here.\n")
    2.12 @@ -96,7 +96,6 @@
    2.13                      newfile.write(tb(3) + "void TearDown() override {\n")
    2.14                      newfile.write(tb(4) + "// Code here will be called immediately after each test (right\n")
    2.15                      newfile.write(tb(4) + "// before the destructor).\n")   
    2.16 -                    newfile.write("\n" + tb(4) + "// While it would be nice to have this in the destructor, it can throw exceptions, so it's here.\n")                 
    2.17                      newfile.write(tb(4) + "engine->shut_down();\n")
    2.18                      newfile.write(tb(4) + "delete engine;\n")                    
    2.19                      newfile.write(tb(4) + "engine = NULL;\n")                    
    2.20 @@ -104,7 +103,8 @@
    2.21                      newfile.write(tb(3) + "}\n\n")
    2.22                      newfile.write(tb(2) + "private:\n");
    2.23                      newfile.write(tb(3) + "const char* test_suite_name;\n")
    2.24 -                    newfile.write(tb(3) + "const char* test_name;\n")                                        
    2.25 +                    newfile.write(tb(3) + "const char* test_name;\n")                                                            
    2.26 +                    newfile.write(tb(3) + "string test_path;\n") 
    2.27                      newfile.write(tb(3) + "// Objects declared here can be used by all tests in the " + modline + " suite.\n\n")
    2.28                      newfile.write(tb(1) + "};\n\n")
    2.29                      newfile.write("}  // namespace\n\n\n")
    2.30 @@ -250,7 +250,7 @@
    2.31              if (line != modline):
    2.32                  if not line.endswith(";"):
    2.33                      eat_next_line = True
    2.34 -                    modline = re.sub(r'\),', r'\)\);', modline);
    2.35 +                    modline = re.sub(r'\),', r'));', modline);
    2.36                  newfile.write(modline + "\n")
    2.37                  continue
    2.38              modline = re.sub(r'TEST_ASSERT\(slurp_and_import_key', r'ASSERT_TRUE(slurp_and_import_key',line)
     3.1 --- a/gtest/include/Engine.h	Fri Aug 23 09:02:09 2019 +0200
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,33 +0,0 @@
     3.4 -#ifndef ENGINE_TEST_SUITE_H
     3.5 -#define ENGINE_TEST_SUITE_H
     3.6 -
     3.7 -#include <string>
     3.8 -#include <map>
     3.9 -#include <vector>
    3.10 -#include <utility>
    3.11 -#include "pEpEngine.h"
    3.12 -
    3.13 -using namespace std;
    3.14 -
    3.15 -class Engine {
    3.16 -    public:
    3.17 -        Engine(string engine_home_dir);
    3.18 -        virtual ~Engine();
    3.19 -        
    3.20 -        void prep(messageToSend_t mts, inject_sync_event_t ise, std::vector<std::pair<std::string, std::string>> init_files);
    3.21 -        void start();
    3.22 -        void shut_down();
    3.23 -        
    3.24 -    protected:
    3.25 -        PEP_SESSION session;
    3.26 -        string engine_home;
    3.27 -        string real_home;
    3.28 -        string prev_pgp_home;
    3.29 -        
    3.30 -        messageToSend_t cached_messageToSend;
    3.31 -        inject_sync_event_t cached_inject_sync_event;
    3.32 -        	
    3.33 -        void copy_conf_file_to_test_dir(const char* dest_path, const char* conf_orig_path, const char* conf_dest_name);        
    3.34 -        void process_file_queue(std::string dirname, std::vector<std::pair<std::string, std::string>> file_queue);
    3.35 -};
    3.36 -#endif
     4.1 --- a/gtest/src/Engine.cc	Fri Aug 23 09:02:09 2019 +0200
     4.2 +++ b/gtest/src/Engine.cc	Mon Aug 26 10:49:04 2019 +0200
     4.3 @@ -58,10 +58,10 @@
     4.4          }
     4.5      }
     4.6      else {
     4.7 -        int errchk = mkdir(engine_home.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
     4.8 -        cout << errchk << endl;
     4.9 +        // Look, we're not creating all of these dirs...
    4.10 +        const int errchk = system((string("mkdir -p ") + engine_home).c_str());
    4.11          if (errchk != 0)
    4.12 -            throw std::runtime_error("ENGINE SETUP: Error creating a test directory.");
    4.13 +            throw std::runtime_error("ENGINE SETUP: Error creating a test directory.");        
    4.14      }
    4.15  
    4.16      process_file_queue(engine_home, init_files);
    4.17 @@ -69,7 +69,7 @@
    4.18      // We will set homedirs etc outside this function. Right now, we're just making sure we can.
    4.19      // Let's make sure we're not trying to run it under the real current home, however.
    4.20      
    4.21 -    if (engine_home.compare(real_home) != 0 || engine_home.compare(real_home + "/") != 0)
    4.22 +    if (engine_home.compare(real_home) == 0 || engine_home.compare(real_home + "/") == 0)
    4.23          throw std::runtime_error("ENGINE SETUP: Cowardly refusing to set up for playing in what looks like the real home directory.");
    4.24      
    4.25  }
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/gtest/src/Engine.h	Mon Aug 26 10:49:04 2019 +0200
     5.3 @@ -0,0 +1,34 @@
     5.4 +#ifndef ENGINE_TEST_SUITE_H
     5.5 +#define ENGINE_TEST_SUITE_H
     5.6 +
     5.7 +#include <string>
     5.8 +#include <map>
     5.9 +#include <vector>
    5.10 +#include <utility>
    5.11 +#include "pEpEngine.h"
    5.12 +
    5.13 +using namespace std;
    5.14 +
    5.15 +class Engine {
    5.16 +    public:
    5.17 +        Engine(string engine_home_dir);
    5.18 +        virtual ~Engine();
    5.19 +        
    5.20 +        void prep(messageToSend_t mts, inject_sync_event_t ise, std::vector<std::pair<std::string, std::string>> init_files);
    5.21 +        void start();
    5.22 +        void shut_down();
    5.23 +
    5.24 +        PEP_SESSION session;
    5.25 +        
    5.26 +    protected:
    5.27 +        string engine_home;
    5.28 +        string real_home;
    5.29 +        string prev_pgp_home;
    5.30 +        
    5.31 +        messageToSend_t cached_messageToSend;
    5.32 +        inject_sync_event_t cached_inject_sync_event;
    5.33 +        	
    5.34 +        void copy_conf_file_to_test_dir(const char* dest_path, const char* conf_orig_path, const char* conf_dest_name);        
    5.35 +        void process_file_queue(std::string dirname, std::vector<std::pair<std::string, std::string>> file_queue);
    5.36 +};
    5.37 +#endif
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/gtest/src/ExportKeyTest.cc	Mon Aug 26 10:49:04 2019 +0200
     6.3 @@ -0,0 +1,179 @@
     6.4 +// This file is under GNU General Public License 3.0
     6.5 +// see LICENSE.txt
     6.6 +
     6.7 +#include <stdlib.h>
     6.8 +#include <cstring>
     6.9 +#include <string>
    6.10 +
    6.11 +#include "test_util.h"
    6.12 +
    6.13 +#include "pEpEngine.h"
    6.14 +
    6.15 +
    6.16 +
    6.17 +#include "Engine.h"
    6.18 +
    6.19 +#include <gtest/gtest.h>
    6.20 +
    6.21 +
    6.22 +namespace {
    6.23 +
    6.24 +	//The fixture for ExportKeyTest
    6.25 +    class ExportKeyTest : public ::testing::Test {
    6.26 +        public:
    6.27 +            Engine* engine;
    6.28 +            PEP_SESSION session;
    6.29 +
    6.30 +        protected:
    6.31 +            // You can remove any or all of the following functions if its body
    6.32 +            // is empty.
    6.33 +            ExportKeyTest() {
    6.34 +                // You can do set-up work for each test here.
    6.35 +                test_suite_name = ::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name();
    6.36 +                test_name = ::testing::UnitTest::GetInstance()->current_test_info()->name();
    6.37 +                test_path = get_main_test_home_dir() + "/" + test_suite_name + "/" + test_name;
    6.38 +            }
    6.39 +
    6.40 +            ~ExportKeyTest() override {
    6.41 +                // You can do clean-up work that doesn't throw exceptions here.
    6.42 +            }
    6.43 +
    6.44 +            // If the constructor and destructor are not enough for setting up
    6.45 +            // and cleaning up each test, you can define the following methods:
    6.46 +
    6.47 +            void SetUp() override {
    6.48 +                // Code here will be called immediately after the constructor (right
    6.49 +                // before each test).
    6.50 +
    6.51 +                // Leave this empty if there are no files to copy to the home directory path
    6.52 +                std::vector<std::pair<std::string, std::string>> init_files = std::vector<std::pair<std::string, std::string>>();
    6.53 +
    6.54 +                // Get a new test Engine.
    6.55 +                engine = new Engine(test_path);
    6.56 +                ASSERT_NE(engine, nullptr);
    6.57 +
    6.58 +                // Ok, let's initialize test directories etc.
    6.59 +                engine->prep(NULL, NULL, init_files);
    6.60 +
    6.61 +                // Ok, try to start this bugger.
    6.62 +                engine->start();
    6.63 +                ASSERT_NE(engine->session, nullptr);
    6.64 +                session = engine->session;
    6.65 +
    6.66 +                // Engine is up. Keep on truckin'
    6.67 +            }
    6.68 +
    6.69 +            void TearDown() override {
    6.70 +                // Code here will be called immediately after each test (right
    6.71 +                // before the destructor).
    6.72 +
    6.73 +                // While it would be nice to have this in the destructor, it can throw exceptions, so it's here.
    6.74 +                engine->shut_down();
    6.75 +                delete engine;
    6.76 +                engine = NULL;
    6.77 +                session = NULL;
    6.78 +            }
    6.79 +
    6.80 +        private:
    6.81 +            const char* test_suite_name;
    6.82 +            const char* test_name;
    6.83 +            string test_path;
    6.84 +            // Objects declared here can be used by all tests in the ExportKeyTest suite.
    6.85 +
    6.86 +    };
    6.87 +
    6.88 +}  // namespace
    6.89 +
    6.90 +
    6.91 +TEST_F(ExportKeyTest, check_export_key_no_key) {
    6.92 +    char* keydata = NULL;
    6.93 +    size_t keysize = 0;
    6.94 +    PEP_STATUS status = export_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39",
    6.95 +                                   &keydata, &keysize);
    6.96 +    ASSERT_EQ(status , PEP_KEY_NOT_FOUND);
    6.97 +    free(keydata);
    6.98 +    keydata = NULL;
    6.99 +    keysize = 0;
   6.100 +    status = export_secret_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39",
   6.101 +                                   &keydata, &keysize);
   6.102 +    ASSERT_EQ(status , PEP_KEY_NOT_FOUND);
   6.103 +    free(keydata);
   6.104 +
   6.105 +}
   6.106 +
   6.107 +TEST_F(ExportKeyTest, check_export_key_pubkey) {
   6.108 +    // Own pub key
   6.109 +    ASSERT_TRUE(slurp_and_import_key(session, "test_keys/pub/pep-test-bob-0xC9C2EE39_pub.asc"));
   6.110 +
   6.111 +    char* keydata = NULL;
   6.112 +    size_t keysize = 0;
   6.113 +    stringlist_t* keylist = NULL;
   6.114 +    PEP_STATUS status = find_keys(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", &keylist);
   6.115 +    ASSERT_TRUE(keylist && keylist->value);
   6.116 +    ASSERT_STREQ(keylist->value, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39");
   6.117 +    free_stringlist(keylist);
   6.118 +
   6.119 +    status = export_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39",
   6.120 +                                   &keydata, &keysize);
   6.121 +    ASSERT_EQ(status , PEP_STATUS_OK);
   6.122 +    ASSERT_NE(keydata, nullptr);
   6.123 +    ASSERT_GT(keysize, 0);
   6.124 +
   6.125 +    free(keydata);
   6.126 +}
   6.127 +
   6.128 +TEST_F(ExportKeyTest, check_export_key_secret_key) {
   6.129 +    ASSERT_TRUE(slurp_and_import_key(session, "test_keys/pub/pep-test-bob-0xC9C2EE39_pub.asc"));
   6.130 +    ASSERT_TRUE(slurp_and_import_key(session, "test_keys/priv/pep-test-bob-0xC9C2EE39_priv.asc"));
   6.131 +    char* keydata = NULL;
   6.132 +    size_t keysize = 0;
   6.133 +    stringlist_t* keylist = NULL;
   6.134 +    PEP_STATUS status = find_keys(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", &keylist);
   6.135 +    ASSERT_TRUE(keylist && keylist->value);
   6.136 +    ASSERT_STREQ(keylist->value, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39");
   6.137 +    free_stringlist(keylist);
   6.138 +    keylist = NULL;
   6.139 +
   6.140 +    bool has_private = false;
   6.141 +    contains_priv_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", &has_private);
   6.142 +    ASSERT_TRUE(has_private);
   6.143 +
   6.144 +    status = export_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39",
   6.145 +                                   &keydata, &keysize);
   6.146 +    ASSERT_EQ(status , PEP_STATUS_OK);
   6.147 +    ASSERT_NE(keydata, nullptr);
   6.148 +    ASSERT_GT(keysize, 0);
   6.149 +
   6.150 +    free(keydata);
   6.151 +    keydata = NULL;
   6.152 +    keysize = 0;
   6.153 +    status = export_secret_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39",
   6.154 +                                   &keydata, &keysize);
   6.155 +    ASSERT_EQ(status , PEP_STATUS_OK);
   6.156 +
   6.157 +    free(keydata);
   6.158 +}
   6.159 +
   6.160 +
   6.161 +TEST_F(ExportKeyTest, check_export_key_no_secret_key) {
   6.162 +    // Own pub key
   6.163 +    ASSERT_TRUE(slurp_and_import_key(session, "test_keys/pub/pep-test-bob-0xC9C2EE39_pub.asc"));
   6.164 +
   6.165 +    char* keydata = NULL;
   6.166 +    size_t keysize = 0;
   6.167 +    stringlist_t* keylist = NULL;
   6.168 +    PEP_STATUS status = find_keys(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", &keylist);
   6.169 +    ASSERT_TRUE(keylist && keylist->value);
   6.170 +    ASSERT_STREQ(keylist->value, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39");
   6.171 +
   6.172 +    status = export_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39",
   6.173 +                                   &keydata, &keysize);
   6.174 +    ASSERT_EQ(status , PEP_STATUS_OK);
   6.175 +    free(keydata);
   6.176 +    keydata = NULL;
   6.177 +    keysize = 0;
   6.178 +    status = export_secret_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39",
   6.179 +                                   &keydata, &keysize);
   6.180 +    ASSERT_EQ(status , PEP_KEY_NOT_FOUND);
   6.181 +    free(keydata);
   6.182 +}
     7.1 --- a/gtest/src/engine_tests/ExportKeyTest.cc	Fri Aug 23 09:02:09 2019 +0200
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,178 +0,0 @@
     7.4 -// This file is under GNU General Public License 3.0
     7.5 -// see LICENSE.txt
     7.6 -
     7.7 -#include <stdlib.h>
     7.8 -#include <cstring>
     7.9 -#include <string>
    7.10 -
    7.11 -#include "test_util.h"
    7.12 -
    7.13 -#include "pEpEngine.h"
    7.14 -
    7.15 -
    7.16 -
    7.17 -#include "Engine.h"
    7.18 -
    7.19 -#include <gtest/gtest.h>
    7.20 -
    7.21 -
    7.22 -namespace {
    7.23 -
    7.24 -	//The fixture for ExportKeyTest
    7.25 -    class ExportKeyTest : public ::testing::Test {
    7.26 -        public:
    7.27 -            Engine* engine;
    7.28 -            PEP_SESSION session;
    7.29 -
    7.30 -        protected:
    7.31 -            // You can remove any or all of the following functions if its body
    7.32 -            // is empty.
    7.33 -            ExportKeyTest() {
    7.34 -                // You can do set-up work for each test here.
    7.35 -                test_suite_name = ::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name();
    7.36 -                test_name = ::testing::UnitTest::GetInstance()->current_test_info()->name();
    7.37 -                string test_path = get_main_test_home_dir() + "/" + test_suite_name + "/" + test_name;
    7.38 -            }
    7.39 -
    7.40 -            ~ExportKeyTest() override {
    7.41 -                // You can do clean-up work that doesn't throw exceptions here.
    7.42 -            }
    7.43 -
    7.44 -            // If the constructor and destructor are not enough for setting up
    7.45 -            // and cleaning up each test, you can define the following methods:
    7.46 -
    7.47 -            void SetUp() override {
    7.48 -                // Code here will be called immediately after the constructor (right
    7.49 -                // before each test).
    7.50 -
    7.51 -                // Leave this empty if there are no files to copy to the home directory path
    7.52 -                std::vector<std::pair<std::string, std::string>> init_files = std::vector<std::pair<std::string, std::string>>();
    7.53 -
    7.54 -                // Get a new test Engine.
    7.55 -                engine = new Engine(test_path);
    7.56 -                ASSERT_NE(engine, nullptr);
    7.57 -
    7.58 -                // Ok, let's initialize test directories etc.
    7.59 -                engine->prep(NULL, NULL, init_files);
    7.60 -
    7.61 -                // Ok, try to start this bugger.
    7.62 -                engine->start();
    7.63 -                ASSERT_NE(engine->session, nullptr);
    7.64 -                session = engine->session;
    7.65 -
    7.66 -                // Engine is up. Keep on truckin'
    7.67 -            }
    7.68 -
    7.69 -            void TearDown() override {
    7.70 -                // Code here will be called immediately after each test (right
    7.71 -                // before the destructor).
    7.72 -
    7.73 -                // While it would be nice to have this in the destructor, it can throw exceptions, so it's here.
    7.74 -                engine->shut_down();
    7.75 -                delete engine;
    7.76 -                engine = NULL;
    7.77 -                session = NULL;
    7.78 -            }
    7.79 -
    7.80 -        private:
    7.81 -            const char* test_suite_name;
    7.82 -            const char* test_name;
    7.83 -            // Objects declared here can be used by all tests in the ExportKeyTest suite.
    7.84 -
    7.85 -    };
    7.86 -
    7.87 -}  // namespace
    7.88 -
    7.89 -
    7.90 -TEST_F(ExportKeyTest, check_export_key_no_key) {
    7.91 -    char* keydata = NULL;
    7.92 -    size_t keysize = 0;
    7.93 -    PEP_STATUS status = export_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39",
    7.94 -                                   &keydata, &keysize);
    7.95 -    ASSERT_EQ(status , PEP_KEY_NOT_FOUND);
    7.96 -    free(keydata);
    7.97 -    keydata = NULL;
    7.98 -    keysize = 0;
    7.99 -    status = export_secret_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39",
   7.100 -                                   &keydata, &keysize);
   7.101 -    ASSERT_EQ(status , PEP_KEY_NOT_FOUND);
   7.102 -    free(keydata);
   7.103 -
   7.104 -}
   7.105 -
   7.106 -TEST_F(ExportKeyTest, check_export_key_pubkey) {
   7.107 -    // Own pub key
   7.108 -    ASSERT_TRUE(slurp_and_import_key(session, "test_keys/pub/pep-test-bob-0xC9C2EE39_pub.asc"\)\);
   7.109 -
   7.110 -    char* keydata = NULL;
   7.111 -    size_t keysize = 0;
   7.112 -    stringlist_t* keylist = NULL;
   7.113 -    PEP_STATUS status = find_keys(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", &keylist);
   7.114 -    ASSERT_TRUE(keylist && keylist->value);
   7.115 -    ASSERT_STREQ(keylist->value, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39");
   7.116 -    free_stringlist(keylist);
   7.117 -
   7.118 -    status = export_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39",
   7.119 -                                   &keydata, &keysize);
   7.120 -    ASSERT_EQ(status , PEP_STATUS_OK);
   7.121 -    ASSERT_NE(keydata, nullptr);
   7.122 -    ASSERT_GT(keysize, 0);
   7.123 -
   7.124 -    free(keydata);
   7.125 -}
   7.126 -
   7.127 -TEST_F(ExportKeyTest, check_export_key_secret_key) {
   7.128 -    ASSERT_TRUE(slurp_and_import_key(session, "test_keys/pub/pep-test-bob-0xC9C2EE39_pub.asc"\)\);
   7.129 -    ASSERT_TRUE(slurp_and_import_key(session, "test_keys/priv/pep-test-bob-0xC9C2EE39_priv.asc"\)\);
   7.130 -    char* keydata = NULL;
   7.131 -    size_t keysize = 0;
   7.132 -    stringlist_t* keylist = NULL;
   7.133 -    PEP_STATUS status = find_keys(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", &keylist);
   7.134 -    ASSERT_TRUE(keylist && keylist->value);
   7.135 -    ASSERT_STREQ(keylist->value, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39");
   7.136 -    free_stringlist(keylist);
   7.137 -    keylist = NULL;
   7.138 -
   7.139 -    bool has_private = false;
   7.140 -    contains_priv_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", &has_private);
   7.141 -    ASSERT_TRUE(has_private);
   7.142 -
   7.143 -    status = export_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39",
   7.144 -                                   &keydata, &keysize);
   7.145 -    ASSERT_EQ(status , PEP_STATUS_OK);
   7.146 -    ASSERT_NE(keydata, nullptr);
   7.147 -    ASSERT_GT(keysize, 0);
   7.148 -
   7.149 -    free(keydata);
   7.150 -    keydata = NULL;
   7.151 -    keysize = 0;
   7.152 -    status = export_secret_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39",
   7.153 -                                   &keydata, &keysize);
   7.154 -    ASSERT_EQ(status , PEP_STATUS_OK);
   7.155 -
   7.156 -    free(keydata);
   7.157 -}
   7.158 -
   7.159 -
   7.160 -TEST_F(ExportKeyTest, check_export_key_no_secret_key) {
   7.161 -    // Own pub key
   7.162 -    ASSERT_TRUE(slurp_and_import_key(session, "test_keys/pub/pep-test-bob-0xC9C2EE39_pub.asc"\)\);
   7.163 -
   7.164 -    char* keydata = NULL;
   7.165 -    size_t keysize = 0;
   7.166 -    stringlist_t* keylist = NULL;
   7.167 -    PEP_STATUS status = find_keys(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", &keylist);
   7.168 -    ASSERT_TRUE(keylist && keylist->value);
   7.169 -    ASSERT_STREQ(keylist->value, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39");
   7.170 -
   7.171 -    status = export_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39",
   7.172 -                                   &keydata, &keysize);
   7.173 -    ASSERT_EQ(status , PEP_STATUS_OK);
   7.174 -    free(keydata);
   7.175 -    keydata = NULL;
   7.176 -    keysize = 0;
   7.177 -    status = export_secret_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39",
   7.178 -                                   &keydata, &keysize);
   7.179 -    ASSERT_EQ(status , PEP_KEY_NOT_FOUND);
   7.180 -    free(keydata);
   7.181 -}
     8.1 --- a/src/message_api.c	Fri Aug 23 09:02:09 2019 +0200
     8.2 +++ b/src/message_api.c	Mon Aug 26 10:49:04 2019 +0200
     8.3 @@ -3935,9 +3935,7 @@
     8.4      if (reencrypt) {
     8.5          if (decrypt_status == PEP_DECRYPTED || decrypt_status == PEP_DECRYPTED_AND_VERIFIED) {
     8.6              const char* sfpr = NULL;
     8.7 -            if (!EMPTYSTR(msg->_sender_fpr))
     8.8 -                sfpr = msg->_sender_fpr;
     8.9 -            else if (_keylist != NULL && !(EMPTYSTR(_keylist->value)))
    8.10 +            if (_keylist != NULL && !(EMPTYSTR(_keylist->value)))
    8.11                  sfpr = _keylist->value;
    8.12               
    8.13              if (sfpr && decrypt_status == PEP_DECRYPTED_AND_VERIFIED) {
     9.1 --- a/test/include/test_util.h	Fri Aug 23 09:02:09 2019 +0200
     9.2 +++ b/test/include/test_util.h	Mon Aug 26 10:49:04 2019 +0200
     9.3 @@ -16,6 +16,8 @@
     9.4  
     9.5  extern std::string _main_test_home_dir;
     9.6  
     9.7 +std::string get_main_test_home_dir();
     9.8 +
     9.9  typedef enum _pEp_test_ident_preset {
    9.10      ALICE,
    9.11      APPLE,
    10.1 --- a/test/src/engine_tests/ReencryptPlusExtraKeysTests.cc	Fri Aug 23 09:02:09 2019 +0200
    10.2 +++ b/test/src/engine_tests/ReencryptPlusExtraKeysTests.cc	Mon Aug 26 10:49:04 2019 +0200
    10.3 @@ -551,6 +551,9 @@
    10.4      TEST_ASSERT(dec_msg != NULL);
    10.5      TEST_ASSERT((flags & PEP_decrypt_flag_src_modified) == 0);
    10.6      TEST_ASSERT(enc_msg != NULL);
    10.7 +    TEST_ASSERT(dec_msg->_sender_fpr);
    10.8 +    TEST_ASSERT(keys);
    10.9 +    TEST_ASSERT(strcmp(dec_msg->_sender_fpr, keys->value) != 0);
   10.10      
   10.11      cout << "PASS: Test 1" << endl << endl;
   10.12      
   10.13 @@ -582,6 +585,10 @@
   10.14      TEST_ASSERT(dec_msg != NULL);
   10.15      TEST_ASSERT((flags & PEP_decrypt_flag_src_modified) == 0);
   10.16      TEST_ASSERT(enc_msg != NULL);
   10.17 +    TEST_ASSERT(dec_msg->_sender_fpr);
   10.18 +    TEST_ASSERT(keys);
   10.19 +    TEST_ASSERT(strcmp(dec_msg->_sender_fpr, keys->value) != 0);
   10.20 +
   10.21      
   10.22      cout << "PASS: Test 2" << endl << endl;
   10.23                                    
   10.24 @@ -614,7 +621,10 @@
   10.25      TEST_ASSERT(dec_msg != NULL);
   10.26      TEST_ASSERT((flags & PEP_decrypt_flag_src_modified) == 0);
   10.27      TEST_ASSERT(enc_msg != NULL);
   10.28 -    
   10.29 +    TEST_ASSERT(dec_msg->_sender_fpr);
   10.30 +    TEST_ASSERT(keys);
   10.31 +    TEST_ASSERT(strcmp(dec_msg->_sender_fpr, keys->value) != 0);
   10.32 +        
   10.33      cout << "PASS: Test 3" << endl << endl;                              
   10.34  
   10.35  }