Skip to content

Commit 2ec28d9

Browse files
committed
Add test cases for each security engine
1 parent 8330e6c commit 2ec28d9

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
File renamed without changes.

tests/test_security.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import pytest
2+
3+
from fastapi_oauth2.security import OAuth2
4+
from fastapi_oauth2.security import OAuth2AuthorizationCodeBearer
5+
from fastapi_oauth2.security import OAuth2PasswordBearer
6+
7+
8+
@pytest.mark.anyio
9+
async def test_security_oauth2(get_app):
10+
try:
11+
get_app(OAuth2())
12+
except (TypeError, Exception):
13+
assert False
14+
15+
16+
@pytest.mark.anyio
17+
async def test_security_oauth2_password_bearer(get_app):
18+
try:
19+
get_app(OAuth2PasswordBearer(tokenUrl="/test"))
20+
except (TypeError, Exception):
21+
assert False
22+
23+
24+
@pytest.mark.anyio
25+
async def test_security_oauth2_authentication_code_bearer(get_app):
26+
try:
27+
get_app(OAuth2AuthorizationCodeBearer(authorizationUrl="/test", tokenUrl="/test"))
28+
except (TypeError, Exception):
29+
assert False

0 commit comments

Comments
 (0)