From 3d124f0b18c1f832569cc51be1c49a13e585d5e6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 22 Nov 2025 12:15:35 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20[pre-commit.ci]=20Auto=20format?= =?UTF-8?q?=20from=20pre-commit.com=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_security_http_basic_empty_realm.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_security_http_basic_empty_realm.py b/tests/test_security_http_basic_empty_realm.py index e61dc06da..eb5513f30 100644 --- a/tests/test_security_http_basic_empty_realm.py +++ b/tests/test_security_http_basic_empty_realm.py @@ -1,4 +1,4 @@ -from fastapi import Depends, FastAPI, HTTPException +from fastapi import Depends, FastAPI from fastapi.security import HTTPBasic, HTTPBasicCredentials from fastapi.testclient import TestClient @@ -6,17 +6,21 @@ app = FastAPI() security = HTTPBasic(realm="") + @app.get("/users/me") def read_current_user(credentials: HTTPBasicCredentials = Depends(security)): return {"username": credentials.username, "password": credentials.password} + client = TestClient(app) + def test_security_http_basic_empty_realm(): response = client.get("/users/me", auth=("john", "secret")) assert response.status_code == 200, response.text assert response.json() == {"username": "john", "password": "secret"} + def test_security_http_basic_invalid_credentials_empty_realm(): response = client.get( "/users/me", headers={"Authorization": "Basic notabase64token"}