1 #ifndef CERT_PROVIDER_TEST_H_
2 #define CERT_PROVIDER_TEST_H_
5 #include <unordered_map>
7 #include "test_utils.h"
17 Param(
const std::string& key,
ArgSet* arg_set) : key_(key), arg_set_(arg_set) {}
18 Param& operator=(
const std::string& val) {
19 arg_set_->arg_map_[key_] = val;
23 void clear() { arg_set_->arg_map_.erase(key_); }
26 const std::string key_;
32 Option(
const std::string& key,
ArgSet* arg_set) : key_(key), arg_set_(arg_set) {}
33 void set() { arg_set_->arg_set_.insert(key_); }
34 void clear() { arg_set_->arg_set_.erase(key_); }
37 const std::string key_;
42 Param fleetCA{
"--fleet-ca",
this};
43 Param fleetCAKey{
"--fleet-ca-key",
this};
44 Param localDir{
"--local",
this};
45 Param directoryPrefix{
"--directory",
this};
46 Param configFile{
"--config",
this};
47 Param validityDays{
"--days",
this};
48 Param countryCode{
"--certificate-c",
this};
49 Param state{
"--certificate-st",
this};
50 Param organization{
"--certificate-o",
this};
51 Param commonName{
"--certificate-cn",
this};
52 Param rsaBits{
"--bits",
this};
53 Param credentialFile{
"--credentials",
this};
55 Option provideRootCA{
"--root-ca",
this};
56 Option provideServerURL{
"--server-url",
this};
59 operator std::vector<std::string>()
const {
60 std::vector<std::string> res_vect;
62 for (
auto val_pair : arg_map_) {
63 res_vect.push_back(val_pair.first);
64 res_vect.push_back(val_pair.second);
67 for (
auto key : arg_set_) {
68 res_vect.push_back(key);
75 std::unordered_map<std::string, std::string> arg_map_;
76 std::set<std::string> arg_set_;
80 OutputPath(
const std::string& root_dir,
const std::string& prefix =
"/var/sota/import",
81 const std::string& private_key_file =
"pkey.pem",
const std::string& cert_file =
"client.pem")
83 privateKeyFile{private_key_file},
85 serverRootCA{
"root.crt"},
86 gtwURLFile{
"gateway.url"},
88 privateKeyFileFullPath{(rootDir / directory / privateKeyFile)},
89 certFileFullPath{rootDir / directory / certFile},
90 serverRootCAFullPath{rootDir / directory / serverRootCA},
91 gtwURLFileFullPath{rootDir / directory / gtwURLFile} {}
93 const std::string directory;
94 const std::string privateKeyFile;
95 const std::string certFile;
96 const std::string serverRootCA;
97 const std::string gtwURLFile;
99 const boost::filesystem::path rootDir;
100 const boost::filesystem::path privateKeyFileFullPath;
101 const boost::filesystem::path certFileFullPath;
102 const boost::filesystem::path serverRootCAFullPath;
103 const boost::filesystem::path gtwURLFileFullPath;
107 #endif // CERT_PROVIDER_TEST_H_