]> git.apps.os.sepia.ceph.com Git - s3-tests.git/commitdiff
add test coverage for DeleteBucketLifecycle
authorCasey Bodley <cbodley@redhat.com>
Fri, 25 Apr 2025 16:00:23 +0000 (12:00 -0400)
committerCasey Bodley <cbodley@redhat.com>
Wed, 30 Apr 2025 14:46:26 +0000 (10:46 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 886a769174bc3ca01243ffd0868037fc51a14892)

s3tests_boto3/functional/test_s3.py

index 529deb6039bdd9c80af4fdd905bd5ee766f5b189..ceeae050adde330bd8d4155b6b58f4cc6da84e2f 100644 (file)
@@ -8314,6 +8314,38 @@ def test_lifecycle_get():
     response = client.get_bucket_lifecycle_configuration(Bucket=bucket_name)
     assert response['Rules'] == rules
 
+@pytest.mark.lifecycle
+def test_lifecycle_delete():
+    client = get_client()
+    bucket_name = get_new_bucket(client)
+
+    e = assert_raises(ClientError, client.get_bucket_lifecycle_configuration, Bucket=bucket_name)
+    status, error_code = _get_status_and_error_code(e.response)
+    assert status == 404
+    assert error_code == 'NoSuchLifecycleConfiguration'
+
+    # returns 204 even if there is no lifecycle config
+    response = client.delete_bucket_lifecycle(Bucket=bucket_name)
+    assert response['ResponseMetadata']['HTTPStatusCode'] == 204
+
+    rules=[{'ID': 'test1/', 'Expiration': {'Days': 31}, 'Prefix': 'test1/', 'Status':'Enabled'},
+           {'ID': 'test2/', 'Expiration': {'Days': 120}, 'Prefix': 'test2/', 'Status':'Enabled'}]
+    lifecycle = {'Rules': rules}
+    client.put_bucket_lifecycle_configuration(Bucket=bucket_name, LifecycleConfiguration=lifecycle)
+    client.get_bucket_lifecycle_configuration(Bucket=bucket_name)
+
+    response = client.delete_bucket_lifecycle(Bucket=bucket_name)
+    assert response['ResponseMetadata']['HTTPStatusCode'] == 204
+
+    e = assert_raises(ClientError, client.get_bucket_lifecycle_configuration, Bucket=bucket_name)
+    status, error_code = _get_status_and_error_code(e.response)
+    assert status == 404
+    assert error_code == 'NoSuchLifecycleConfiguration'
+
+    # returns 204 even if there is no lifecycle config
+    response = client.delete_bucket_lifecycle(Bucket=bucket_name)
+    assert response['ResponseMetadata']['HTTPStatusCode'] == 204
+
 @pytest.mark.lifecycle
 def test_lifecycle_get_no_id():
     bucket_name = get_new_bucket()