feat(audit): P1 cross-tenant/RBAC tests, P3 test fixes, P2/P3 frontend fixes
Check Cross-Plugin Imports / check (push) Has been cancelled

- P1-Tests: 12 test files with new cross-tenant isolation + RBAC tests
- P3-Tests: 8 fixes (duplicate fixtures, sys.path.insert, unused imports, KeyError)
- P3-Frontend: LucideIcons → ICON_MAP (2 files), inline styles → Tailwind (2 files)
- P3-Frontend: DOMPurify for iframe XSS, redundant regex removed, console.log → console.debug
- P2-Frontend: 2 notification API TODOs retained (requires larger refactor)
- conftest.py: create_no_perm_user helper added
- pyproject.toml: pythonpath for scripts/ added
- All checks green: ruff 0, F821 0, tsc 0, app 495 routes, cross-plugin 0
This commit is contained in:
Agent Zero
2026-08-16 01:30:02 +02:00
parent abbe7a18fc
commit db97a39133
29 changed files with 618 additions and 52 deletions
+35
View File
@@ -1078,3 +1078,38 @@ async def test_ac30_private_entry_visibility(calendar_app, db_session):
# Direct access to private entry → 403
resp = await viewer_c.get(f"/api/v1/calendar/entries/{entry_id}", headers=ORIGIN_HEADER)
assert resp.status_code == 403
# ─── Cross-tenant isolation test ───
@pytest.mark.asyncio
async def test_cross_tenant_calendar_isolation(calendar_app, db_session):
"""Calendar created in tenant A is not accessible from tenant B."""
from httpx import ASGITransport, AsyncClient
from tests.conftest import seed_tenant_and_users
await seed_tenant_and_users(db_session)
transport = ASGITransport(app=calendar_app)
async with AsyncClient(transport=transport, base_url="http://test") as client_a:
await login_client(client_a, "admin@tenanta.com")
resp = await client_a.post(
"/api/v1/calendars",
json={"name": "Tenant A Calendar"},
headers=ORIGIN_HEADER,
)
assert resp.status_code == 201
cal_id = resp.json()["id"]
# Tenant B admin must not see tenant A's calendar
async with AsyncClient(transport=transport, base_url="http://test") as client_b:
await login_client(client_b, "admin@tenantb.com")
list_resp = await client_b.get("/api/v1/calendars", headers=ORIGIN_HEADER)
assert list_resp.status_code == 200
assert all(c["id"] != cal_id for c in list_resp.json())
# Direct access to tenant A's calendar → 404
get_resp = await client_b.get(f"/api/v1/calendars/{cal_id}", headers=ORIGIN_HEADER)
assert get_resp.status_code == 404