ENGINE-427: fixed code mangled by revert. ENGINE-427
authorKrista Bennett <krista@pep-project.org>
Tue, 14 Aug 2018 10:00:48 +0200
branchENGINE-427
changeset 2823f56e57460c61
parent 2821 7fe5b66e570d
child 2824 34863e77a260
child 2827 b558a7d28ae2
ENGINE-427: fixed code mangled by revert.
test/include/EngineTestSuite.h
test/src/EngineTestSuite.cc
     1.1 --- a/test/include/EngineTestSuite.h	Tue Aug 14 08:55:46 2018 +0200
     1.2 +++ b/test/include/EngineTestSuite.h	Tue Aug 14 10:00:48 2018 +0200
     1.3 @@ -4,6 +4,8 @@
     1.4  #include <cpptest.h>
     1.5  #include <string>
     1.6  #include <map>
     1.7 +#include <vector>
     1.8 +#include <utility>
     1.9  #include "pEpEngine.h"
    1.10  
    1.11  using namespace std;
    1.12 @@ -40,11 +42,18 @@
    1.13          virtual void tear_down();
    1.14          
    1.15          void set_full_env();
    1.16 -	void set_full_env(const char* gpg_conf_copy_path, const char* gpg_agent_conf_file_copy_path, const char* db_conf_file_copy_path);
    1.17 +        void set_full_env(const char* gpg_conf_copy_path, const char* gpg_agent_conf_file_copy_path, const char* db_conf_file_copy_path);
    1.18          void restore_full_env();
    1.19          void initialise_test_home();
    1.20          void set_my_name();    
    1.21  	
    1.22 -	void copy_conf_file_to_test_dir(const char* dest_path, const char* conf_orig_path, const char* conf_dest_name);
    1.23 +        void copy_conf_file_to_test_dir(const char* dest_path, const char* conf_orig_path, const char* conf_dest_name);
    1.24 +        
    1.25 +        std::vector<std::pair<std::string, std::string>> gpgdir_fileadd_queue;
    1.26 +        std::vector<std::pair<std::string, std::string>> homedir_fileadd_queue;
    1.27 +        void add_file_to_gpg_dir_queue(std::string copy_from, std::string dst_fname);    
    1.28 +        void add_file_to_home_dir_queue(std::string copy_from, std::string dst_fname);
    1.29 +        void process_file_queue(std::string dirname, std::vector<std::pair<std::string, std::string>> file_queue);
    1.30 +
    1.31  };
    1.32  #endif
     2.1 --- a/test/src/EngineTestSuite.cc	Tue Aug 14 08:55:46 2018 +0200
     2.2 +++ b/test/src/EngineTestSuite.cc	Tue Aug 14 10:00:48 2018 +0200
     2.3 @@ -10,6 +10,10 @@
     2.4  #include <sys/types.h>
     2.5  #include <sys/stat.h>
     2.6  
     2.7 +#import <string>
     2.8 +#import <vector>
     2.9 +#include <utility>
    2.10 +
    2.11  #include "platform_unix.h"
    2.12  
    2.13  #include "test_util.h"
    2.14 @@ -60,6 +64,27 @@
    2.15      dst.close();
    2.16  }
    2.17  
    2.18 +void EngineTestSuite::add_file_to_gpg_dir_queue(string copy_from, string dst_fname) {    
    2.19 +    gpgdir_fileadd_queue.push_back(make_pair(copy_from, dst_fname));
    2.20 +}
    2.21 +
    2.22 +void EngineTestSuite::add_file_to_home_dir_queue(string copy_from, string dst_fname) {
    2.23 +    homedir_fileadd_queue.push_back(make_pair(copy_from, dst_fname));
    2.24 +}
    2.25 +
    2.26 +void EngineTestSuite::process_file_queue(string dirname, vector<pair<string, string>> file_queue) {
    2.27 +    if (file_queue.empty())
    2.28 +        return;
    2.29 +        
    2.30 +    vector<pair<string, string>>::iterator it;
    2.31 +    
    2.32 +    for (it = file_queue.begin(); it != file_queue.end(); it++) {
    2.33 +        copy_conf_file_to_test_dir(dirname.c_str(), it->first.c_str(), it->second.c_str());
    2.34 +    }
    2.35 +    
    2.36 +    file_queue.clear();
    2.37 +}
    2.38 +
    2.39  void EngineTestSuite::set_full_env() {
    2.40      set_full_env(NULL, NULL, NULL);
    2.41  }
    2.42 @@ -151,6 +176,11 @@
    2.43      if (success != 0)
    2.44          throw std::runtime_error("SETUP: Cannot set test_home for init.");
    2.45  
    2.46 +    string tmp_gpg_dir = temp_test_home + "/.gnupg";
    2.47 +
    2.48 +    process_file_queue(tmp_gpg_dir, gpgdir_fileadd_queue);
    2.49 +    process_file_queue(temp_test_home, homedir_fileadd_queue);
    2.50 +
    2.51      if (gpg_conf_copy_path)
    2.52          copy_conf_file_to_test_dir((temp_test_home + "/gnupg").c_str(), gpg_conf_copy_path, "gpg.conf");
    2.53      if (gpg_agent_conf_file_copy_path)