kin: BATON-FIX-012-debugger
This commit is contained in:
parent
e21bcb1eb4
commit
2f6a84f08b
3 changed files with 53 additions and 32 deletions
|
|
@ -42,6 +42,19 @@ _UUID_BLOCK = "f0000001-0000-4000-8000-000000000001"
|
|||
_UUID_UNBLOCK = "f0000002-0000-4000-8000-000000000002"
|
||||
_UUID_SIG_OK = "f0000003-0000-4000-8000-000000000003"
|
||||
|
||||
# Valid UUID v4 for admin-only tests (POST /admin/users, no /api/register call)
|
||||
_UUID_ADM_UNAUTH = "e0000000-0000-4000-8000-000000000000"
|
||||
_UUID_ADM_CREATE_1 = "e0000001-0000-4000-8000-000000000001"
|
||||
_UUID_ADM_CREATE_2 = "e0000002-0000-4000-8000-000000000002"
|
||||
_UUID_ADM_CREATE_3 = "e0000003-0000-4000-8000-000000000003"
|
||||
_UUID_ADM_PASS_1 = "e0000004-0000-4000-8000-000000000004"
|
||||
_UUID_ADM_PASS_2 = "e0000005-0000-4000-8000-000000000005"
|
||||
_UUID_ADM_BLOCK = "e0000006-0000-4000-8000-000000000006"
|
||||
_UUID_ADM_UNBLOCK = "e0000007-0000-4000-8000-000000000007"
|
||||
_UUID_ADM_DELETE_1 = "e0000008-0000-4000-8000-000000000008"
|
||||
_UUID_ADM_DELETE_2 = "e0000009-0000-4000-8000-000000000009"
|
||||
_UUID_ADM_REGRESS = "e000000a-0000-4000-8000-000000000010"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Criterion 6 — Unauthorised requests to /admin/* return 401
|
||||
|
|
@ -70,7 +83,7 @@ async def test_admin_create_user_without_token_returns_401() -> None:
|
|||
async with make_app_client() as client:
|
||||
resp = await client.post(
|
||||
"/admin/users",
|
||||
json={"uuid": "unauth-uuid-001", "name": "Ghost"},
|
||||
json={"uuid": _UUID_ADM_UNAUTH, "name": "Ghost"},
|
||||
)
|
||||
assert resp.status_code == 401
|
||||
|
||||
|
|
@ -116,12 +129,12 @@ async def test_admin_create_user_returns_201_with_user_data() -> None:
|
|||
async with make_app_client() as client:
|
||||
resp = await client.post(
|
||||
"/admin/users",
|
||||
json={"uuid": "create-uuid-001", "name": "Alice Admin"},
|
||||
json={"uuid": _UUID_ADM_CREATE_1, "name": "Alice Admin"},
|
||||
headers=ADMIN_HEADERS,
|
||||
)
|
||||
assert resp.status_code == 201
|
||||
data = resp.json()
|
||||
assert data["uuid"] == "create-uuid-001"
|
||||
assert data["uuid"] == _UUID_ADM_CREATE_1
|
||||
assert data["name"] == "Alice Admin"
|
||||
assert data["id"] > 0
|
||||
assert data["is_blocked"] is False
|
||||
|
|
@ -133,7 +146,7 @@ async def test_admin_create_user_appears_in_list() -> None:
|
|||
async with make_app_client() as client:
|
||||
await client.post(
|
||||
"/admin/users",
|
||||
json={"uuid": "create-uuid-002", "name": "Bob Admin"},
|
||||
json={"uuid": _UUID_ADM_CREATE_2, "name": "Bob Admin"},
|
||||
headers=ADMIN_HEADERS,
|
||||
)
|
||||
resp = await client.get("/admin/users", headers=ADMIN_HEADERS)
|
||||
|
|
@ -141,7 +154,7 @@ async def test_admin_create_user_appears_in_list() -> None:
|
|||
assert resp.status_code == 200
|
||||
users = resp.json()
|
||||
uuids = [u["uuid"] for u in users]
|
||||
assert "create-uuid-002" in uuids
|
||||
assert _UUID_ADM_CREATE_2 in uuids
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
@ -150,12 +163,12 @@ async def test_admin_create_user_duplicate_uuid_returns_409() -> None:
|
|||
async with make_app_client() as client:
|
||||
await client.post(
|
||||
"/admin/users",
|
||||
json={"uuid": "create-uuid-003", "name": "Carol"},
|
||||
json={"uuid": _UUID_ADM_CREATE_3, "name": "Carol"},
|
||||
headers=ADMIN_HEADERS,
|
||||
)
|
||||
resp = await client.post(
|
||||
"/admin/users",
|
||||
json={"uuid": "create-uuid-003", "name": "Carol Duplicate"},
|
||||
json={"uuid": _UUID_ADM_CREATE_3, "name": "Carol Duplicate"},
|
||||
headers=ADMIN_HEADERS,
|
||||
)
|
||||
assert resp.status_code == 409
|
||||
|
|
@ -181,7 +194,7 @@ async def test_admin_set_password_returns_ok() -> None:
|
|||
async with make_app_client() as client:
|
||||
create_resp = await client.post(
|
||||
"/admin/users",
|
||||
json={"uuid": "pass-uuid-001", "name": "PassUser"},
|
||||
json={"uuid": _UUID_ADM_PASS_1, "name": "PassUser"},
|
||||
headers=ADMIN_HEADERS,
|
||||
)
|
||||
user_id = create_resp.json()["id"]
|
||||
|
|
@ -213,7 +226,7 @@ async def test_admin_set_password_user_still_accessible_after_change() -> None:
|
|||
async with make_app_client() as client:
|
||||
create_resp = await client.post(
|
||||
"/admin/users",
|
||||
json={"uuid": "pass-uuid-002", "name": "PassUser2"},
|
||||
json={"uuid": _UUID_ADM_PASS_2, "name": "PassUser2"},
|
||||
headers=ADMIN_HEADERS,
|
||||
)
|
||||
user_id = create_resp.json()["id"]
|
||||
|
|
@ -227,7 +240,7 @@ async def test_admin_set_password_user_still_accessible_after_change() -> None:
|
|||
list_resp = await client.get("/admin/users", headers=ADMIN_HEADERS)
|
||||
|
||||
uuids = [u["uuid"] for u in list_resp.json()]
|
||||
assert "pass-uuid-002" in uuids
|
||||
assert _UUID_ADM_PASS_2 in uuids
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
@ -241,7 +254,7 @@ async def test_admin_block_user_returns_is_blocked_true() -> None:
|
|||
async with make_app_client() as client:
|
||||
create_resp = await client.post(
|
||||
"/admin/users",
|
||||
json={"uuid": "block-uuid-001", "name": "BlockUser"},
|
||||
json={"uuid": _UUID_ADM_BLOCK, "name": "BlockUser"},
|
||||
headers=ADMIN_HEADERS,
|
||||
)
|
||||
user_id = create_resp.json()["id"]
|
||||
|
|
@ -312,7 +325,7 @@ async def test_admin_unblock_user_returns_is_blocked_false() -> None:
|
|||
async with make_app_client() as client:
|
||||
create_resp = await client.post(
|
||||
"/admin/users",
|
||||
json={"uuid": "unblock-uuid-001", "name": "UnblockUser"},
|
||||
json={"uuid": _UUID_ADM_UNBLOCK, "name": "UnblockUser"},
|
||||
headers=ADMIN_HEADERS,
|
||||
)
|
||||
user_id = create_resp.json()["id"]
|
||||
|
|
@ -385,7 +398,7 @@ async def test_admin_delete_user_returns_204() -> None:
|
|||
async with make_app_client() as client:
|
||||
create_resp = await client.post(
|
||||
"/admin/users",
|
||||
json={"uuid": "delete-uuid-001", "name": "DeleteUser"},
|
||||
json={"uuid": _UUID_ADM_DELETE_1, "name": "DeleteUser"},
|
||||
headers=ADMIN_HEADERS,
|
||||
)
|
||||
user_id = create_resp.json()["id"]
|
||||
|
|
@ -403,7 +416,7 @@ async def test_admin_delete_user_disappears_from_list() -> None:
|
|||
async with make_app_client() as client:
|
||||
create_resp = await client.post(
|
||||
"/admin/users",
|
||||
json={"uuid": "delete-uuid-002", "name": "DeleteUser2"},
|
||||
json={"uuid": _UUID_ADM_DELETE_2, "name": "DeleteUser2"},
|
||||
headers=ADMIN_HEADERS,
|
||||
)
|
||||
user_id = create_resp.json()["id"]
|
||||
|
|
@ -416,7 +429,7 @@ async def test_admin_delete_user_disappears_from_list() -> None:
|
|||
list_resp = await client.get("/admin/users", headers=ADMIN_HEADERS)
|
||||
|
||||
uuids = [u["uuid"] for u in list_resp.json()]
|
||||
assert "delete-uuid-002" not in uuids
|
||||
assert _UUID_ADM_DELETE_2 not in uuids
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
@ -480,7 +493,7 @@ async def test_register_not_broken_after_admin_operations() -> None:
|
|||
# Admin операции
|
||||
await client.post(
|
||||
"/admin/users",
|
||||
json={"uuid": "regress-admin-uuid-001", "name": "AdminCreated"},
|
||||
json={"uuid": _UUID_ADM_REGRESS, "name": "AdminCreated"},
|
||||
headers=ADMIN_HEADERS,
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue