You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/03/16 07:27:45 UTC
[GitHub] [airflow] potiuk commented on a change in pull request #7733:
[AIRFLOW-4175] S3Hook load_file should support ACL policy paramete
potiuk commented on a change in pull request #7733: [AIRFLOW-4175] S3Hook load_file should support ACL policy paramete
URL: https://github.com/apache/airflow/pull/7733#discussion_r392827374
##########
File path: tests/providers/amazon/aws/hooks/test_s3.py
##########
@@ -255,6 +284,31 @@ def test_load_file_gzip(self, s3_bucket):
resource = boto3.resource('s3').Object(s3_bucket, 'my_key') # pylint: disable=no-member
assert gz.decompress(resource.get()['Body'].read()) == b'Content'
+ def test_load_file_acl(self, s3_bucket):
+ hook = S3Hook()
+ with tempfile.NamedTemporaryFile() as temp_file:
+ temp_file.write(b"Content")
+ temp_file.seek(0)
+ hook.load_file(temp_file, "my_key", s3_bucket, gzip=True,
+ acl_policy='public-read')
+ response = boto3.client('s3').get_object_acl(Bucket=s3_bucket,
+ Key="my_key",
+ RequestPayer='requester') # pylint: disable=no-member # noqa: E501 # pylint: disable=C0301
+ assert ((response['Grants'][1]['Permission'] == 'READ') and
+ (response['Grants'][0]['Permission'] == 'FULL_CONTROL'))
+
+ def test_copy_object_acl(self, s3_bucket):
+ hook = S3Hook()
+ with tempfile.NamedTemporaryFile() as temp_file:
+ temp_file.write(b"Content")
+ temp_file.seek(0)
+ hook.load_file_obj(temp_file, "my_key", s3_bucket)
+ hook.copy_object("my_key", "my_key", s3_bucket, s3_bucket)
+ response = boto3.client('s3').get_object_acl(Bucket=s3_bucket,
+ Key="my_key",
+ RequestPayer='requester') # pylint: disable=no-member # noqa: E501 # pylint: disable=C0301
+ assert response['Grants'][0]['Permission'] == 'FULL_CONTROL'
Review comment:
One small thing - can you please check there are no more permissions here?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services