From 3c6713b5e216dd89d7679432a5139b590b537c6b Mon Sep 17 00:00:00 2001 From: Maxime Alves LIRMM Date: Fri, 28 May 2021 12:27:35 +0200 Subject: [PATCH] =?UTF-8?q?[tests]=C2=A0add=20JWTMw=20test=20for=20query?= =?UTF-8?q?=20without=20tokens=20(must=20return=20Unauth=20user)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_jwt_middleware.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/test_jwt_middleware.py b/tests/test_jwt_middleware.py index 073b28b..1d7896a 100644 --- a/tests/test_jwt_middleware.py +++ b/tests/test_jwt_middleware.py @@ -112,7 +112,19 @@ def test_JWTUser(): assert user.is_authenticated == True @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() assert backend.secret_key == SECRET