Browse Source

Update tests to check the same error for HTTP security utils

pull/13786/head
Sebastián Ramírez 8 months ago
parent
commit
3fbf5c98ff
  1. 4
      tests/test_security_http_basic_optional.py
  2. 4
      tests/test_security_http_basic_realm.py
  3. 4
      tests/test_security_http_basic_realm_description.py
  4. 2
      tests/test_security_http_bearer.py
  5. 2
      tests/test_security_http_bearer_description.py
  6. 2
      tests/test_security_http_digest.py
  7. 2
      tests/test_security_http_digest_description.py
  8. 2
      tests/test_tutorial/test_security/test_tutorial003.py
  9. 4
      tests/test_tutorial/test_security/test_tutorial006.py

4
tests/test_security_http_basic_optional.py

@ -38,7 +38,7 @@ def test_security_http_basic_invalid_credentials():
)
assert response.status_code == 401, response.text
assert response.headers["WWW-Authenticate"] == "Basic"
assert response.json() == {"detail": "Invalid authentication credentials"}
assert response.json() == {"detail": "Not authenticated"}
def test_security_http_basic_non_basic_credentials():
@ -47,7 +47,7 @@ def test_security_http_basic_non_basic_credentials():
response = client.get("/users/me", headers={"Authorization": auth_header})
assert response.status_code == 401, response.text
assert response.headers["WWW-Authenticate"] == "Basic"
assert response.json() == {"detail": "Invalid authentication credentials"}
assert response.json() == {"detail": "Not authenticated"}
def test_openapi_schema():

4
tests/test_security_http_basic_realm.py

@ -36,7 +36,7 @@ def test_security_http_basic_invalid_credentials():
)
assert response.status_code == 401, response.text
assert response.headers["WWW-Authenticate"] == 'Basic realm="simple"'
assert response.json() == {"detail": "Invalid authentication credentials"}
assert response.json() == {"detail": "Not authenticated"}
def test_security_http_basic_non_basic_credentials():
@ -45,7 +45,7 @@ def test_security_http_basic_non_basic_credentials():
response = client.get("/users/me", headers={"Authorization": auth_header})
assert response.status_code == 401, response.text
assert response.headers["WWW-Authenticate"] == 'Basic realm="simple"'
assert response.json() == {"detail": "Invalid authentication credentials"}
assert response.json() == {"detail": "Not authenticated"}
def test_openapi_schema():

4
tests/test_security_http_basic_realm_description.py

@ -36,7 +36,7 @@ def test_security_http_basic_invalid_credentials():
)
assert response.status_code == 401, response.text
assert response.headers["WWW-Authenticate"] == 'Basic realm="simple"'
assert response.json() == {"detail": "Invalid authentication credentials"}
assert response.json() == {"detail": "Not authenticated"}
def test_security_http_basic_non_basic_credentials():
@ -45,7 +45,7 @@ def test_security_http_basic_non_basic_credentials():
response = client.get("/users/me", headers={"Authorization": auth_header})
assert response.status_code == 401, response.text
assert response.headers["WWW-Authenticate"] == 'Basic realm="simple"'
assert response.json() == {"detail": "Invalid authentication credentials"}
assert response.json() == {"detail": "Not authenticated"}
def test_openapi_schema():

2
tests/test_security_http_bearer.py

@ -31,7 +31,7 @@ def test_security_http_bearer_no_credentials():
def test_security_http_bearer_incorrect_scheme_credentials():
response = client.get("/users/me", headers={"Authorization": "Basic notreally"})
assert response.status_code == 401, response.text
assert response.json() == {"detail": "Invalid authentication credentials"}
assert response.json() == {"detail": "Not authenticated"}
assert response.headers["WWW-Authenticate"] == "Bearer"

2
tests/test_security_http_bearer_description.py

@ -31,7 +31,7 @@ def test_security_http_bearer_no_credentials():
def test_security_http_bearer_incorrect_scheme_credentials():
response = client.get("/users/me", headers={"Authorization": "Basic notreally"})
assert response.status_code == 401, response.text
assert response.json() == {"detail": "Invalid authentication credentials"}
assert response.json() == {"detail": "Not authenticated"}
assert response.headers["WWW-Authenticate"] == "Bearer"

2
tests/test_security_http_digest.py

@ -33,7 +33,7 @@ def test_security_http_digest_incorrect_scheme_credentials():
"/users/me", headers={"Authorization": "Other invalidauthorization"}
)
assert response.status_code == 401, response.text
assert response.json() == {"detail": "Invalid authentication credentials"}
assert response.json() == {"detail": "Not authenticated"}
assert response.headers["WWW-Authenticate"] == "Digest"

2
tests/test_security_http_digest_description.py

@ -33,7 +33,7 @@ def test_security_http_digest_incorrect_scheme_credentials():
"/users/me", headers={"Authorization": "Other invalidauthorization"}
)
assert response.status_code == 401, response.text
assert response.json() == {"detail": "Invalid authentication credentials"}
assert response.json() == {"detail": "Not authenticated"}
assert response.headers["WWW-Authenticate"] == "Digest"

2
tests/test_tutorial/test_security/test_tutorial003.py

@ -66,7 +66,7 @@ def test_token(client: TestClient):
def test_incorrect_token(client: TestClient):
response = client.get("/users/me", headers={"Authorization": "Bearer nonexistent"})
assert response.status_code == 401, response.text
assert response.json() == {"detail": "Invalid authentication credentials"}
assert response.json() == {"detail": "Not authenticated"}
assert response.headers["WWW-Authenticate"] == "Bearer"

4
tests/test_tutorial/test_security/test_tutorial006.py

@ -41,7 +41,7 @@ def test_security_http_basic_invalid_credentials(client: TestClient):
)
assert response.status_code == 401, response.text
assert response.headers["WWW-Authenticate"] == "Basic"
assert response.json() == {"detail": "Invalid authentication credentials"}
assert response.json() == {"detail": "Not authenticated"}
def test_security_http_basic_non_basic_credentials(client: TestClient):
@ -50,7 +50,7 @@ def test_security_http_basic_non_basic_credentials(client: TestClient):
response = client.get("/users/me", headers={"Authorization": auth_header})
assert response.status_code == 401, response.text
assert response.headers["WWW-Authenticate"] == "Basic"
assert response.json() == {"detail": "Invalid authentication credentials"}
assert response.json() == {"detail": "Not authenticated"}
def test_openapi_schema(client: TestClient):

Loading…
Cancel
Save