Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s3: test that object lock can be enabled on an existing bucket #622

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions s3tests_boto3/functional/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -12360,6 +12360,35 @@ def test_object_lock_put_obj_lock_invalid_bucket():
assert status == 409
assert error_code == 'InvalidBucketState'

def test_object_lock_put_obj_lock_enable_after_create():
bucket_name = get_new_bucket_name()
client = get_client()
client.create_bucket(Bucket=bucket_name)
conf = {'ObjectLockEnabled':'Enabled',
'Rule': {
'DefaultRetention':{
'Mode':'GOVERNANCE',
'Days':1
}
}}

# fail if bucket is not versioned
e = assert_raises(ClientError, client.put_object_lock_configuration, Bucket=bucket_name, ObjectLockConfiguration=conf)
status, error_code = _get_status_and_error_code(e.response)
assert status == 409
assert error_code == 'InvalidBucketState'

# fail if versioning is suspended
check_configure_versioning_retry(bucket_name, "Suspended", "Suspended")
e = assert_raises(ClientError, client.put_object_lock_configuration, Bucket=bucket_name, ObjectLockConfiguration=conf)
status, error_code = _get_status_and_error_code(e.response)
assert status == 409
assert error_code == 'InvalidBucketState'

# enable object lock if versioning is enabled
check_configure_versioning_retry(bucket_name, "Enabled", "Enabled")
response = client.put_object_lock_configuration(Bucket=bucket_name, ObjectLockConfiguration=conf)
assert response['ResponseMetadata']['HTTPStatusCode'] == 200

@pytest.mark.fails_on_dbstore
def test_object_lock_put_obj_lock_with_days_and_years():
Expand Down