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:
Sebastián Ramírez
2019-04-21 21:44:25 +04:00
committed by GitHub
parent a4558e7053
commit f216d340ec
4 changed files with 102 additions and 12 deletions

View File

@@ -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"}