Skip to content

Commit

Permalink
Merge pull request #3507 from aws/muhamoth/fix#3500-NewerNoncurrentVe…
Browse files Browse the repository at this point in the history
…rsions-PutLifecycleConfigurationRequestMarshaller

fix: #3500 Add missing NewerNoncurrentVersions to PutLifecycleConfigurationRequestMarshall
  • Loading branch information
muhammad-othman authored Oct 15, 2024
2 parents 18a62e4 + 70a6e1b commit eb687e4
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 16 deletions.
11 changes: 11 additions & 0 deletions generator/.DevConfigs/78e0b691-e434-47d4-9e53-d63e12ae1407.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"services": [
{
"serviceName": "S3",
"type": "patch",
"changeLogMessages": [
"fix: Add missing NewerNoncurrentVersions to PutLifecycleConfigurationRequestMarshall"
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public IRequest Marshall(PutLifecycleConfigurationRequest putLifecycleConfigurat
request.AddSubResource("lifecycle");

var stringWriter = new XMLEncodedStringWriter(System.Globalization.CultureInfo.InvariantCulture);
using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings(){Encoding = Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize }))
using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize }))
{
var lifecycleConfigurationLifecycleConfiguration = putLifecycleConfigurationRequest.Configuration;
if (lifecycleConfigurationLifecycleConfiguration != null)
Expand Down Expand Up @@ -137,6 +137,10 @@ public IRequest Marshall(PutLifecycleConfigurationRequest putLifecycleConfigurat
if (noncurrentVersionTransition != null)
{
xmlWriter.WriteStartElement("NoncurrentVersionTransition");
if (noncurrentVersionTransition.IsSetNewerNoncurrentVersions())
{
xmlWriter.WriteElementString("NewerNoncurrentVersions", S3Transforms.ToXmlStringValue(noncurrentVersionTransition.NewerNoncurrentVersions));
}
if (noncurrentVersionTransition.IsSetNoncurrentDays())
{
xmlWriter.WriteElementString("NoncurrentDays", S3Transforms.ToXmlStringValue(noncurrentVersionTransition.NoncurrentDays));
Expand Down
50 changes: 35 additions & 15 deletions sdk/test/Services/S3/IntegrationTests/LifecycleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
Expand Down Expand Up @@ -97,9 +97,13 @@ public void LifecycleTest()
{
new LifecycleRule
{
#pragma warning disable 618
Prefix = "rule1-",
#pragma warning restore 618
Filter = new LifecycleFilter
{
LifecycleFilterPredicate = new LifecyclePrefixPredicate()
{
Prefix = "rule1-"
}
},
Status = LifecycleRuleStatus.Enabled,
Expiration = new LifecycleRuleExpiration
{
Expand All @@ -114,6 +118,7 @@ public void LifecycleTest()
NoncurrentVersionTransition = new LifecycleRuleNoncurrentVersionTransition
{
NoncurrentDays = 14,
NewerNoncurrentVersions = 10,
StorageClass = S3StorageClass.Glacier
},
#pragma warning restore 618
Expand All @@ -124,9 +129,13 @@ public void LifecycleTest()
},
new LifecycleRule
{
#pragma warning disable 618
Prefix = "rule2-",
#pragma warning restore 618
Filter = new LifecycleFilter
{
LifecycleFilterPredicate = new LifecyclePrefixPredicate()
{
Prefix = "rule2-"
}
},
Expiration = new LifecycleRuleExpiration
{
Days = 120
Expand All @@ -149,21 +158,27 @@ public void LifecycleTest()
new LifecycleRuleNoncurrentVersionTransition
{
NoncurrentDays = 30,
NewerNoncurrentVersions = 20,
StorageClass = S3StorageClass.StandardInfrequentAccess
},
new LifecycleRuleNoncurrentVersionTransition
{
NoncurrentDays = 90,
NewerNoncurrentVersions = 50,
StorageClass = S3StorageClass.Glacier
}
}
},
new LifecycleRule
{
#pragma warning disable 618
Prefix = "rule3-",
#pragma warning restore 618
Expiration = new LifecycleRuleExpiration
Filter = new LifecycleFilter
{
LifecycleFilterPredicate = new LifecyclePrefixPredicate()
{
Prefix = "rule3-"
}
},
Expiration = new LifecycleRuleExpiration
{
ExpiredObjectDeleteMarker = true
},
Expand All @@ -185,11 +200,13 @@ public void LifecycleTest()
new LifecycleRuleNoncurrentVersionTransition
{
NoncurrentDays = 30,
NewerNoncurrentVersions = 60,
StorageClass = S3StorageClass.StandardInfrequentAccess
},
new LifecycleRuleNoncurrentVersionTransition
{
NoncurrentDays = 90,
NewerNoncurrentVersions = 70,
StorageClass = S3StorageClass.Glacier
}
}
Expand All @@ -202,7 +219,7 @@ public void LifecycleTest()
BucketName = bucketName,
Configuration = configuration
});

s3Configuration = S3TestUtils.WaitForConsistency(() =>
{
var res = Client.GetLifecycleConfiguration(bucketName);
Expand All @@ -213,7 +230,7 @@ public void LifecycleTest()
Assert.IsNotNull(s3Configuration);
Assert.IsNotNull(s3Configuration.Rules);
Assert.AreEqual(configuration.Rules.Count, s3Configuration.Rules.Count);
for(int i=0;i<configuration.Rules.Count;i++)
for (int i = 0; i < configuration.Rules.Count; i++)
{
var s3Rule = s3Configuration.Rules[i];
var rule = configuration.Rules[i];
Expand Down Expand Up @@ -414,7 +431,7 @@ private static void TestLifecycleFilterPredicate(LifecycleFilterPredicate predic
}
}
});

var actualConfig = S3TestUtils.WaitForConsistency(() =>
{
var res = client.GetLifecycleConfiguration(bucketName);
Expand Down Expand Up @@ -475,6 +492,9 @@ private static void AssertRulesAreEqual(LifecycleRule expected, LifecycleRule ac
{
Assert.AreEqual(expected.NoncurrentVersionTransition.NoncurrentDays,
actual.NoncurrentVersionTransition.NoncurrentDays);

Assert.AreEqual(expected.NoncurrentVersionTransition.NewerNoncurrentVersions,
actual.NoncurrentVersionTransition.NewerNoncurrentVersions);
}
#pragma warning restore 618
}
Expand All @@ -491,7 +511,7 @@ private static void AssertFiltersAreEqual(LifecycleFilter expected, LifecycleFil
}
}

private static void AssertPredicatesAreEqual(LifecycleFilterPredicate expected, LifecycleFilterPredicate actual)
private static void AssertPredicatesAreEqual(LifecycleFilterPredicate expected, LifecycleFilterPredicate actual)
{
Assert.IsNotNull(expected);
Assert.IsNotNull(actual);
Expand Down

0 comments on commit eb687e4

Please sign in to comment.