Fix:s3 Presign Post with object acl (#3246)
* Fix:s3 Presign Post with object acl * Added import in tests Co-authored-by: usmankb <usman@krazybee.com>
This commit is contained in:
parent
3fb7cf75d4
commit
d2e16ecc2e
2 changed files with 37 additions and 0 deletions
|
|
@ -2800,6 +2800,39 @@ def test_put_bucket_acl_body():
|
|||
assert not result.get("Grants")
|
||||
|
||||
|
||||
@mock_s3
|
||||
def test_object_acl_with_presigned_post():
|
||||
s3 = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
|
||||
|
||||
bucket_name = "imageS3Bucket"
|
||||
object_name = "text.txt"
|
||||
fields = {"acl": "public-read"}
|
||||
file = open("text.txt", "w")
|
||||
file.write("test")
|
||||
file.close()
|
||||
|
||||
s3.create_bucket(Bucket=bucket_name)
|
||||
response = s3.generate_presigned_post(
|
||||
bucket_name, object_name, Fields=fields, ExpiresIn=60000
|
||||
)
|
||||
|
||||
with open(object_name, "rb") as f:
|
||||
files = {"file": (object_name, f)}
|
||||
requests.post(response["url"], data=response["fields"], files=files)
|
||||
|
||||
response = s3.get_object_acl(Bucket=bucket_name, Key=object_name)
|
||||
|
||||
assert "Grants" in response
|
||||
assert len(response["Grants"]) == 2
|
||||
assert response["Grants"][1]["Permission"] == "READ"
|
||||
|
||||
response = s3.get_object(Bucket=bucket_name, Key=object_name)
|
||||
|
||||
assert "ETag" in response
|
||||
assert "Body" in response
|
||||
os.remove("text.txt")
|
||||
|
||||
|
||||
@mock_s3
|
||||
def test_put_bucket_notification():
|
||||
s3 = boto3.client("s3", region_name=DEFAULT_REGION_NAME)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue