mirror of
https://github.com/ceph/s3-tests.git
synced 2025-03-29 09:03:51 +00:00
rgw/s3-test: adding test to set, get, delete and then get
a bucket policy to ensure that delete correctly removes the bucket policy Signed-off-by: Pritha Srivastava <prsrivas@redhat.com>
This commit is contained in:
parent
d245097771
commit
3fa3367190
1 changed files with 37 additions and 0 deletions
|
@ -10912,6 +10912,43 @@ def test_bucket_policy_set_condition_operator_end_with_IfExists():
|
||||||
response = client.get_bucket_policy(Bucket=bucket_name)
|
response = client.get_bucket_policy(Bucket=bucket_name)
|
||||||
print(response)
|
print(response)
|
||||||
|
|
||||||
|
@pytest.mark.bucket_policy
|
||||||
|
def test_set_get_del_bucket_policy():
|
||||||
|
bucket_name = get_new_bucket()
|
||||||
|
client = get_client()
|
||||||
|
key = 'asdf'
|
||||||
|
client.put_object(Bucket=bucket_name, Key=key, Body='asdf')
|
||||||
|
|
||||||
|
resource1 = "arn:aws:s3:::" + bucket_name
|
||||||
|
resource2 = "arn:aws:s3:::" + bucket_name + "/*"
|
||||||
|
policy_document = json.dumps(
|
||||||
|
{
|
||||||
|
"Version": "2012-10-17",
|
||||||
|
"Statement": [{
|
||||||
|
"Effect": "Allow",
|
||||||
|
"Principal": {"AWS": "*"},
|
||||||
|
"Action": "s3:ListBucket",
|
||||||
|
"Resource": [
|
||||||
|
"{}".format(resource1),
|
||||||
|
"{}".format(resource2)
|
||||||
|
]
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
client.put_bucket_policy(Bucket=bucket_name, Policy=policy_document)
|
||||||
|
|
||||||
|
response = client.get_bucket_policy(Bucket=bucket_name)
|
||||||
|
response_policy = response['Policy']
|
||||||
|
assert policy_document == response_policy
|
||||||
|
|
||||||
|
client.delete_bucket_policy(Bucket=bucket_name)
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = client.get_bucket_policy(Bucket=bucket_name)
|
||||||
|
except botocore.exceptions.ClientError as e:
|
||||||
|
print (e)
|
||||||
|
assert e.response['Error']['Code'] == 'NoSuchBucketPolicy'
|
||||||
|
|
||||||
def _create_simple_tagset(count):
|
def _create_simple_tagset(count):
|
||||||
tagset = []
|
tagset = []
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
|
|
Loading…
Add table
Reference in a new issue