19
from base import S3TestCase, get_env_s3_client
22
'"Version": "2012-10-17", ' \
25
'"Effect": "Allow",' \
26
'"Principal": {"AWS": ["arn:aws:iam::123456789012:root"]}, ' \
27
'"Action": ["s3:PutObject"], ' \
28
'"Resource": ["arn:aws:s3:::' + env.BUCKET + '/*" ] ' \
32
class PolicyTest(S3TestCase):
35
def __init__(self, case):
36
super(PolicyTest, self).__init__(case)
37
self.s3 = get_env_s3_client()
39
def test_policy_set(self):
42
result=self.s3.get_bucket_policy(Bucket=env.BUCKET)
43
except Exception as e:
44
self.assert_client_error(error=e, expect_status_code=404)
46
self.assert_result_status_code(
47
result=self.s3.put_bucket_policy(Bucket=env.BUCKET, Policy=POLICY), status_code=204)
49
self.assert_get_bucket_policy_result(
50
result=self.s3.get_bucket_policy(Bucket=env.BUCKET), policy=json.loads(POLICY))
52
self.assert_result_status_code(
53
result=self.s3.delete_bucket_policy(Bucket=env.BUCKET), status_code=204)
56
result=self.s3.get_bucket_policy(Bucket=env.BUCKET)
57
except Exception as e:
58
self.assert_client_error(error=e, expect_status_code=404)