Add x-amz-expiration header in some S3 responses (#9667)

x-amz-expiration is described in the S3 specification as a header which
indicates if the object in question will expire any time in the future.
This commit is contained in:
Anis Elleuch
2020-05-21 22:12:52 +01:00
committed by GitHub
parent fade056244
commit cdf4815a6b
5 changed files with 87 additions and 7 deletions

View File

@@ -168,6 +168,35 @@ func TestMarshalLifecycleConfig(t *testing.T) {
}
}
func TestExpectedExpiryTime(t *testing.T) {
testCases := []struct {
modTime time.Time
days ExpirationDays
expected time.Time
}{
{
time.Date(2020, time.March, 15, 10, 10, 10, 0, time.UTC),
4,
time.Date(2020, time.March, 20, 0, 0, 0, 0, time.UTC),
},
{
time.Date(2020, time.March, 15, 0, 0, 0, 0, time.UTC),
1,
time.Date(2020, time.March, 17, 0, 0, 0, 0, time.UTC),
},
}
for i, tc := range testCases {
t.Run(fmt.Sprintf("Test %d", i+1), func(t *testing.T) {
got := expectedExpiryTime(tc.modTime, tc.days)
if got != tc.expected {
t.Fatalf("Expected %v to be equal to %v", got, tc.expected)
}
})
}
}
func TestComputeActions(t *testing.T) {
testCases := []struct {
inputConfig string