15 #include <aws/core/client/ClientConfiguration.h> 18 #include <gtest/gtest.h> 21 #define CLIENT_CONFIG_PREFIX "aws_client_configuration" 22 #define USER_AGENT_SUFFIX "/user_agent" 32 config.region =
"uk-north-20";
34 config.proxyPort = 787;
36 config.connectTimeoutMs = 511111;
38 config.verifySSL =
true;
40 config.followRedirects =
true;
46 TEST(DefaultClientConfigurationProvider, getClientConfiguration)
48 Aws::Client::ClientConfiguration prepared_config;
52 auto parameter_reader = std::make_shared<Aws::Client::Ros1NodeParameterReader>();
54 Aws::Client::ClientConfiguration generated_config = config_provider.GetClientConfiguration();
55 prepared_config.userAgent =
59 prepared_config.followRedirects =
false;
60 ASSERT_NE(prepared_config, generated_config);
62 prepared_config.followRedirects =
true;
63 ASSERT_EQ(prepared_config, generated_config);
70 TEST(DefaultClientConfigurationProvider, userAgentTest)
72 Aws::Client::ClientConfiguration prepared_config;
75 auto parameter_reader = std::make_shared<Aws::Client::Ros1NodeParameterReader>();
79 std::vector<std::string> ros1_distros = {
"indigo",
"jade",
"kinetic",
"lunar",
"melodic"};
80 Aws::Client::ClientConfiguration generated_config = config_provider.GetClientConfiguration();
81 size_t ros_user_agent_index = std::string::npos;
82 for (
const auto & distro : ros1_distros) {
83 ros_user_agent_index =
84 generated_config.userAgent.find(std::string(
"exec-env/AWS_RoboMaker ros-" + distro).c_str());
85 if (std::string::npos != ros_user_agent_index) {
89 ASSERT_NE(std::string::npos, ros_user_agent_index);
92 const char version_override[] =
"1.12.16";
93 generated_config = config_provider.GetClientConfiguration(version_override);
94 ASSERT_EQ(0, generated_config.userAgent
95 .substr(generated_config.userAgent.size() - (
sizeof(version_override) - 1),
96 sizeof(version_override) - 1)
97 .compare(version_override));
100 Aws::Client::ClientConfiguration stock_config;
103 generated_config.userAgent.substr(0, ros_user_agent_index - 1).compare(stock_config.userAgent));
106 prepared_config.userAgent =
"my-user-agent";
107 std::string stored_user_agent;
112 generated_config = config_provider.GetClientConfiguration();
113 ASSERT_EQ(prepared_config, generated_config);
114 if (!stored_user_agent.empty()) {
121 int main(
int argc,
char ** argv)
123 testing::InitGoogleTest(&argc, argv);
124 ros::init(argc, argv,
"test_configuration_provider");
125 return RUN_ALL_TESTS();
bool deleteParam(const std::string &key) const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
int main(int argc, char **argv)
#define CLIENT_CONFIG_PREFIX
void InitializeNodeAndConfig(ros::NodeHandle &node, Aws::Client::ClientConfiguration &config)
#define USER_AGENT_SUFFIX
bool getParam(const std::string &key, std::string &s) const
bool hasParam(const std::string &key) const
void setParam(const std::string &key, const XmlRpc::XmlRpcValue &v) const
TEST(DefaultClientConfigurationProvider, getClientConfiguration)