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:
[email protected]


With regards,
Apache Git Services

Reply via email to