@@ -224,30 +224,53 @@ TEST_F(S3UnitTest, S3UriPathPreservationOn) {
224224 // Turn on path preservation
225225 Aws::Http::SetPreservePathSeparators (true );
226226
227- auto putObjectRequest = PutObjectRequest ()
228- .WithBucket (" velvetunderground" )
229- .WithKey (" ////stephanie////says////////////that////////she//wants///////to/know.txt" );
227+ struct TestCase {
228+ const char * bucket;
229+ const char * key;
230+ const char * expectedUri;
231+ };
230232
231- std::shared_ptr<IOStream> body = Aws::MakeShared<StringStream>(ALLOCATION_TAG,
232- " What country shall I say is calling From across the world?" ,
233- std::ios_base::in | std::ios_base::binary);
233+ TestCase testCases[] = {
234+ {
235+ " velvetunderground" ,
236+ " ////stephanie////says////////////that////////she//wants///////to/know.txt" ,
237+ " https://velvetunderground.s3.us-east-1.amazonaws.com/////stephanie////says////////////that////////she//wants///////to/know.txt"
238+ },
239+ {
240+ " velvetunderground" ,
241+ " ////stephanie////says////////////that////////she//wants///////to/know.txt/" ,
242+ " https://velvetunderground.s3.us-east-1.amazonaws.com/////stephanie////says////////////that////////she//wants///////to/know.txt/"
243+ },
244+ {
245+ " velvetunderground" ,
246+ " ////stephanie////says////////////that////////she//wants///////to/know.txt//" ,
247+ " https://velvetunderground.s3.us-east-1.amazonaws.com/////stephanie////says////////////that////////she//wants///////to/know.txt//"
248+ }
249+ };
234250
235- putObjectRequest.SetBody (body);
251+ for (const auto & testCase : testCases) {
252+ auto putObjectRequest = PutObjectRequest ()
253+ .WithBucket (testCase.bucket )
254+ .WithKey (testCase.key );
236255
237- // We have to mock requset because it is used to create the return body, it actually isnt used.
238- auto mockRequest = Aws::MakeShared<Standard::StandardHttpRequest>(ALLOCATION_TAG, " mockuri" , HttpMethod::HTTP_GET);
239- mockRequest->SetResponseStreamFactory ([]() -> IOStream* {
240- return Aws::New<StringStream>(ALLOCATION_TAG, " response-string" , std::ios_base::in | std::ios_base::binary);
241- });
242- auto mockResponse = Aws::MakeShared<Standard::StandardHttpResponse>(ALLOCATION_TAG, mockRequest);
243- mockResponse->SetResponseCode (HttpResponseCode::OK);
244- _mockHttpClient->AddResponseToReturn (mockResponse);
256+ std::shared_ptr<IOStream> body = Aws::MakeShared<StringStream>(ALLOCATION_TAG,
257+ " test content" , std::ios_base::in | std::ios_base::binary);
258+ putObjectRequest.SetBody (body);
245259
246- const auto response = _s3Client->PutObject (putObjectRequest);
247- AWS_EXPECT_SUCCESS (response);
260+ auto mockRequest = Aws::MakeShared<Standard::StandardHttpRequest>(ALLOCATION_TAG, " mockuri" , HttpMethod::HTTP_GET);
261+ mockRequest->SetResponseStreamFactory ([]() -> IOStream* {
262+ return Aws::New<StringStream>(ALLOCATION_TAG, " response-string" , std::ios_base::in | std::ios_base::binary);
263+ });
264+ auto mockResponse = Aws::MakeShared<Standard::StandardHttpResponse>(ALLOCATION_TAG, mockRequest);
265+ mockResponse->SetResponseCode (HttpResponseCode::OK);
266+ _mockHttpClient->AddResponseToReturn (mockResponse);
248267
249- const auto seenRequest = _mockHttpClient->GetMostRecentHttpRequest ();
250- EXPECT_EQ (" https://velvetunderground.s3.us-east-1.amazonaws.com/////stephanie////says////////////that////////she//wants///////to/know.txt" , seenRequest.GetUri ().GetURIString ());
268+ const auto response = _s3Client->PutObject (putObjectRequest);
269+ AWS_EXPECT_SUCCESS (response);
270+
271+ const auto seenRequest = _mockHttpClient->GetMostRecentHttpRequest ();
272+ EXPECT_EQ (testCase.expectedUri , seenRequest.GetUri ().GetURIString ());
273+ }
251274}
252275
253276TEST_F (S3UnitTest, S3EmbeddedErrorTest) {
0 commit comments