mirror of
https://github.com/fastapi/fastapi.git
synced 2026-03-31 13:11:17 -04:00
✨ Add automatic header handling for HTTP Basic Auth (#175)
* ✨ Add automatic header handling for HTTP Basic Auth * 🎨 Remove obsolete comment
This commit is contained in:
committed by
GitHub
parent
a4558e7053
commit
f216d340ec
@@ -67,7 +67,8 @@ def test_security_http_basic_invalid_credentials():
|
||||
response = client.get(
|
||||
"/users/me", headers={"Authorization": "Basic notabase64token"}
|
||||
)
|
||||
assert response.status_code == 403
|
||||
assert response.status_code == 401
|
||||
assert response.headers["WWW-Authenticate"] == "Basic"
|
||||
assert response.json() == {"detail": "Invalid authentication credentials"}
|
||||
|
||||
|
||||
@@ -75,5 +76,6 @@ def test_security_http_basic_non_basic_credentials():
|
||||
payload = b64encode(b"johnsecret").decode("ascii")
|
||||
auth_header = f"Basic {payload}"
|
||||
response = client.get("/users/me", headers={"Authorization": auth_header})
|
||||
assert response.status_code == 403
|
||||
assert response.status_code == 401
|
||||
assert response.headers["WWW-Authenticate"] == "Basic"
|
||||
assert response.json() == {"detail": "Invalid authentication credentials"}
|
||||
|
||||
Reference in New Issue
Block a user