From d8adabdf386379e452c9f16932a0cf3a89f927dc Mon Sep 17 00:00:00 2001 From: Peter Song Date: Tue, 29 Oct 2024 15:27:49 -0700 Subject: [PATCH 1/2] Remove disabletrimmingleadingslash flag for copyobject and copypart operations --- .../2869e4ae-e992-4bb7-938e-fed27e1b1d47.json | 11 +++++++++++ .../Services/S3/Custom/Model/CopyObjectRequest.cs | 11 ----------- sdk/src/Services/S3/Custom/Model/CopyPartRequest.cs | 10 ---------- .../CopyObjectRequestMarshaller.cs | 12 +++--------- .../CopyPartRequestMarshaller.cs | 12 +++--------- .../IntegrationTests/S3/CopyObjectTests.cs | 10 ++++------ .../Services/S3/IntegrationTests/CopyObjectTests.cs | 9 ++++----- .../Services/S3/IntegrationTests/CopyPartTests.cs | 1 - 8 files changed, 25 insertions(+), 51 deletions(-) create mode 100644 generator/.DevConfigs/2869e4ae-e992-4bb7-938e-fed27e1b1d47.json diff --git a/generator/.DevConfigs/2869e4ae-e992-4bb7-938e-fed27e1b1d47.json b/generator/.DevConfigs/2869e4ae-e992-4bb7-938e-fed27e1b1d47.json new file mode 100644 index 000000000000..1d2e45eb6c09 --- /dev/null +++ b/generator/.DevConfigs/2869e4ae-e992-4bb7-938e-fed27e1b1d47.json @@ -0,0 +1,11 @@ +{ + "services": [ + { + "serviceName": "S3", + "type": "patch", + "changeLogMessages": [ + "Remove the DisableTrimmingLeadingSlash flag for CopyObject and CopyPart operations. The SDK will no longer trim leading slashes." + ] + } + ] +} diff --git a/sdk/src/Services/S3/Custom/Model/CopyObjectRequest.cs b/sdk/src/Services/S3/Custom/Model/CopyObjectRequest.cs index 96d14ea6cda7..cb0cc3773227 100644 --- a/sdk/src/Services/S3/Custom/Model/CopyObjectRequest.cs +++ b/sdk/src/Services/S3/Custom/Model/CopyObjectRequest.cs @@ -245,7 +245,6 @@ public partial class CopyObjectRequest : PutWithACLRequest private string copySourceServerSideEncryptionCustomerProvidedKeyMD5; private TaggingDirective taggingDirective; - private bool disableTrimmingLeadingSlash = false; /// /// A canned access control list (CACL) to apply to the object. @@ -1189,16 +1188,6 @@ internal bool IsSetChecksumAlgorithm() return this._checksumAlgorithm != null; } - /// - /// If this is set to true then the Amazon S3 client will not remove leading slashes from and . - /// The default value is false. - /// - public bool DisableTrimmingLeadingSlash - { - get { return this.disableTrimmingLeadingSlash; } - set { this.disableTrimmingLeadingSlash = value; } - } - /// /// Specifies whether the object tag-set is copied from the source object or replaced with the tag-set that's provided in the request. /// diff --git a/sdk/src/Services/S3/Custom/Model/CopyPartRequest.cs b/sdk/src/Services/S3/Custom/Model/CopyPartRequest.cs index c6075c78de6c..0a1c3d18cee5 100644 --- a/sdk/src/Services/S3/Custom/Model/CopyPartRequest.cs +++ b/sdk/src/Services/S3/Custom/Model/CopyPartRequest.cs @@ -246,7 +246,6 @@ public partial class CopyPartRequest : AmazonWebServiceRequest private string copySourceServerSideEncryptionCustomerProvidedKey; private string copySourceServerSideEncryptionCustomerProvidedKeyMD5; - private bool disableTrimmingLeadingSlash = false; /// /// The name of the bucket containing the object to copy. @@ -823,14 +822,5 @@ internal bool IsSetRequestPayer() return requestPayer != null; } - /// - /// If this is set to true then the Amazon S3 client will not remove leading slashes from and . - /// The default value is false. - /// - public bool DisableTrimmingLeadingSlash - { - get { return this.disableTrimmingLeadingSlash; } - set { this.disableTrimmingLeadingSlash = value; } - } } } diff --git a/sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/CopyObjectRequestMarshaller.cs b/sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/CopyObjectRequestMarshaller.cs index c07bdb80d302..f4533e628ae4 100644 --- a/sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/CopyObjectRequestMarshaller.cs +++ b/sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/CopyObjectRequestMarshaller.cs @@ -36,15 +36,9 @@ public IRequest Marshall(Amazon.Runtime.AmazonWebServiceRequest input) public IRequest Marshall(CopyObjectRequest copyObjectRequest) { - var sourceKey = - copyObjectRequest.DisableTrimmingLeadingSlash || string.IsNullOrEmpty(copyObjectRequest.SourceKey) ? - copyObjectRequest.SourceKey : - AmazonS3Util.RemoveLeadingSlash(copyObjectRequest.SourceKey); - - var destinationKey = - copyObjectRequest.DisableTrimmingLeadingSlash || string.IsNullOrEmpty(copyObjectRequest.DestinationKey) ? - copyObjectRequest.DestinationKey: - AmazonS3Util.RemoveLeadingSlash(copyObjectRequest.DestinationKey); + var sourceKey = copyObjectRequest.SourceKey; + + var destinationKey = copyObjectRequest.DestinationKey; IRequest request = new DefaultRequest(copyObjectRequest, "AmazonS3"); diff --git a/sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/CopyPartRequestMarshaller.cs b/sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/CopyPartRequestMarshaller.cs index aa133eb461db..528463beb293 100644 --- a/sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/CopyPartRequestMarshaller.cs +++ b/sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/CopyPartRequestMarshaller.cs @@ -38,15 +38,9 @@ public IRequest Marshall(CopyPartRequest copyPartRequest) { IRequest request = new DefaultRequest(copyPartRequest, "AmazonS3"); - var sourceKey = - copyPartRequest.DisableTrimmingLeadingSlash ? - copyPartRequest.SourceKey : - AmazonS3Util.RemoveLeadingSlash(copyPartRequest.SourceKey); - - var destinationKey = - copyPartRequest.DisableTrimmingLeadingSlash ? - copyPartRequest.DestinationKey : - AmazonS3Util.RemoveLeadingSlash(copyPartRequest.DestinationKey); + var sourceKey = copyPartRequest.SourceKey; + + var destinationKey = copyPartRequest.DestinationKey; request.HttpMethod = "PUT"; diff --git a/sdk/test/NetStandard/IntegrationTests/IntegrationTests/S3/CopyObjectTests.cs b/sdk/test/NetStandard/IntegrationTests/IntegrationTests/S3/CopyObjectTests.cs index e4ec33572fae..8191a9fd6460 100644 --- a/sdk/test/NetStandard/IntegrationTests/IntegrationTests/S3/CopyObjectTests.cs +++ b/sdk/test/NetStandard/IntegrationTests/IntegrationTests/S3/CopyObjectTests.cs @@ -42,11 +42,11 @@ protected override void Dispose(bool disposing) } [Theory] - [InlineData(false, testKey, "/destinationTestKey1.txt", "destinationTestKey1.txt")] - [InlineData(true, testKeyWithSlash, "/destinationTestKey2.txt", "/destinationTestKey2.txt")] - [InlineData(true, testKeyWithSlash, "/", "/")] + [InlineData(testKey, "/destinationTestKey1.txt", "/destinationTestKey1.txt")] + [InlineData(testKeyWithSlash, "/destinationTestKey2.txt", "/destinationTestKey2.txt")] + [InlineData(testKeyWithSlash, "/", "/")] [Trait(CategoryAttribute, "S3")] - public async Task CopyObjectTestWithLeadingSlash(bool disableTrimmingLeadingSlash, string sourceKey, string destinationKey, string expectedKey) + public async Task CopyObjectTestWithLeadingSlash(string sourceKey, string destinationKey, string expectedKey) { var copyResponse = await Client.CopyObjectAsync(new CopyObjectRequest { @@ -55,8 +55,6 @@ public async Task CopyObjectTestWithLeadingSlash(bool disableTrimmingLeadingSlas DestinationBucket = bucketName, DestinationKey = destinationKey, - - DisableTrimmingLeadingSlash = disableTrimmingLeadingSlash }); Assert.Equal(HttpStatusCode.OK, copyResponse.HttpStatusCode); diff --git a/sdk/test/Services/S3/IntegrationTests/CopyObjectTests.cs b/sdk/test/Services/S3/IntegrationTests/CopyObjectTests.cs index f3b3005d4522..7d28099845ca 100644 --- a/sdk/test/Services/S3/IntegrationTests/CopyObjectTests.cs +++ b/sdk/test/Services/S3/IntegrationTests/CopyObjectTests.cs @@ -157,12 +157,12 @@ public void TestCopyObjectWithTagsReplace() Assert.IsTrue(taggingMetadata.Tagging.Any(tag => tag.Key == "newtag1" && tag.Value == "1")); } - [DataRow(false, testKey, "/destinationTestKey1.txt", "destinationTestKey1.txt")] - [DataRow(true, testKeyWithSlash, "/destinationTestKey2.txt", "/destinationTestKey2.txt")] - [DataRow(true, testKeyWithSlash, "/", "/")] + [DataRow(testKey, "/destinationTestKey1.txt", "/destinationTestKey1.txt")] + [DataRow(testKeyWithSlash, "/destinationTestKey2.txt", "/destinationTestKey2.txt")] + [DataRow(testKeyWithSlash, "/", "/")] [DataTestMethod] [TestCategory("S3")] - public void TestCopyObjectWithLeadingSlash(bool disableTrimmingLeadingSlash, string sourceKey, string destinationKey, string expectedKey) + public void TestCopyObjectWithLeadingSlash(string sourceKey, string destinationKey, string expectedKey) { var copyObjectResponse = usEastClient.CopyObject(new CopyObjectRequest { @@ -172,7 +172,6 @@ public void TestCopyObjectWithLeadingSlash(bool disableTrimmingLeadingSlash, str DestinationBucket = westBucketName, DestinationKey = destinationKey, - DisableTrimmingLeadingSlash = disableTrimmingLeadingSlash }); Assert.AreEqual(HttpStatusCode.OK, copyObjectResponse.HttpStatusCode); diff --git a/sdk/test/Services/S3/IntegrationTests/CopyPartTests.cs b/sdk/test/Services/S3/IntegrationTests/CopyPartTests.cs index bab03faeefb5..79212bafade6 100644 --- a/sdk/test/Services/S3/IntegrationTests/CopyPartTests.cs +++ b/sdk/test/Services/S3/IntegrationTests/CopyPartTests.cs @@ -63,7 +63,6 @@ public void TestCopyPartWithLeadingSlash() UploadId = uploadId, PartNumber = 1, - DisableTrimmingLeadingSlash = true }); Assert.IsNotNull(copyPartResponse.ETag); Assert.IsTrue(copyPartResponse.ETag != null && copyPartResponse.ETag.Length > 0); From 29ce6b8c80bfb5e7967ee76dfb02e8ab02890093 Mon Sep 17 00:00:00 2001 From: Peter Song Date: Thu, 31 Oct 2024 09:59:21 -0700 Subject: [PATCH 2/2] tweak test code --- sdk/test/Services/S3/IntegrationTests/CopyObjectTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/test/Services/S3/IntegrationTests/CopyObjectTests.cs b/sdk/test/Services/S3/IntegrationTests/CopyObjectTests.cs index 7d28099845ca..f5026d03a0b4 100644 --- a/sdk/test/Services/S3/IntegrationTests/CopyObjectTests.cs +++ b/sdk/test/Services/S3/IntegrationTests/CopyObjectTests.cs @@ -157,7 +157,7 @@ public void TestCopyObjectWithTagsReplace() Assert.IsTrue(taggingMetadata.Tagging.Any(tag => tag.Key == "newtag1" && tag.Value == "1")); } - [DataRow(testKey, "/destinationTestKey1.txt", "/destinationTestKey1.txt")] + [DataRow(testKey, "destinationTestKey1.txt", "destinationTestKey1.txt")] [DataRow(testKeyWithSlash, "/destinationTestKey2.txt", "/destinationTestKey2.txt")] [DataRow(testKeyWithSlash, "/", "/")] [DataTestMethod]