@@ -27,6 +27,7 @@ class AWSConfigTestSuite : public ::testing::Test
27
27
SaveEnvironmentVariable (" AWS_DEFAULT_REGION" );
28
28
SaveEnvironmentVariable (" AWS_REGION" );
29
29
SaveEnvironmentVariable (" AWS_EC2_METADATA_SERVICE_ENDPOINT" );
30
+ SaveEnvironmentVariable (" USE_REQUEST_COMPRESSION" );
30
31
31
32
Aws::StringStream ss;
32
33
ss << Aws::Auth::GetConfigProfileFilename () + " _blah" << std::this_thread::get_id ();
@@ -37,6 +38,7 @@ class AWSConfigTestSuite : public ::testing::Test
37
38
Aws::Environment::UnSetEnv (" AWS_DEFAULT_REGION" );
38
39
Aws::Environment::UnSetEnv (" AWS_REGION" );
39
40
Aws::Environment::UnSetEnv (" AWS_EC2_METADATA_SERVICE_ENDPOINT" );
41
+ Aws::Environment::UnSetEnv (" USE_REQUEST_COMPRESSION" );
40
42
41
43
auto profileDirectory = Aws::Auth::ProfileConfigFileAWSCredentialsProvider::GetProfileDirectory ();
42
44
Aws::FileSystem::CreateDirectoryIfNotExists (profileDirectory.c_str ());
@@ -115,6 +117,78 @@ TEST_F(AWSConfigTestSuite, TestClientConfigurationSetsRegionToProfile)
115
117
EXPECT_EQ (Aws::Region::US_WEST_2, config.region );
116
118
EXPECT_STREQ (" Dijkstra" , config.profileName .c_str ());
117
119
120
+ // cleanup
121
+ Aws::FileSystem::RemoveFileIfExists (m_configFileName.c_str ());
122
+ }
123
+
124
+ TEST_F (AWSConfigTestSuite, TestNoEnvNoConfigSetsUseRequestCompressionToTrue){
125
+ // create an empty config file
126
+ Aws::OFStream configFileNew (m_configFileName.c_str (), Aws::OFStream::out | Aws::OFStream::trunc);
127
+
128
+ configFileNew.flush ();
129
+ configFileNew.close ();
130
+ Aws::Config::ReloadCachedConfigFile ();
131
+
132
+ Aws::Client::ClientConfiguration config;
133
+
134
+ EXPECT_EQ (Aws::Client::UseRequestCompression::TRUE , config.useRequestCompression );
135
+
136
+ // cleanup
137
+ Aws::FileSystem::RemoveFileIfExists (m_configFileName.c_str ());
138
+ }
139
+
140
+ TEST_F (AWSConfigTestSuite, TestEnvToFalseAndNoConfigSetsUseRequestCompressionToFalse){
141
+ // Set Env variable
142
+ Aws::Environment::SetEnv (" USE_REQUEST_COMPRESSION" , " FALSE" , 1 /* overwrite*/ );
143
+ // create an empty config file
144
+ Aws::OFStream configFileNew (m_configFileName.c_str (), Aws::OFStream::out | Aws::OFStream::trunc);
145
+
146
+ configFileNew.flush ();
147
+ configFileNew.close ();
148
+ Aws::Config::ReloadCachedConfigFile ();
149
+
150
+ Aws::Client::ClientConfiguration config;
151
+
152
+ EXPECT_EQ (Aws::Client::UseRequestCompression::FALSE , config.useRequestCompression );
153
+
154
+ // cleanup
155
+ Aws::FileSystem::RemoveFileIfExists (m_configFileName.c_str ());
156
+ }
157
+
158
+ TEST_F (AWSConfigTestSuite, TestEnvToTrueAndConfigSetToFalseSetsUseRequestCompressionToTrue){
159
+ // Set Env variable
160
+ Aws::Environment::SetEnv (" USE_REQUEST_COMPRESSION" , " TRUE" , 1 /* overwrite*/ );
161
+ // create an empty config file
162
+ Aws::OFStream configFileNew (m_configFileName.c_str (), Aws::OFStream::out | Aws::OFStream::trunc);
163
+ configFileNew << " [profile Dijkstra]" << std::endl; // profile keyword is mandatory per specification
164
+ configFileNew << " use_request_compression = false" << std::endl;
165
+
166
+ configFileNew.flush ();
167
+ configFileNew.close ();
168
+ Aws::Config::ReloadCachedConfigFile ();
169
+
170
+ Aws::Client::ClientConfiguration config (" Dijkstra" );
171
+
172
+ EXPECT_EQ (Aws::Client::UseRequestCompression::TRUE , config.useRequestCompression );
173
+
174
+ // cleanup
175
+ Aws::FileSystem::RemoveFileIfExists (m_configFileName.c_str ());
176
+ }
177
+
178
+ TEST_F (AWSConfigTestSuite, TestNoEnvAndConfigSetToFalseSetsUseRequestCompressionToFalse){
179
+ // create an empty config file
180
+ Aws::OFStream configFileNew (m_configFileName.c_str (), Aws::OFStream::out | Aws::OFStream::trunc);
181
+ configFileNew << " [profile default]" << std::endl; // profile keyword is mandatory per specification
182
+ configFileNew << " use_request_compression = false" << std::endl;
183
+
184
+ configFileNew.flush ();
185
+ configFileNew.close ();
186
+ Aws::Config::ReloadCachedConfigFile ();
187
+
188
+ Aws::Client::ClientConfiguration config;
189
+
190
+ EXPECT_EQ (Aws::Client::UseRequestCompression::FALSE , config.useRequestCompression );
191
+
118
192
// cleanup
119
193
Aws::FileSystem::RemoveFileIfExists (m_configFileName.c_str ());
120
194
}
0 commit comments