diff --git a/s3tests_boto3/functional/test_s3.py b/s3tests_boto3/functional/test_s3.py index c114bca..2925b59 100644 --- a/s3tests_boto3/functional/test_s3.py +++ b/s3tests_boto3/functional/test_s3.py @@ -9001,6 +9001,128 @@ def test_lifecycle_expiration_versioning_enabled(): eq(len(versions), 1) eq(len(delete_markers), 1) +@attr(resource='bucket') +@attr(method='put') +@attr(operation='test lifecycle expiration with 1 tag') +@attr('lifecycle') +@attr('lifecycle_expiration') +@attr('fails_on_aws') +def test_lifecycle_expiration_tags1(): + bucket_name = get_new_bucket() + client = get_client() + + tom_key = 'days1/tom' + tom_tagset = {'TagSet': + [{'Key': 'tom', 'Value': 'sawyer'}]} + + client.put_object(Bucket=bucket_name, Key=tom_key, Body='tom_body') + + response = client.put_object_tagging(Bucket=bucket_name, Key=tom_key, + Tagging=tom_tagset) + eq(response['ResponseMetadata']['HTTPStatusCode'], 200) + + lifecycle_config = { + 'Rules': [ + { + 'Expiration': { + 'Days': 1, + }, + 'ID': 'rule_tag1', + 'Filter': { + 'Prefix': 'days1/', + 'Tag': { + 'Key': 'tom', + 'Value': 'sawyer' + }, + }, + 'Status': 'Enabled', + }, + ] + } + + response = client.put_bucket_lifecycle_configuration( + Bucket=bucket_name, LifecycleConfiguration=lifecycle_config) + eq(response['ResponseMetadata']['HTTPStatusCode'], 200) + + time.sleep(28) + + try: + expire_objects = response['Contents'] + except KeyError: + expire_objects = [] + + eq(len(expire_objects), 0) + +@attr(resource='bucket') +@attr(method='put') +@attr(operation='test lifecycle expiration with 2 tags') +@attr('lifecycle') +@attr('lifecycle_expiration') +@attr('fails_on_aws') +def test_lifecycle_expiration_tags2(): + bucket_name = get_new_bucket() + client = get_client() + + tom_key = 'days1/tom' + tom_tagset = {'TagSet': + [{'Key': 'tom', 'Value': 'sawyer'}]} + + client.put_object(Bucket=bucket_name, Key=tom_key, Body='tom_body') + + response = client.put_object_tagging(Bucket=bucket_name, Key=tom_key, + Tagging=tom_tagset) + eq(response['ResponseMetadata']['HTTPStatusCode'], 200) + + huck_key = 'days1/huck' + huck_tagset = { + 'TagSet': + [{'Key': 'tom', 'Value': 'sawyer'}, + {'Key': 'huck', 'Value': 'finn'}]} + + client.put_object(Bucket=bucket_name, Key=huck_key, Body='huck_body') + + response = client.put_object_tagging(Bucket=bucket_name, Key=huck_key, + Tagging=huck_tagset) + eq(response['ResponseMetadata']['HTTPStatusCode'], 200) + + lifecycle_config = { + 'Rules': [ + { + 'Expiration': { + 'Days': 1, + }, + 'ID': 'rule_tag1', + 'Filter': { + 'Prefix': 'days1/', + 'Tag': { + 'Key': 'tom', + 'Value': 'sawyer' + }, + 'And': { + 'Prefix': 'days1', + 'Tags': [ + { + 'Key': 'huck', + 'Value': 'finn' + }, + ] + } + }, + 'Status': 'Enabled', + }, + ] + } + + response = client.put_bucket_lifecycle_configuration( + Bucket=bucket_name, LifecycleConfiguration=lifecycle_config) + eq(response['ResponseMetadata']['HTTPStatusCode'], 200) + + time.sleep(28) + response = client.list_objects(Bucket=bucket_name) + expire1_objects = response['Contents'] + + eq(len(expire1_objects), 1) + @attr(resource='bucket') @attr(method='put') @attr(operation='id too long in lifecycle rule')