[tests] add JWTMw test for query without tokens (must return Unauth user)

This commit is contained in:
Maxime Alves LIRMM 2021-05-28 12:27:35 +02:00
parent c7e29e399b
commit 3c6713b5e2
1 changed files with 13 additions and 1 deletions

View File

@ -112,7 +112,19 @@ def test_JWTUser():
assert user.is_authenticated == True assert user.is_authenticated == True
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_JWTAuthenticationBackend(token_builder): async def test_JWTAuthenticationBackend_NoToken(token_builder):
backend = JWTAuthenticationBackend()
assert backend.secret_key == SECRET
req = Request()
credentials, user = await backend.authenticate(req)
assert isinstance(user, UnauthenticatedUser)
assert isinstance(credentials, AuthCredentials)
@pytest.mark.asyncio
async def test_JWTAuthenticationBackend_Token(token_builder):
backend = JWTAuthenticationBackend() backend = JWTAuthenticationBackend()
assert backend.secret_key == SECRET assert backend.secret_key == SECRET