Skip to content

Commit

Permalink
BucketPolicy: add test for sse-c in conditions
Browse files Browse the repository at this point in the history
Ref. ceph/ceph#58689

Signed-off-by: Seena Fallah <[email protected]>
  • Loading branch information
clwluvw committed Jul 19, 2024
1 parent 4eda9c0 commit 87b496f
Showing 1 changed file with 38 additions and 4 deletions.
42 changes: 38 additions & 4 deletions s3tests_boto3/functional/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -10077,6 +10077,44 @@ def test_encryption_sse_c_post_object_authenticated_request():
body = _get_body(response)
assert body == 'bar'


@pytest.mark.encryption
@pytest.mark.fails_on_dbstore
def test_encryption_sse_c_enforced_with_bucket_policy():
bucket_name = get_new_bucket()
client = get_client()

deny_incorrect_algo = {
"StringNotEquals": {
"s3:x-amz-server-side-encryption-customer-algorithm": "AES256"
}
}

deny_unencrypted_obj = {
"Null" : {
"s3:x-amz-server-side-encryption-customer-algorithm": "true"
}
}

p = Policy()
resource = _make_arn_resource("{}/{}".format(bucket_name, "*"))

s1 = Statement("s3:PutObject", resource, effect="Deny", condition=deny_incorrect_algo)
s2 = Statement("s3:PutObject", resource, effect="Deny", condition=deny_unencrypted_obj)
policy_document = p.add_statement(s1).add_statement(s2).to_json()

client.put_bucket_policy(Bucket=bucket_name, Policy=policy_document)

check_access_denied(client.put_object, Bucket=bucket_name, Key='foo', Body='bar')

client.put_object(
Bucket=bucket_name, Key='foo', Body='bar',
SSECustomerAlgorithm='AES256',
SSECustomerKey='pO3upElrwuEXSoFwCfnZPdSsmt/xWeFa0N9KgDijwVs=',
SSECustomerKeyMD5='DWygnHRtgiJ77HCm+1rvHw=='
)


@pytest.mark.encryption
@pytest.mark.fails_on_dbstore
def _test_sse_kms_customer_write(file_size, key_id = 'testkey-1'):
Expand All @@ -10102,10 +10140,6 @@ def _test_sse_kms_customer_write(file_size, key_id = 'testkey-1'):
assert body == data






@pytest.mark.encryption
@pytest.mark.fails_on_dbstore
def test_sse_kms_method_head():
Expand Down

0 comments on commit 87b496f

Please sign in to comment.