[tests] JWTmw - flags check et user_id

This commit is contained in:
Maxime Alves LIRMM 2021-05-28 12:41:23 +02:00
parent 3c6713b5e2
commit ea1f54cb82
1 changed files with 33 additions and 0 deletions

View File

@ -167,3 +167,36 @@ async def test_JWTAuthenticationBackend_DebugTrue(token_debug_true_builder):
await backend.authenticate(req)
except Exception as exc:
assert type(exc) == AuthenticationError
@pytest.mark.asyncio
async def test_JWTAuthenticationBackend_Check(token_debug_false_builder):
backend = JWTAuthenticationBackend()
assert backend.secret_key == SECRET
req = Request(
params={
'check':True,
})
credentials, user = await backend.authenticate(req)
assert isinstance(user, UnauthenticatedUser)
assert isinstance(credentials, AuthCredentials)
@pytest.mark.asyncio
async def test_JWTAuthenticationBackend_CheckUserId(token_debug_false_builder):
backend = JWTAuthenticationBackend()
assert backend.secret_key == SECRET
tmp_user_id = str(uuid4())
req = Request(
params={
'check': True,
'user_id': tmp_user_id
})
credentials, user = await backend.authenticate(req)
assert isinstance(user, JWTUser)
assert user.__id == tmp_user_id
assert isinstance(credentials, AuthCredentials)