fix rate-limit valid login bug and fix sessions of redis and psql in tests

This commit is contained in:
2026-09-05 21:55:31 +03:00
parent c4a6a88d05
commit 9fd44c0ad9
8 changed files with 50 additions and 30 deletions
+6 -5
View File
@@ -118,7 +118,8 @@ class TestAuth:
with allure.step("create fake refresh token"):
token=await jwt_service.create_refresh_token({"sub":str(uuid4())})
refresh_token=await jwt_service.create_refresh_token({"sub":str(uuid4())})
access_token=await jwt_service.create_access_token({"sub":str(uuid4)})
with allure.step("patching db call functions"):
@@ -126,7 +127,7 @@ class TestAuth:
with allure.step("test logout with fake data"):
status=await current_user_service.logout(token[0])
status=await current_user_service.logout(refresh_token[0], access_token)
assert status is True
@pytest.mark.parametrize("jti,db_result, expected_exception, expected_status",[
@@ -148,11 +149,11 @@ class TestAuth:
with allure.step("create fake refresh token"):
token=await fake_create_refresh_token({"sub":str(uuid4()), "jti":jti, "token_type":"refresh", "exp":datetime.now(UTC)+timedelta(days=45)})
refresh_token=await fake_create_refresh_token({"sub":str(uuid4()), "jti":jti, "token_type":"refresh", "exp":datetime.now(UTC)+timedelta(days=45)})
access_token=await fake_create_refresh_token({"sub":str(uuid4()), "jti":jti, "token_type":"refresh", "exp":datetime.now(UTC)+timedelta(minutes=30)})
with allure.step("test logout with fake data"), pytest.raises(expected_exception) as exc_info:
await current_user_service.logout(token)
await current_user_service.logout(refresh_token, access_token)
if expected_exception is HTTPException:
assert exc_info.value.status_code==expected_status