Initial commit: site monorepo with API, web, and infra.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
def test_wesp_admin_users_shape(client):
|
||||
login = client.post(
|
||||
"/api/v1/auth/login",
|
||||
json={"email": "admin@compton.example", "password": "Admin1234"},
|
||||
)
|
||||
token = login.json()["access_token"]
|
||||
headers = {"Authorization": f"Bearer {token}"}
|
||||
|
||||
response = client.get("/api/admin/users", headers=headers)
|
||||
assert response.status_code == 200
|
||||
body = response.json()
|
||||
assert body["status"] == "success"
|
||||
assert isinstance(body["users"], list)
|
||||
assert body["users"]
|
||||
assert "login" in body["users"][0]
|
||||
|
||||
|
||||
def test_wesp_admin_summary_and_stubs(client):
|
||||
login = client.post(
|
||||
"/api/v1/auth/login",
|
||||
json={"email": "admin@compton.example", "password": "Admin1234"},
|
||||
)
|
||||
token = login.json()["access_token"]
|
||||
headers = {"Authorization": f"Bearer {token}"}
|
||||
|
||||
summary = client.get("/api/admin/summary", headers=headers)
|
||||
assert summary.status_code == 200
|
||||
data = summary.json()
|
||||
assert data["status"] == "success"
|
||||
assert "counts" in data
|
||||
assert "sync" in data
|
||||
|
||||
metrics = client.get("/api/admin/system-metrics", headers=headers)
|
||||
assert metrics.status_code == 200
|
||||
assert metrics.json()["status"] == "success"
|
||||
assert "metrics" in metrics.json()
|
||||
|
||||
network = client.get("/api/admin/network-settings", headers=headers)
|
||||
assert network.status_code == 200
|
||||
assert network.json()["network"]["public_base_url"]
|
||||
|
||||
sync_diag = client.get("/api/admin/sync-diagnostics", headers=headers)
|
||||
assert sync_diag.status_code == 200
|
||||
assert sync_diag.json()["status"] == "success"
|
||||
|
||||
|
||||
def test_wesp_admin_server_log(client):
|
||||
login = client.post(
|
||||
"/api/v1/auth/login",
|
||||
json={"email": "admin@compton.example", "password": "Admin1234"},
|
||||
)
|
||||
headers = {"Authorization": f"Bearer {login.json()['access_token']}"}
|
||||
response = client.get("/api/admin/server-log?lines=10", headers=headers)
|
||||
assert response.status_code == 200
|
||||
body = response.json()
|
||||
assert body["status"] in {"success", "error"}
|
||||
assert "lines" in body
|
||||
|
||||
download = client.get("/api/admin/server-log/download", headers=headers)
|
||||
assert download.status_code == 200
|
||||
assert "text/plain" in (download.headers.get("content-type") or "")
|
||||
|
||||
|
||||
def test_wesp_admin_client_logs_index(client):
|
||||
login = client.post(
|
||||
"/api/v1/auth/login",
|
||||
json={"email": "admin@compton.example", "password": "Admin1234"},
|
||||
)
|
||||
headers = {"Authorization": f"Bearer {login.json()['access_token']}"}
|
||||
response = client.get("/api/admin/client-uploaded-logs", headers=headers)
|
||||
assert response.status_code == 200
|
||||
body = response.json()
|
||||
assert body["status"] == "success"
|
||||
assert isinstance(body["clients"], list)
|
||||
|
||||
|
||||
def test_wesp_admin_ui_activity(client):
|
||||
login = client.post(
|
||||
"/api/v1/auth/login",
|
||||
json={"email": "admin@compton.example", "password": "Admin1234"},
|
||||
)
|
||||
token = login.json()["access_token"]
|
||||
headers = {"Authorization": f"Bearer {token}"}
|
||||
|
||||
response = client.post(
|
||||
"/api/admin/ui-activity",
|
||||
headers=headers,
|
||||
json={"text": "test event", "level": "ok"},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert response.json()["status"] == "success"
|
||||
|
||||
feed = client.get("/api/admin/activity-feed", headers=headers)
|
||||
assert feed.status_code == 200
|
||||
body = feed.json()
|
||||
assert body["status"] == "success"
|
||||
assert isinstance(body["entries"], list)
|
||||
Reference in New Issue
Block a user