add 'Authorization' header to the test_cors/test_tutorial001.py

This commit is contained in:
Flavius Raducu 2025-10-01 18:16:13 +01:00
parent 33b0f024d9
commit c91067adc0
No known key found for this signature in database
2 changed files with 5 additions and 4 deletions

View File

@ -15,7 +15,7 @@ app.add_middleware(
allow_origins=origins, allow_origins=origins,
allow_credentials=True, allow_credentials=True,
allow_methods=["GET"], allow_methods=["GET"],
allow_headers=["X-Example"], allow_headers=["Authorization", "X-Example"],
) )

View File

@ -18,10 +18,11 @@ def test_cors():
response.headers["access-control-allow-origin"] response.headers["access-control-allow-origin"]
== "https://localhost.tiangolo.com" == "https://localhost.tiangolo.com"
) )
expected_headers = ( assert response.headers["access-control-allow-headers"] == (
"Accept, Accept-Language, Content-Language, Content-Type, X-Example" "Accept, Accept-Language, "
"Authorization, Content-Language, "
"Content-Type, X-Example"
) )
assert response.headers["access-control-allow-headers"] == expected_headers
# Test standard response # Test standard response
headers = {"Origin": "https://localhost.tiangolo.com"} headers = {"Origin": "https://localhost.tiangolo.com"}