/
burevol
/
GymAssistant
Обзор
Документация
Войти
/
burevol
/
GymAssistant
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
tests/test_crypto.py
32 строки
1 KB
Alexander Maximov
Расширены тесты криптомодуля
08 май 2025, 12:21
08 май 2025, 12:21
a02833b
Код
Авторство
О чём код?
from datetime import timedelta from dependencies import crypto from utils.models import UserInDB def test_get_password_hash(): password = "test" hashed_password = crypto.get_password_hash(password) assert isinstance(hashed_password, str) def test_verify_password(): password = "test" hashed_password = crypto.get_password_hash(password) assert crypto.verify_password(password, hashed_password) assert not crypto.verify_password("wrong", hashed_password) def test_create_access_token(): data = {"sub": "test"} token = crypto.create_access_token(data) assert isinstance(token, str) token = crypto.create_access_token(data, timedelta(minutes=1)) assert isinstance(token, str) def test_authenticate(): password = "test" user = UserInDB(hashed_password=crypto.get_password_hash(password), username="test", disable=False) assert crypto.authenticate_user(user, password) assert not crypto.authenticate_user(user, "wrong") assert crypto.authenticate_user(None, password) == False