Browse Source

Increase tests for coverage

pull/14459/head
Sebastián Ramírez 8 months ago
parent
commit
723a76f481
  1. 16
      tests/test_security_oauth2_authorization_code_bearer_scopes_openapi.py
  2. 6
      tests/test_security_oauth2_authorization_code_bearer_scopes_openapi_simple.py

16
tests/test_security_oauth2_authorization_code_bearer_scopes_openapi.py

@ -69,6 +69,22 @@ def test_root():
assert response.json() == {"message": "Hello World"}
def test_read_with_oauth2_scheme():
response = client.get(
"/with-oauth2-scheme", headers={"Authorization": "Bearer testtoken"}
)
assert response.status_code == 200, response.text
assert response.json() == {"message": "Admin Access"}
def test_read_with_get_token():
response = client.get(
"/with-get-token", headers={"Authorization": "Bearer testtoken"}
)
assert response.status_code == 200, response.text
assert response.json() == {"message": "Admin Access"}
def test_read_token():
response = client.get("/items/", headers={"Authorization": "Bearer testtoken"})
assert response.status_code == 200, response.text

6
tests/test_security_oauth2_authorization_code_bearer_scopes_openapi_simple.py

@ -28,6 +28,12 @@ async def read_admin():
client = TestClient(app)
def test_read_admin():
response = client.get("/admin", headers={"Authorization": "Bearer faketoken"})
assert response.status_code == 200, response.text
assert response.json() == {"message": "Admin Access"}
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text

Loading…
Cancel
Save