integration tests

This commit is contained in:
2026-07-30 15:49:08 +03:00
parent f87f54de55
commit 439d57554c
5 changed files with 130 additions and 40 deletions
+1 -3
View File
@@ -146,10 +146,8 @@ class CurrentUser:
ip_address=request.headers.get("x-forwarded-for", "").split(",")[0].strip() or (request.client.host if request.client else "unknown"),
expires_at=datetime.now(UTC)+timedelta(days=env_settings.REFRESH_TOKEN_EXPIRE_DAYS),
)
self.jwt_db_actions.create_token(RefreshTokensCreate.model_dump(new_token_record))
'''update old token to deactivate it and assign replaced_by'''
self.jwt_db_actions.update_token(old_jti, new_jti)
self.jwt_db_actions.create_and_update_token(RefreshTokensCreate.model_dump(new_token_record), old_jti, new_jti)
return (new_access_token,new_refresh_token)
+4
View File
@@ -34,6 +34,8 @@ class Jwt:
def create_access_token(self, data:dict)->str:
user_info=data.copy()
if not (user_info.get("sub")) or user_info.get("sub") == "":
raise self.error.credentials_error(detail="Jwt token is incorrect")
user_info.update({"exp": datetime.now(UTC)+timedelta(minutes=env_settings.ACCESS_TOKEN_EXPIRE_MINUTES),
"token_type":"access"})
return jwt.encode(user_info, env_settings.SECRET_KEY, env_settings.ALGORITHM)
@@ -43,6 +45,8 @@ class Jwt:
user_info=data.copy()
jti=str(uuid4())
if not (user_info.get("sub")) or user_info.get("sub") == "":
raise self.error.credentials_error(detail="Jwt token is incorrect")
user_info.update({"exp":datetime.now(UTC)+timedelta(days=env_settings.REFRESH_TOKEN_EXPIRE_DAYS),
"token_type":"refresh",
"jti":jti