Skip to content

Commit

Permalink
S3: get_bucket_cors(): Fix ExposeHeader XML tag (#8407)
Browse files Browse the repository at this point in the history
  • Loading branch information
kangasta authored Dec 18, 2024
1 parent 6bf0cfc commit 08a8506
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion moto/s3/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -2997,7 +2997,7 @@ def _invalid_headers(self, url: str, headers: Dict[str, str]) -> bool:
{% endif %}
{% if cors.exposed_headers is not none %}
{% for header in cors.exposed_headers %}
<ExposedHeader>{{ header }}</ExposedHeader>
<ExposeHeader>{{ header }}</ExposeHeader>
{% endfor %}
{% endif %}
{% if cors.max_age_seconds is not none %}
Expand Down
5 changes: 5 additions & 0 deletions tests/test_s3/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2309,6 +2309,11 @@ def test_get_bucket_cors():
resp = s3_client.get_bucket_cors(Bucket=bucket_name)
assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200
assert len(resp["CORSRules"]) == 2
for rules in resp["CORSRules"]:
assert rules["AllowedOrigins"] == ["*"]
assert rules["AllowedHeaders"] == ["Authorization"]
assert rules["ExposeHeaders"] == ["x-amz-request-id"]
assert rules["MaxAgeSeconds"] == 123


@pytest.mark.aws_verified
Expand Down
2 changes: 1 addition & 1 deletion tests/test_s3/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def test_s3_server_post_cors_exposed_header():
assert res.status_code == 200

cors_res = test_client.get("/?cors", "http://testcors.localhost:5000")
assert b"<ExposedHeader>ETag</ExposedHeader>" in cors_res.data
assert b"<ExposeHeader>ETag</ExposeHeader>" in cors_res.data

# Test OPTIONS bucket response and key response
for key_name in ("/", "/test"):
Expand Down

0 comments on commit 08a8506

Please sign in to comment.