ENGINE-427: commiting so I can go collect some old databases ENGINE-427
authorKrista Bennett <krista@pep-project.org>
Wed, 27 Jun 2018 16:42:07 +0200
branchENGINE-427
changeset 27730bca1887355e
parent 2765 a55905bf3925
child 2776 003ce543c234
ENGINE-427: commiting so I can go collect some old databases
test/include/EngineTestSuite.h
test/include/GPGConfFixTests.h
test/src/EngineTestSuite.cc
test/src/engine_tests/GPGConfFixTests.cc
     1.1 --- a/test/include/EngineTestSuite.h	Mon Jun 25 10:59:28 2018 +0200
     1.2 +++ b/test/include/EngineTestSuite.h	Wed Jun 27 16:42:07 2018 +0200
     1.3 @@ -38,8 +38,11 @@
     1.4          virtual void tear_down();
     1.5          
     1.6          void set_full_env();
     1.7 +	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.8          void restore_full_env();
     1.9          void initialise_test_home();
    1.10          void set_my_name();    
    1.11 +	
    1.12 +	void copy_conf_file_to_test_dir(const char* dest_path, const char* conf_orig_path, const char* conf_dest_name);
    1.13  };
    1.14  #endif
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/include/GPGConfFixTests.h	Wed Jun 27 16:42:07 2018 +0200
     2.3 @@ -0,0 +1,23 @@
     2.4 +// This file is under GNU General Public License 3.0
     2.5 +// see LICENSE.txt
     2.6 +
     2.7 +#ifndef G_P_G_CONF_FIX_H
     2.8 +#define G_P_G_CONF_FIX_H
     2.9 +
    2.10 +#include <string>
    2.11 +#include "EngineTestIndividualSuite.h"
    2.12 +
    2.13 +using namespace std;
    2.14 +
    2.15 +class GPGConfFixTests : public EngineTestIndividualSuite {
    2.16 +    public:
    2.17 +        GPGConfFixTests(string test_suite, string test_home_dir);
    2.18 +
    2.19 +    protected:
    2.20 +	void setup();
    2.21 +
    2.22 +    private:
    2.23 +        void check_g_p_g_conf_fix();
    2.24 +};
    2.25 +
    2.26 +#endif
     3.1 --- a/test/src/EngineTestSuite.cc	Mon Jun 25 10:59:28 2018 +0200
     3.2 +++ b/test/src/EngineTestSuite.cc	Wed Jun 27 16:42:07 2018 +0200
     3.3 @@ -5,6 +5,8 @@
     3.4  #include <unistd.h>
     3.5  #include <ftw.h>
     3.6  #include <assert.h>
     3.7 +#include <fstream>
     3.8 +#include <iostream>
     3.9  
    3.10  #include "platform_unix.h"
    3.11  
    3.12 @@ -30,7 +32,23 @@
    3.13      number_of_tests++;
    3.14  }
    3.15  
    3.16 +void EngineTestSuite::copy_conf_file_to_test_dir(const char* dest_path, const char* conf_orig_path, const char* conf_dest_name) {
    3.17 +    string conf_dest_path = dest_path + "/" + conf_dest_name;
    3.18 +    ifstream src(conf_orig_path);
    3.19 +    ofstream dst(conf_dest_path, ios::trunc);
    3.20 +    assert(src && dst);
    3.21 +    
    3.22 +    dst << src.rdbuf();
    3.23 +     
    3.24 +    src.close()
    3.25 +    dst.close();
    3.26 +}
    3.27 +
    3.28  void EngineTestSuite::set_full_env() {
    3.29 +    set_full_env(NULL, NULL, NULL);
    3.30 +}
    3.31 +
    3.32 +void EngineTestSuite::set_full_env(const char* gpg_conf_copy_path, const char* gpg_agent_conf_file_copy_path, const char* db_conf_file_copy_path) {
    3.33      int success = 0;
    3.34      struct stat dirchk;
    3.35      
    3.36 @@ -110,7 +128,14 @@
    3.37      success = setenv("HOME", temp_test_home.c_str(), 1);
    3.38      if (success != 0)
    3.39          throw std::runtime_error("SETUP: Cannot set test_home for init.");
    3.40 -    
    3.41 +
    3.42 +    if (gpg_conf_copy_path)
    3.43 +        copy_conf_file_to_test_dir(temp_test_home + "/.gnupg", gpg_conf_copy_path, "gpg.conf")
    3.44 +    if (gpg_agent_conf_file_copy_path)        
    3.45 +        copy_conf_file_to_test_dir(temp_test_home + "/.gnupg", gpg_agent_conf_file_copy_path, "gpg-agent.conf")
    3.46 +    if (db_conf_file_copy_path)
    3.47 +        copy copy_conf_file_to_test_dir(temp_test_home, db_conf_file_copy_path, ".pEp_management.db");
    3.48 +        
    3.49      unix_local_db(true);
    3.50      gpg_conf(true);
    3.51      gpg_agent_conf(true);
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/test/src/engine_tests/GPGConfFixTests.cc	Wed Jun 27 16:42:07 2018 +0200
     4.3 @@ -0,0 +1,23 @@
     4.4 +// This file is under GNU General Public License 3.0
     4.5 +// see LICENSE.txt
     4.6 +
     4.7 +#include <stdlib.h>
     4.8 +#include <string>
     4.9 +
    4.10 +#include "pEpEngine.h"
    4.11 +
    4.12 +#include "EngineTestIndividualSuite.h"
    4.13 +#include "GPGConfFixTests.h"
    4.14 +
    4.15 +using namespace std;
    4.16 +
    4.17 +GPGConfFixTests::GPGConfFixTests(string suitename, string test_home_dir) :
    4.18 +    EngineTestIndividualSuite::EngineTestIndividualSuite(suitename, test_home_dir) {
    4.19 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("GPGConfFixTests::check_g_p_g_conf_fix"),
    4.20 +                                                                      static_cast<Func>(&GPGConfFixTests::check_g_p_g_conf_fix)));
    4.21 +}
    4.22 +
    4.23 +void GPGConfFixTests::check_g_p_g_conf_fix() {
    4.24 +    TEST_ASSERT(true);
    4.25 +}
    4.26 +