mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-06-05 14:45:24 -04:00
* fix(frontend): 🐛 update dialog implementation to simplify state management * test(backend): ✅ refactor test fixtures + admin group tests * chore(backend): 🔨 add launcher.json for python debugging (tests) * fix typing * feat(backend): ✨ refactor/fix group management for admins * feat(frontend): ✨ add/fix admin group management * add LDAP checker Co-authored-by: hay-kot <hay-kot@pm.me>
34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
import json
|
|
|
|
from fastapi.testclient import TestClient
|
|
from pytest import fixture
|
|
|
|
from tests.utils.app_routes import AppRoutes
|
|
|
|
|
|
@fixture
|
|
def long_live_token(api_client: TestClient, api_routes: AppRoutes, admin_token):
|
|
response = api_client.post(api_routes.users_api_tokens, json={"name": "Test Fixture Token"}, headers=admin_token)
|
|
assert response.status_code == 201
|
|
|
|
return {"Authorization": f"Bearer {json.loads(response.text).get('token')}"}
|
|
|
|
|
|
def test_api_token_creation(api_client: TestClient, api_routes: AppRoutes, admin_token):
|
|
response = api_client.post(api_routes.users_api_tokens, json={"name": "Test API Token"}, headers=admin_token)
|
|
assert response.status_code == 201
|
|
|
|
|
|
def test_use_token(api_client: TestClient, api_routes: AppRoutes, long_live_token):
|
|
response = api_client.get(api_routes.users, headers=long_live_token)
|
|
|
|
assert response.status_code == 200
|
|
|
|
|
|
def test_delete_token(api_client: TestClient, api_routes: AppRoutes, admin_token):
|
|
response = api_client.delete(api_routes.users_api_tokens_token_id(1), headers=admin_token)
|
|
assert response.status_code == 200
|
|
|
|
response = api_client.delete(api_routes.users_api_tokens_token_id(2), headers=admin_token)
|
|
assert response.status_code == 200
|