b3c41a4bd0
* add data-types required for login security * implement user lockout checking at login * cleanup legacy patterns * expose passwords in test_user * test user lockout after bad attempts * test user service * bump alembic version * save increment to database * add locked_at to datetime transformer on import * do proper test cleanup * implement scheduled task * spelling * document env variables * implement context manager for session * use context manager * implement reset script * cleanup generator * run generator * implement API endpoint for resetting locked users * add button to reset all locked users * add info when account is locked * use ignore instead of expect-error
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
from pytest import fixture
|
|
from starlette.testclient import TestClient
|
|
|
|
from mealie.core.config import get_app_settings
|
|
from tests import utils
|
|
|
|
|
|
@fixture(scope="session")
|
|
def admin_token(api_client: TestClient, api_routes: utils.AppRoutes):
|
|
settings = get_app_settings()
|
|
|
|
form_data = {"username": settings.DEFAULT_EMAIL, "password": settings.DEFAULT_PASSWORD}
|
|
return utils.login(form_data, api_client, api_routes)
|
|
|
|
|
|
@fixture(scope="session")
|
|
def admin_user(api_client: TestClient, api_routes: utils.AppRoutes):
|
|
settings = get_app_settings()
|
|
|
|
form_data = {"username": settings.DEFAULT_EMAIL, "password": settings.DEFAULT_PASSWORD}
|
|
|
|
token = utils.login(form_data, api_client, api_routes)
|
|
|
|
user_data = api_client.get(api_routes.users_self, headers=token).json()
|
|
assert token is not None
|
|
|
|
assert user_data.get("admin") is True
|
|
assert user_data.get("groupId") is not None
|
|
assert user_data.get("id") is not None
|
|
|
|
try:
|
|
yield utils.TestUser(
|
|
_group_id=user_data.get("groupId"),
|
|
user_id=user_data.get("id"),
|
|
password=settings.DEFAULT_PASSWORD,
|
|
username=user_data.get("username"),
|
|
email=user_data.get("email"),
|
|
token=token,
|
|
)
|
|
finally:
|
|
# TODO: Delete User after test
|
|
pass
|