Skip to content

Commit 194116b

Browse files
committed
test(auth): cover lowlevel auth app helper branches
1 parent d0c0b43 commit 194116b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/server/test_lowlevel_streamable_http_auth_app.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
from typing import cast
12
from unittest.mock import Mock
23

4+
import pytest
35
from pydantic import AnyHttpUrl
46
from starlette.applications import Starlette
57
from starlette.middleware.authentication import AuthenticationMiddleware
@@ -24,6 +26,22 @@ def route_paths(app: Starlette) -> set[str]:
2426
return paths
2527

2628

29+
@pytest.mark.anyio
30+
async def test_dummy_token_verifier_returns_none():
31+
verifier = DummyTokenVerifier()
32+
33+
assert await verifier.verify_token("token") is None
34+
35+
36+
def test_route_paths_ignores_non_string_paths():
37+
app = Starlette()
38+
routes = cast(list[object], app.router.routes)
39+
routes.append(Mock(path="/ok"))
40+
routes.append(object())
41+
42+
assert route_paths(app) == {"/ok"}
43+
44+
2745
def test_streamable_http_app_adds_auth_routes_without_token_verifier():
2846
server = Server("test-server")
2947

0 commit comments

Comments
 (0)