Files
Aegis/backend/tests/test_list_operators.py
T
kitos 58c0143304
Aegis CI / lint-and-test (push) Has been cancelled
Snyk Security Scan / Python vulnerabilities (backend) (push) Has been cancelled
Snyk Security Scan / npm vulnerabilities (frontend) (push) Has been cancelled
Snyk Security Scan / Docker image vulnerabilities (backend) (push) Has been cancelled
feat(permissions): admin no longer acts on the test workflow; managers coordinate operators
Admin administers the site — it no longer has any override on
validate-red/blue, review-red/blue, resolve-dispute, request-discussion,
reopen, hold, resume, assign-operators, or classification-update.
Introduces require_any_role_strict(), a role dependency without the
global admin bypass, so these specific endpoints truly exclude admin
instead of only removing it from the (redundant) role tuple.

Managers gain the ability to assign red_tech/blue_tech operators
(POST /tests/{id}/assign, GET /users/operators) alongside leads, since
that's coordination, not resolving a ticket.

Also enlarges and repositions the operator-assignment controls next
to the Start Execution button, and fixes a literal '\u2014' rendering
as text instead of an em dash in the test detail technique line.
2026-07-10 10:28:04 +02:00

47 lines
1.7 KiB
Python

"""Tests for GET /users/operators — lead/manager-reachable operator picker list."""
def test_red_lead_can_list_operators(client, red_lead_headers, red_tech_user, blue_tech_user, red_lead_user):
resp = client.get("/api/v1/users/operators", headers=red_lead_headers)
assert resp.status_code == 200, resp.text
usernames = {u["username"] for u in resp.json()}
assert "redtech" in usernames
assert "bluetech" in usernames
assert "redlead" in usernames
def test_operators_list_excludes_viewers(client, red_lead_headers, db):
from app.auth import hash_password
from app.models.user import User
viewer = User(
username="viewer_ops", email="viewer_ops@test.com",
hashed_password=hash_password("x"), role="viewer", is_active=True,
must_change_password=False,
)
db.add(viewer)
db.commit()
resp = client.get("/api/v1/users/operators", headers=red_lead_headers)
assert resp.status_code == 200
usernames = {u["username"] for u in resp.json()}
assert "viewer_ops" not in usernames
def test_red_tech_cannot_list_operators(client, red_tech_headers):
resp = client.get("/api/v1/users/operators", headers=red_tech_headers)
assert resp.status_code == 403
def test_admin_cannot_list_operators(client, auth_headers):
"""Admin administers the site — coordinating operators is a lead/manager call."""
resp = client.get("/api/v1/users/operators", headers=auth_headers)
assert resp.status_code == 403
def test_manager_can_list_operators(client, manager_headers, red_tech_user):
resp = client.get("/api/v1/users/operators", headers=manager_headers)
assert resp.status_code == 200, resp.text
usernames = {u["username"] for u in resp.json()}
assert "redtech" in usernames