From 253b63aa11156a317e2f17590b6a718b17f40aa3 Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Mon, 14 Sep 2020 14:23:48 -0400 Subject: [PATCH] fix lifecycle expiration days: 0 In fact test_lifecycle_expiration_days0 is should fail, as 0-day expiration is permitted for transition rules but not expiration rules. Signed-off-by: Matt Benjamin --- s3tests_boto3/functional/test_s3.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/s3tests_boto3/functional/test_s3.py b/s3tests_boto3/functional/test_s3.py index a17cf88..c114bca 100644 --- a/s3tests_boto3/functional/test_s3.py +++ b/s3tests_boto3/functional/test_s3.py @@ -9126,21 +9126,18 @@ def test_lifecycle_expiration_days0(): bucket_name = _create_objects(keys=['days0/foo', 'days0/bar']) client = get_client() - rules=[{'Expiration': {'Days': 1}, 'ID': 'rule1', 'Prefix': 'days0/', 'Status':'Enabled'}] + rules=[{'Expiration': {'Days': 0}, 'ID': 'rule1', 'Prefix': 'days0/', 'Status':'Enabled'}] lifecycle = {'Rules': rules} - response = client.put_bucket_lifecycle_configuration(Bucket=bucket_name, LifecycleConfiguration=lifecycle) - eq(response['ResponseMetadata']['HTTPStatusCode'], 200) - - time.sleep(30) - - response = client.list_objects(Bucket=bucket_name) + # days: 0 is legal in a transition rule, but not legal in an + # expiration rule + response_code = "" try: - expire_objects = response['Contents'] - except KeyError: - expire_objects = [] + response = client.put_bucket_lifecycle_configuration(Bucket=bucket_name, LifecycleConfiguration=lifecycle) + except botocore.exceptions.ClientError as e: + response_code = e.response['Error']['Code'] - eq(len(expire_objects), 0) + eq(response_code, 'InvalidArgument') def setup_lifecycle_expiration(client, bucket_name, rule_id, delta_days,