diff --git a/tests/test_security_api_key_cookie.py b/tests/test_security_api_key_cookie.py index addb9cdb4..586e92c5f 100644 --- a/tests/test_security_api_key_cookie.py +++ b/tests/test_security_api_key_cookie.py @@ -22,37 +22,6 @@ def read_current_user(current_user: User = Depends(get_current_user)): return current_user -openapi_schema = { - "openapi": "3.0.2", - "info": {"title": "FastAPI", "version": "0.1.0"}, - "paths": { - "/users/me": { - "get": { - "responses": { - "200": { - "description": "Successful Response", - "content": {"application/json": {"schema": {}}}, - } - }, - "summary": "Read Current User", - "operationId": "read_current_user_users_me_get", - "security": [{"key": []}], - } - } - }, - "components": { - "securitySchemes": {"key": {"type": "apiKey", "name": "key", "in": "cookie"}} - }, -} - - -def test_openapi_schema(): - client = TestClient(app) - response = client.get("/openapi.json") - assert response.status_code == 200, response.text - assert response.json() == openapi_schema - - def test_security_api_key(): client = TestClient(app, cookies={"key": "secret"}) response = client.get("/users/me") @@ -85,13 +54,13 @@ def test_openapi_schema(): }, "summary": "Read Current User", "operationId": "read_current_user_users_me_get", - "security": [{"APIKeyCookie": []}], + "security": [{"key": []}], } } }, "components": { "securitySchemes": { - "APIKeyCookie": {"type": "apiKey", "name": "key", "in": "cookie"} + "key": {"type": "apiKey", "name": "key", "in": "cookie"} } }, } diff --git a/tests/test_security_api_key_cookie_description.py b/tests/test_security_api_key_cookie_description.py index 25f4e19fa..17ec35e71 100644 --- a/tests/test_security_api_key_cookie_description.py +++ b/tests/test_security_api_key_cookie_description.py @@ -22,44 +22,6 @@ def read_current_user(current_user: User = Depends(get_current_user)): return current_user -openapi_schema = { - "openapi": "3.0.2", - "info": {"title": "FastAPI", "version": "0.1.0"}, - "paths": { - "/users/me": { - "get": { - "responses": { - "200": { - "description": "Successful Response", - "content": {"application/json": {"schema": {}}}, - } - }, - "summary": "Read Current User", - "operationId": "read_current_user_users_me_get", - "security": [{"key": []}], - } - } - }, - "components": { - "securitySchemes": { - "key": { - "type": "apiKey", - "name": "key", - "in": "cookie", - "description": "An API Cookie Key", - } - } - }, -} - - -def test_openapi_schema(): - client = TestClient(app) - response = client.get("/openapi.json") - assert response.status_code == 200, response.text - assert response.json() == openapi_schema - - def test_security_api_key(): client = TestClient(app, cookies={"key": "secret"}) response = client.get("/users/me") @@ -92,13 +54,13 @@ def test_openapi_schema(): }, "summary": "Read Current User", "operationId": "read_current_user_users_me_get", - "security": [{"APIKeyCookie": []}], + "security": [{"key": []}], } } }, "components": { "securitySchemes": { - "APIKeyCookie": { + "key": { "type": "apiKey", "name": "key", "in": "cookie", diff --git a/tests/test_security_api_key_cookie_optional.py b/tests/test_security_api_key_cookie_optional.py index 6da8ec019..de2193934 100644 --- a/tests/test_security_api_key_cookie_optional.py +++ b/tests/test_security_api_key_cookie_optional.py @@ -29,37 +29,6 @@ def read_current_user(current_user: User = Depends(get_current_user)): return current_user -openapi_schema = { - "openapi": "3.0.2", - "info": {"title": "FastAPI", "version": "0.1.0"}, - "paths": { - "/users/me": { - "get": { - "responses": { - "200": { - "description": "Successful Response", - "content": {"application/json": {"schema": {}}}, - } - }, - "summary": "Read Current User", - "operationId": "read_current_user_users_me_get", - "security": [{"key": []}], - } - } - }, - "components": { - "securitySchemes": {"key": {"type": "apiKey", "name": "key", "in": "cookie"}} - }, -} - - -def test_openapi_schema(): - client = TestClient(app) - response = client.get("/openapi.json") - assert response.status_code == 200, response.text - assert response.json() == openapi_schema - - def test_security_api_key(): client = TestClient(app, cookies={"key": "secret"}) response = client.get("/users/me") @@ -92,13 +61,13 @@ def test_openapi_schema(): }, "summary": "Read Current User", "operationId": "read_current_user_users_me_get", - "security": [{"APIKeyCookie": []}], + "security": [{"key": []}], } } }, "components": { "securitySchemes": { - "APIKeyCookie": {"type": "apiKey", "name": "key", "in": "cookie"} + "key": {"type": "apiKey", "name": "key", "in": "cookie"} } }, } diff --git a/tests/test_security_api_key_header.py b/tests/test_security_api_key_header.py index 0824d9bfa..2e5ed7ad5 100644 --- a/tests/test_security_api_key_header.py +++ b/tests/test_security_api_key_header.py @@ -24,35 +24,6 @@ def read_current_user(current_user: User = Depends(get_current_user)): client = TestClient(app) -openapi_schema = { - "openapi": "3.0.2", - "info": {"title": "FastAPI", "version": "0.1.0"}, - "paths": { - "/users/me": { - "get": { - "responses": { - "200": { - "description": "Successful Response", - "content": {"application/json": {"schema": {}}}, - } - }, - "summary": "Read Current User", - "operationId": "read_current_user_users_me_get", - "security": [{"key": []}], - } - } - }, - "components": { - "securitySchemes": {"key": {"type": "apiKey", "name": "key", "in": "header"}} - }, -} - - -def test_openapi_schema(): - response = client.get("/openapi.json") - assert response.status_code == 200, response.text - assert response.json() == openapi_schema - def test_security_api_key(): response = client.get("/users/me", headers={"key": "secret"}) @@ -83,13 +54,13 @@ def test_openapi_schema(): }, "summary": "Read Current User", "operationId": "read_current_user_users_me_get", - "security": [{"APIKeyHeader": []}], + "security": [{"key": []}], } } }, "components": { "securitySchemes": { - "APIKeyHeader": {"type": "apiKey", "name": "key", "in": "header"} + "key": {"type": "apiKey", "name": "key", "in": "header"} } }, } diff --git a/tests/test_security_api_key_header_description.py b/tests/test_security_api_key_header_description.py index adc40e556..ffbe03784 100644 --- a/tests/test_security_api_key_header_description.py +++ b/tests/test_security_api_key_header_description.py @@ -24,42 +24,6 @@ def read_current_user(current_user: User = Depends(get_current_user)): client = TestClient(app) -openapi_schema = { - "openapi": "3.0.2", - "info": {"title": "FastAPI", "version": "0.1.0"}, - "paths": { - "/users/me": { - "get": { - "responses": { - "200": { - "description": "Successful Response", - "content": {"application/json": {"schema": {}}}, - } - }, - "summary": "Read Current User", - "operationId": "read_current_user_users_me_get", - "security": [{"key": []}], - } - } - }, - "components": { - "securitySchemes": { - "key": { - "type": "apiKey", - "name": "key", - "in": "header", - "description": "An API Key Header", - } - } - }, -} - - -def test_openapi_schema(): - response = client.get("/openapi.json") - assert response.status_code == 200, response.text - assert response.json() == openapi_schema - def test_security_api_key(): response = client.get("/users/me", headers={"key": "secret"}) @@ -90,13 +54,13 @@ def test_openapi_schema(): }, "summary": "Read Current User", "operationId": "read_current_user_users_me_get", - "security": [{"APIKeyHeader": []}], + "security": [{"key": []}], } } }, "components": { "securitySchemes": { - "APIKeyHeader": { + "key": { "type": "apiKey", "name": "key", "in": "header", diff --git a/tests/test_security_api_key_header_optional.py b/tests/test_security_api_key_header_optional.py index 674cdaa30..79f553caa 100644 --- a/tests/test_security_api_key_header_optional.py +++ b/tests/test_security_api_key_header_optional.py @@ -30,35 +30,6 @@ def read_current_user(current_user: Optional[User] = Depends(get_current_user)): client = TestClient(app) -openapi_schema = { - "openapi": "3.0.2", - "info": {"title": "FastAPI", "version": "0.1.0"}, - "paths": { - "/users/me": { - "get": { - "responses": { - "200": { - "description": "Successful Response", - "content": {"application/json": {"schema": {}}}, - } - }, - "summary": "Read Current User", - "operationId": "read_current_user_users_me_get", - "security": [{"key": []}], - } - } - }, - "components": { - "securitySchemes": {"key": {"type": "apiKey", "name": "key", "in": "header"}} - }, -} - - -def test_openapi_schema(): - response = client.get("/openapi.json") - assert response.status_code == 200, response.text - assert response.json() == openapi_schema - def test_security_api_key(): response = client.get("/users/me", headers={"key": "secret"}) @@ -89,13 +60,13 @@ def test_openapi_schema(): }, "summary": "Read Current User", "operationId": "read_current_user_users_me_get", - "security": [{"APIKeyHeader": []}], + "security": [{"key": []}], } } }, "components": { "securitySchemes": { - "APIKeyHeader": {"type": "apiKey", "name": "key", "in": "header"} + "key": {"type": "apiKey", "name": "key", "in": "header"} } }, } diff --git a/tests/test_security_api_key_query.py b/tests/test_security_api_key_query.py index c0d99aaf3..fcfde8308 100644 --- a/tests/test_security_api_key_query.py +++ b/tests/test_security_api_key_query.py @@ -24,35 +24,6 @@ def read_current_user(current_user: User = Depends(get_current_user)): client = TestClient(app) -openapi_schema = { - "openapi": "3.0.2", - "info": {"title": "FastAPI", "version": "0.1.0"}, - "paths": { - "/users/me": { - "get": { - "responses": { - "200": { - "description": "Successful Response", - "content": {"application/json": {"schema": {}}}, - } - }, - "summary": "Read Current User", - "operationId": "read_current_user_users_me_get", - "security": [{"key": []}], - } - } - }, - "components": { - "securitySchemes": {"key": {"type": "apiKey", "name": "key", "in": "query"}} - }, -} - - -def test_openapi_schema(): - response = client.get("/openapi.json") - assert response.status_code == 200, response.text - assert response.json() == openapi_schema - def test_security_api_key(): response = client.get("/users/me?key=secret") @@ -83,13 +54,13 @@ def test_openapi_schema(): }, "summary": "Read Current User", "operationId": "read_current_user_users_me_get", - "security": [{"APIKeyQuery": []}], + "security": [{"key": []}], } } }, "components": { "securitySchemes": { - "APIKeyQuery": {"type": "apiKey", "name": "key", "in": "query"} + "key": {"type": "apiKey", "name": "key", "in": "query"} } }, } diff --git a/tests/test_security_api_key_query_description.py b/tests/test_security_api_key_query_description.py index b5a977f31..98000e266 100644 --- a/tests/test_security_api_key_query_description.py +++ b/tests/test_security_api_key_query_description.py @@ -24,42 +24,6 @@ def read_current_user(current_user: User = Depends(get_current_user)): client = TestClient(app) -openapi_schema = { - "openapi": "3.0.2", - "info": {"title": "FastAPI", "version": "0.1.0"}, - "paths": { - "/users/me": { - "get": { - "responses": { - "200": { - "description": "Successful Response", - "content": {"application/json": {"schema": {}}}, - } - }, - "summary": "Read Current User", - "operationId": "read_current_user_users_me_get", - "security": [{"key": []}], - } - } - }, - "components": { - "securitySchemes": { - "key": { - "type": "apiKey", - "name": "key", - "in": "query", - "description": "API Key Query", - } - } - }, -} - - -def test_openapi_schema(): - response = client.get("/openapi.json") - assert response.status_code == 200, response.text - assert response.json() == openapi_schema - def test_security_api_key(): response = client.get("/users/me?key=secret") @@ -90,13 +54,13 @@ def test_openapi_schema(): }, "summary": "Read Current User", "operationId": "read_current_user_users_me_get", - "security": [{"APIKeyQuery": []}], + "security": [{"key": []}], } } }, "components": { "securitySchemes": { - "APIKeyQuery": { + "key": { "type": "apiKey", "name": "key", "in": "query", diff --git a/tests/test_security_api_key_query_optional.py b/tests/test_security_api_key_query_optional.py index a97df1bd7..4862a9657 100644 --- a/tests/test_security_api_key_query_optional.py +++ b/tests/test_security_api_key_query_optional.py @@ -30,35 +30,6 @@ def read_current_user(current_user: Optional[User] = Depends(get_current_user)): client = TestClient(app) -openapi_schema = { - "openapi": "3.0.2", - "info": {"title": "FastAPI", "version": "0.1.0"}, - "paths": { - "/users/me": { - "get": { - "responses": { - "200": { - "description": "Successful Response", - "content": {"application/json": {"schema": {}}}, - } - }, - "summary": "Read Current User", - "operationId": "read_current_user_users_me_get", - "security": [{"key": []}], - } - } - }, - "components": { - "securitySchemes": {"key": {"type": "apiKey", "name": "key", "in": "query"}} - }, -} - - -def test_openapi_schema(): - response = client.get("/openapi.json") - assert response.status_code == 200, response.text - assert response.json() == openapi_schema - def test_security_api_key(): response = client.get("/users/me?key=secret") @@ -89,13 +60,13 @@ def test_openapi_schema(): }, "summary": "Read Current User", "operationId": "read_current_user_users_me_get", - "security": [{"APIKeyQuery": []}], + "security": [{"key": []}], } } }, "components": { "securitySchemes": { - "APIKeyQuery": {"type": "apiKey", "name": "key", "in": "query"} + "key": {"type": "apiKey", "name": "key", "in": "query"} } }, }