From 102605a6a9b7e5c1eb0bc7285db2d5802a6d2dad Mon Sep 17 00:00:00 2001 From: pulimsr Date: Mon, 10 Nov 2025 11:15:11 -0500 Subject: [PATCH 1/7] fix/when s_preservePathSeparators enabled --- src/aws-cpp-sdk-core/include/aws/core/http/URI.h | 2 +- tests/aws-cpp-sdk-s3-unit-tests/S3UnitTests.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/aws-cpp-sdk-core/include/aws/core/http/URI.h b/src/aws-cpp-sdk-core/include/aws/core/http/URI.h index 894a57eff07..776c375ee85 100644 --- a/src/aws-cpp-sdk-core/include/aws/core/http/URI.h +++ b/src/aws-cpp-sdk-core/include/aws/core/http/URI.h @@ -153,7 +153,7 @@ namespace Aws { m_pathSegments.push_back(segment); } - m_pathHasTrailingSlash = (m_pathSegments.empty() || !s_preservePathSeparators) && (!segments.empty() && segments.back() == '/'); + m_pathHasTrailingSlash = s_preservePathSeparators ? (!segments.empty() && segments.back() == '/') : m_pathSegments.empty() && (!segments.empty() && segments.back() == '/'); } /** diff --git a/tests/aws-cpp-sdk-s3-unit-tests/S3UnitTests.cpp b/tests/aws-cpp-sdk-s3-unit-tests/S3UnitTests.cpp index 80bc663d3ed..ea543c3b471 100644 --- a/tests/aws-cpp-sdk-s3-unit-tests/S3UnitTests.cpp +++ b/tests/aws-cpp-sdk-s3-unit-tests/S3UnitTests.cpp @@ -226,7 +226,7 @@ TEST_F(S3UnitTest, S3UriPathPreservationOn) { auto putObjectRequest = PutObjectRequest() .WithBucket("velvetunderground") - .WithKey("////stephanie////says////////////that////////she//wants///////to/know.txt"); + .WithKey("////stephanie////says////////////that////////she//wants///////to/know.txt/"); std::shared_ptr body = Aws::MakeShared(ALLOCATION_TAG, "What country shall I say is calling From across the world?", @@ -247,7 +247,7 @@ TEST_F(S3UnitTest, S3UriPathPreservationOn) { AWS_EXPECT_SUCCESS(response); const auto seenRequest = _mockHttpClient->GetMostRecentHttpRequest(); - EXPECT_EQ("https://velvetunderground.s3.us-east-1.amazonaws.com/////stephanie////says////////////that////////she//wants///////to/know.txt", seenRequest.GetUri().GetURIString()); + EXPECT_EQ("https://velvetunderground.s3.us-east-1.amazonaws.com/////stephanie////says////////////that////////she//wants///////to/know.txt/", seenRequest.GetUri().GetURIString()); } TEST_F(S3UnitTest, S3EmbeddedErrorTest) { From 9a92054a7f512c20691517f32ef15553a6d33cb8 Mon Sep 17 00:00:00 2001 From: pulimsr Date: Mon, 10 Nov 2025 13:31:57 -0500 Subject: [PATCH 2/7] adding more paths to test --- .../aws-cpp-sdk-s3-unit-tests/S3UnitTests.cpp | 61 +++++++++++++------ 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/tests/aws-cpp-sdk-s3-unit-tests/S3UnitTests.cpp b/tests/aws-cpp-sdk-s3-unit-tests/S3UnitTests.cpp index ea543c3b471..3f9a45aa9ae 100644 --- a/tests/aws-cpp-sdk-s3-unit-tests/S3UnitTests.cpp +++ b/tests/aws-cpp-sdk-s3-unit-tests/S3UnitTests.cpp @@ -224,30 +224,53 @@ TEST_F(S3UnitTest, S3UriPathPreservationOn) { //Turn on path preservation Aws::Http::SetPreservePathSeparators(true); - auto putObjectRequest = PutObjectRequest() - .WithBucket("velvetunderground") - .WithKey("////stephanie////says////////////that////////she//wants///////to/know.txt/"); + struct TestCase { + const char* bucket; + const char* key; + const char* expectedUri; + }; - std::shared_ptr body = Aws::MakeShared(ALLOCATION_TAG, - "What country shall I say is calling From across the world?", - std::ios_base::in | std::ios_base::binary); + TestCase testCases[] = { + { + "velvetunderground", + "////stephanie////says////////////that////////she//wants///////to/know.txt", + "https://velvetunderground.s3.us-east-1.amazonaws.com/////stephanie////says////////////that////////she//wants///////to/know.txt" + }, + { + "velvetunderground", + "////stephanie////says////////////that////////she//wants///////to/know.txt/", + "https://velvetunderground.s3.us-east-1.amazonaws.com/////stephanie////says////////////that////////she//wants///////to/know.txt/" + }, + { + "velvetunderground", + "////stephanie////says////////////that////////she//wants///////to/know.txt//", + "https://velvetunderground.s3.us-east-1.amazonaws.com/////stephanie////says////////////that////////she//wants///////to/know.txt//" + } + }; - putObjectRequest.SetBody(body); + for (const auto& testCase : testCases) { + auto putObjectRequest = PutObjectRequest() + .WithBucket(testCase.bucket) + .WithKey(testCase.key); - //We have to mock requset because it is used to create the return body, it actually isnt used. - auto mockRequest = Aws::MakeShared(ALLOCATION_TAG, "mockuri", HttpMethod::HTTP_GET); - mockRequest->SetResponseStreamFactory([]() -> IOStream* { - return Aws::New(ALLOCATION_TAG, "response-string", std::ios_base::in | std::ios_base::binary); - }); - auto mockResponse = Aws::MakeShared(ALLOCATION_TAG, mockRequest); - mockResponse->SetResponseCode(HttpResponseCode::OK); - _mockHttpClient->AddResponseToReturn(mockResponse); + std::shared_ptr body = Aws::MakeShared(ALLOCATION_TAG, + "test content", std::ios_base::in | std::ios_base::binary); + putObjectRequest.SetBody(body); - const auto response = _s3Client->PutObject(putObjectRequest); - AWS_EXPECT_SUCCESS(response); + auto mockRequest = Aws::MakeShared(ALLOCATION_TAG, "mockuri", HttpMethod::HTTP_GET); + mockRequest->SetResponseStreamFactory([]() -> IOStream* { + return Aws::New(ALLOCATION_TAG, "response-string", std::ios_base::in | std::ios_base::binary); + }); + auto mockResponse = Aws::MakeShared(ALLOCATION_TAG, mockRequest); + mockResponse->SetResponseCode(HttpResponseCode::OK); + _mockHttpClient->AddResponseToReturn(mockResponse); - const auto seenRequest = _mockHttpClient->GetMostRecentHttpRequest(); - EXPECT_EQ("https://velvetunderground.s3.us-east-1.amazonaws.com/////stephanie////says////////////that////////she//wants///////to/know.txt/", seenRequest.GetUri().GetURIString()); + const auto response = _s3Client->PutObject(putObjectRequest); + AWS_EXPECT_SUCCESS(response); + + const auto seenRequest = _mockHttpClient->GetMostRecentHttpRequest(); + EXPECT_EQ(testCase.expectedUri, seenRequest.GetUri().GetURIString()); + } } TEST_F(S3UnitTest, S3EmbeddedErrorTest) { From 58f1f3308bf3c5e1c82085275f2ff3bd4fb39337 Mon Sep 17 00:00:00 2001 From: pulimsr Date: Tue, 11 Nov 2025 07:44:14 -0500 Subject: [PATCH 3/7] for testing --- src/aws-cpp-sdk-core/include/aws/core/http/URI.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aws-cpp-sdk-core/include/aws/core/http/URI.h b/src/aws-cpp-sdk-core/include/aws/core/http/URI.h index 776c375ee85..894a57eff07 100644 --- a/src/aws-cpp-sdk-core/include/aws/core/http/URI.h +++ b/src/aws-cpp-sdk-core/include/aws/core/http/URI.h @@ -153,7 +153,7 @@ namespace Aws { m_pathSegments.push_back(segment); } - m_pathHasTrailingSlash = s_preservePathSeparators ? (!segments.empty() && segments.back() == '/') : m_pathSegments.empty() && (!segments.empty() && segments.back() == '/'); + m_pathHasTrailingSlash = (m_pathSegments.empty() || !s_preservePathSeparators) && (!segments.empty() && segments.back() == '/'); } /** From 4c605dfafa0d9a323fc5fa7f9e39aeaf581bfaf9 Mon Sep 17 00:00:00 2001 From: pulimsr Date: Tue, 11 Nov 2025 09:58:35 -0500 Subject: [PATCH 4/7] adding fix back --- src/aws-cpp-sdk-core/include/aws/core/http/URI.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aws-cpp-sdk-core/include/aws/core/http/URI.h b/src/aws-cpp-sdk-core/include/aws/core/http/URI.h index 894a57eff07..776c375ee85 100644 --- a/src/aws-cpp-sdk-core/include/aws/core/http/URI.h +++ b/src/aws-cpp-sdk-core/include/aws/core/http/URI.h @@ -153,7 +153,7 @@ namespace Aws { m_pathSegments.push_back(segment); } - m_pathHasTrailingSlash = (m_pathSegments.empty() || !s_preservePathSeparators) && (!segments.empty() && segments.back() == '/'); + m_pathHasTrailingSlash = s_preservePathSeparators ? (!segments.empty() && segments.back() == '/') : m_pathSegments.empty() && (!segments.empty() && segments.back() == '/'); } /** From 22126ab2e7685f9e0ebc94b2e602df97b25687ba Mon Sep 17 00:00:00 2001 From: pulimsr Date: Tue, 11 Nov 2025 12:46:07 -0500 Subject: [PATCH 5/7] path-saparator --- src/aws-cpp-sdk-core/include/aws/core/http/URI.h | 2 +- src/aws-cpp-sdk-core/source/http/URI.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/aws-cpp-sdk-core/include/aws/core/http/URI.h b/src/aws-cpp-sdk-core/include/aws/core/http/URI.h index 776c375ee85..990bbc065c8 100644 --- a/src/aws-cpp-sdk-core/include/aws/core/http/URI.h +++ b/src/aws-cpp-sdk-core/include/aws/core/http/URI.h @@ -153,7 +153,7 @@ namespace Aws { m_pathSegments.push_back(segment); } - m_pathHasTrailingSlash = s_preservePathSeparators ? (!segments.empty() && segments.back() == '/') : m_pathSegments.empty() && (!segments.empty() && segments.back() == '/'); + m_pathHasTrailingSlash = !segments.empty() && segments.back() == '/'; } /** diff --git a/src/aws-cpp-sdk-core/source/http/URI.cpp b/src/aws-cpp-sdk-core/source/http/URI.cpp index daf5554b7a4..cd42bbcc386 100644 --- a/src/aws-cpp-sdk-core/source/http/URI.cpp +++ b/src/aws-cpp-sdk-core/source/http/URI.cpp @@ -206,7 +206,11 @@ Aws::String URI::GetPath() const path.append(segment); } - if (m_pathSegments.empty() || m_pathHasTrailingSlash) + if (m_pathSegments.empty()) + { + path.push_back('/'); + } + else if (m_pathHasTrailingSlash) { path.push_back('/'); } From f84ea56d16ef36af81526d79e088b107e01d663c Mon Sep 17 00:00:00 2001 From: pulimsr Date: Tue, 11 Nov 2025 16:42:39 -0500 Subject: [PATCH 6/7] revert unnecessary conditional split --- src/aws-cpp-sdk-core/source/http/URI.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/aws-cpp-sdk-core/source/http/URI.cpp b/src/aws-cpp-sdk-core/source/http/URI.cpp index cd42bbcc386..daf5554b7a4 100644 --- a/src/aws-cpp-sdk-core/source/http/URI.cpp +++ b/src/aws-cpp-sdk-core/source/http/URI.cpp @@ -206,11 +206,7 @@ Aws::String URI::GetPath() const path.append(segment); } - if (m_pathSegments.empty()) - { - path.push_back('/'); - } - else if (m_pathHasTrailingSlash) + if (m_pathSegments.empty() || m_pathHasTrailingSlash) { path.push_back('/'); } From ffe956988c6e5cfb113b2ea167e91d5d59169ab7 Mon Sep 17 00:00:00 2001 From: pulimsr Date: Wed, 12 Nov 2025 09:14:32 -0500 Subject: [PATCH 7/7] adding sns to integration test --- tools/scripts/run_integration_tests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/scripts/run_integration_tests.py b/tools/scripts/run_integration_tests.py index 5627fc35f55..cb46a95463f 100644 --- a/tools/scripts/run_integration_tests.py +++ b/tools/scripts/run_integration_tests.py @@ -44,6 +44,7 @@ def main(): "aws-cpp-sdk-dynamodb-integration-tests", "aws-cpp-sdk-sqs-integration-tests", "aws-cpp-sdk-sqs-unit-tests", + "aws-cpp-sdk-sns-integration-tests", "aws-cpp-sdk-s3-integration-tests", "aws-cpp-sdk-s3-unit-tests", "aws-cpp-sdk-s3-crt-integration-tests",