2026-06-13 16:32:33 +02:00
|
|
|
# retoor <retoor@molodetz.nl>
|
feat: add api key auth, devii agent, openai gateway, and admin service management
This commit introduces a comprehensive set of new features including API key authentication with CLI management commands (get, reset, backfill), a Devii agentic assistant with WebSocket terminal and session bootstrap, an OpenAI-compatible LLM gateway service, and an admin service management panel. It also adds Playwright browser automation for bot support, configures internal gateway URLs, refactors content editing/deletion to support JSON API responses, and updates documentation across AGENTS.md, README.md, and the developer docs site.
2026-06-08 17:38:33 +02:00
|
|
|
|
2026-06-13 16:32:33 +02:00
|
|
|
import time
|
feat: add api key auth, devii agent, openai gateway, and admin service management
This commit introduces a comprehensive set of new features including API key authentication with CLI management commands (get, reset, backfill), a Devii agentic assistant with WebSocket terminal and session bootstrap, an OpenAI-compatible LLM gateway service, and an admin service management panel. It also adds Playwright browser automation for bot support, configures internal gateway URLs, refactors content editing/deletion to support JSON API responses, and updates documentation across AGENTS.md, README.md, and the developer docs site.
2026-06-08 17:38:33 +02:00
|
|
|
import requests
|
|
|
|
|
from tests.conftest import BASE_URL
|
|
|
|
|
from devplacepy.database import get_table
|
|
|
|
|
from devplacepy.docs_api import API_GROUPS, build_services_group
|
|
|
|
|
from devplacepy.services.manager import service_manager
|
2026-06-13 16:32:33 +02:00
|
|
|
JSON_auth_matrix = {"Accept": "application/json"}
|
|
|
|
|
_counter_auth_matrix = [0]
|
feat: add api key auth, devii agent, openai gateway, and admin service management
This commit introduces a comprehensive set of new features including API key authentication with CLI management commands (get, reset, backfill), a Devii agentic assistant with WebSocket terminal and session bootstrap, an OpenAI-compatible LLM gateway service, and an admin service management panel. It also adds Playwright browser automation for bot support, configures internal gateway URLs, refactors content editing/deletion to support JSON API responses, and updates documentation across AGENTS.md, README.md, and the developer docs site.
2026-06-08 17:38:33 +02:00
|
|
|
LOGIN_REDIRECT = "/auth/login"
|
|
|
|
|
FEED_REDIRECT = "/feed"
|
|
|
|
|
JSON_BODY_OVERRIDES = {
|
2026-06-09 18:48:08 +02:00
|
|
|
"push-register": {
|
|
|
|
|
"endpoint": "https://example.test/p",
|
|
|
|
|
"keys": {"p256dh": "a", "auth": "b"},
|
|
|
|
|
},
|
feat: add api key auth, devii agent, openai gateway, and admin service management
This commit introduces a comprehensive set of new features including API key authentication with CLI management commands (get, reset, backfill), a Devii agentic assistant with WebSocket terminal and session bootstrap, an OpenAI-compatible LLM gateway service, and an admin service management panel. It also adds Playwright browser automation for bot support, configures internal gateway URLs, refactors content editing/deletion to support JSON API responses, and updates documentation across AGENTS.md, README.md, and the developer docs site.
2026-06-08 17:38:33 +02:00
|
|
|
"gateway-chat": {"model": "x", "messages": [{"role": "user", "content": "hi"}]},
|
|
|
|
|
}
|
2026-06-13 16:32:33 +02:00
|
|
|
def _signup_auth_matrix(role="Member"):
|
|
|
|
|
_counter_auth_matrix[0] += 1
|
|
|
|
|
name = f"authmx{int(time.time() * 1000)}{_counter_auth_matrix[0]}"
|
2026-06-09 18:48:08 +02:00
|
|
|
requests.post(
|
|
|
|
|
f"{BASE_URL}/auth/signup",
|
|
|
|
|
data={
|
|
|
|
|
"username": name,
|
|
|
|
|
"email": f"{name}@t.dev",
|
|
|
|
|
"password": "secret123",
|
|
|
|
|
"confirm_password": "secret123",
|
Add the trust and safety subsystem and the App Store compliance work
Implements the moderation and consent obligations a social platform carries,
so the web version and any client that speaks to it enforce the same rules.
Moderation core (services/moderation/, database/moderation.py): a reportable
target registry, the content filter and its choke points, the report queue with
atomic resolution, enforcement actions, consent tracking, maturity gating, and
account deletion with a grace window.
Surfaces: POST /reports plus the member report list, /admin/moderation and the
per-report admin view, /workspaces, terms acceptance at /auth/terms, consent and
account deletion under /profile, the report button and dialog partials, the
maturity gate, and the moderation stylesheet and ReportDialog client.
Every user-generated surface stays reportable by construction: new content tables
are registered in REPORTABLE_TARGETS or listed in UNREPORTABLE_TABLES with a
reason, and the registry test fails the suite on anything left unclassified.
Docs: community guidelines, content moderation, intellectual property, privacy,
terms, contact, and the admin-only moderation operations page, plus the
moderation API group and the Devii moderation actions.
Compliance record: applecomp.md is the requirement register, applechanges.md the
gap analysis against this codebase, and appleimpl.md the implementation design
they resolve to.
Tests cover the report flow, admin moderation, consent, account deletion, terms
acceptance, workspaces, and the registry invariant across the unit, api, and e2e
tiers.
2026-08-09 00:18:20 +02:00
|
|
|
"birth_date": "1990-01-01",
|
|
|
|
|
"accept_terms": "1",
|
2026-06-09 18:48:08 +02:00
|
|
|
},
|
|
|
|
|
allow_redirects=True,
|
|
|
|
|
)
|
feat: add api key auth, devii agent, openai gateway, and admin service management
This commit introduces a comprehensive set of new features including API key authentication with CLI management commands (get, reset, backfill), a Devii agentic assistant with WebSocket terminal and session bootstrap, an OpenAI-compatible LLM gateway service, and an admin service management panel. It also adds Playwright browser automation for bot support, configures internal gateway URLs, refactors content editing/deletion to support JSON API responses, and updates documentation across AGENTS.md, README.md, and the developer docs site.
2026-06-08 17:38:33 +02:00
|
|
|
row = get_table("users").find_one(username=name)
|
|
|
|
|
get_table("users").update({"uid": row["uid"], "role": role}, ["uid"])
|
|
|
|
|
return get_table("users").find_one(username=name)["api_key"]
|
|
|
|
|
def _all_endpoints():
|
|
|
|
|
endpoints = []
|
|
|
|
|
for group in API_GROUPS:
|
|
|
|
|
endpoints.extend(group["endpoints"])
|
2026-06-09 18:48:08 +02:00
|
|
|
endpoints.extend(
|
|
|
|
|
build_services_group(service_manager.describe_all(), BASE_URL)["endpoints"]
|
|
|
|
|
)
|
feat: add api key auth, devii agent, openai gateway, and admin service management
This commit introduces a comprehensive set of new features including API key authentication with CLI management commands (get, reset, backfill), a Devii agentic assistant with WebSocket terminal and session bootstrap, an OpenAI-compatible LLM gateway service, and an admin service management panel. It also adds Playwright browser automation for bot support, configures internal gateway URLs, refactors content editing/deletion to support JSON API responses, and updates documentation across AGENTS.md, README.md, and the developer docs site.
2026-06-08 17:38:33 +02:00
|
|
|
return endpoints
|
|
|
|
|
def _build(endpoint):
|
|
|
|
|
path = endpoint["path"]
|
|
|
|
|
params, data, files = {}, {}, None
|
|
|
|
|
for param in endpoint["params"]:
|
|
|
|
|
example = param.get("example") or ""
|
|
|
|
|
location = param["location"]
|
|
|
|
|
if location == "path":
|
|
|
|
|
value = str(example)
|
|
|
|
|
if "{{" in value or not value:
|
|
|
|
|
value = "x"
|
|
|
|
|
path = path.replace("{" + param["name"] + "}", value)
|
|
|
|
|
elif location == "query":
|
|
|
|
|
if example:
|
|
|
|
|
params[param["name"]] = example
|
|
|
|
|
elif location == "form":
|
|
|
|
|
if param["type"] == "file":
|
|
|
|
|
files = {"file": ("probe.txt", b"hello", "text/plain")}
|
|
|
|
|
else:
|
|
|
|
|
data[param["name"]] = param.get("example") or "x"
|
|
|
|
|
json_body = None
|
|
|
|
|
if endpoint["encoding"] == "json":
|
|
|
|
|
json_body = JSON_BODY_OVERRIDES.get(
|
|
|
|
|
endpoint["id"],
|
2026-06-09 18:48:08 +02:00
|
|
|
{
|
|
|
|
|
p["name"]: (p.get("example") or "x")
|
|
|
|
|
for p in endpoint["params"]
|
|
|
|
|
if p["location"] == "json"
|
|
|
|
|
},
|
feat: add api key auth, devii agent, openai gateway, and admin service management
This commit introduces a comprehensive set of new features including API key authentication with CLI management commands (get, reset, backfill), a Devii agentic assistant with WebSocket terminal and session bootstrap, an OpenAI-compatible LLM gateway service, and an admin service management panel. It also adds Playwright browser automation for bot support, configures internal gateway URLs, refactors content editing/deletion to support JSON API responses, and updates documentation across AGENTS.md, README.md, and the developer docs site.
2026-06-08 17:38:33 +02:00
|
|
|
)
|
|
|
|
|
if endpoint["encoding"] == "multipart" and files is None:
|
|
|
|
|
files = {"file": ("probe.txt", b"hello", "text/plain")}
|
|
|
|
|
return path, params, data, json_body, files
|
|
|
|
|
def _call(endpoint, headers):
|
|
|
|
|
path, params, data, json_body, files = _build(endpoint)
|
|
|
|
|
kwargs = dict(headers=headers, params=params, allow_redirects=False, timeout=15)
|
|
|
|
|
if json_body is not None:
|
|
|
|
|
kwargs["json"] = json_body
|
|
|
|
|
elif files is not None:
|
|
|
|
|
kwargs["files"] = files
|
|
|
|
|
if data:
|
|
|
|
|
kwargs["data"] = data
|
|
|
|
|
elif data:
|
|
|
|
|
kwargs["data"] = data
|
|
|
|
|
return requests.request(endpoint["method"], f"{BASE_URL}{path}", **kwargs)
|
2026-06-14 09:48:10 +02:00
|
|
|
def _clear_probe_jobs():
|
|
|
|
|
from devplacepy.database import refresh_snapshot
|
|
|
|
|
|
|
|
|
|
refresh_snapshot()
|
|
|
|
|
jobs = get_table("jobs")
|
|
|
|
|
for row in list(jobs.find()):
|
|
|
|
|
jobs.delete(uid=row["uid"])
|
|
|
|
|
|
|
|
|
|
|
feat: add api key auth, devii agent, openai gateway, and admin service management
This commit introduces a comprehensive set of new features including API key authentication with CLI management commands (get, reset, backfill), a Devii agentic assistant with WebSocket terminal and session bootstrap, an OpenAI-compatible LLM gateway service, and an admin service management panel. It also adds Playwright browser automation for bot support, configures internal gateway URLs, refactors content editing/deletion to support JSON API responses, and updates documentation across AGENTS.md, README.md, and the developer docs site.
2026-06-08 17:38:33 +02:00
|
|
|
def _redirects_to(response, target):
|
2026-06-09 18:48:08 +02:00
|
|
|
return response.status_code in (
|
|
|
|
|
302,
|
|
|
|
|
303,
|
|
|
|
|
307,
|
|
|
|
|
308,
|
|
|
|
|
) and target in response.headers.get("location", "")
|
feat: add api key auth, devii agent, openai gateway, and admin service management
This commit introduces a comprehensive set of new features including API key authentication with CLI management commands (get, reset, backfill), a Devii agentic assistant with WebSocket terminal and session bootstrap, an OpenAI-compatible LLM gateway service, and an admin service management panel. It also adds Playwright browser automation for bot support, configures internal gateway URLs, refactors content editing/deletion to support JSON API responses, and updates documentation across AGENTS.md, README.md, and the developer docs site.
2026-06-08 17:38:33 +02:00
|
|
|
def _is_auth_rejected(response):
|
|
|
|
|
return response.status_code == 401 or _redirects_to(response, LOGIN_REDIRECT)
|
|
|
|
|
def _is_role_rejected(response):
|
|
|
|
|
return response.status_code == 403 or _redirects_to(response, FEED_REDIRECT)
|
|
|
|
|
def _is_allowed(response):
|
|
|
|
|
return not _is_auth_rejected(response) and response.status_code != 403
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_documented_minimal_role_matches_enforcement(seeded_db):
|
|
|
|
|
# depend on seeded_db so alice_test keeps the is_first -> Admin slot; our signups
|
|
|
|
|
# below are never the first user and cannot demote the suite's admin fixture.
|
2026-06-13 16:32:33 +02:00
|
|
|
member_key = _signup_auth_matrix("Member")
|
|
|
|
|
member = {**JSON_auth_matrix, "X-API-KEY": member_key}
|
feat: add api key auth, devii agent, openai gateway, and admin service management
This commit introduces a comprehensive set of new features including API key authentication with CLI management commands (get, reset, backfill), a Devii agentic assistant with WebSocket terminal and session bootstrap, an OpenAI-compatible LLM gateway service, and an admin service management panel. It also adds Playwright browser automation for bot support, configures internal gateway URLs, refactors content editing/deletion to support JSON API responses, and updates documentation across AGENTS.md, README.md, and the developer docs site.
2026-06-08 17:38:33 +02:00
|
|
|
|
|
|
|
|
endpoints = _all_endpoints()
|
|
|
|
|
assert len(endpoints) >= 50
|
|
|
|
|
|
|
|
|
|
failures = []
|
2026-06-14 09:48:10 +02:00
|
|
|
try:
|
|
|
|
|
for endpoint in endpoints:
|
|
|
|
|
auth = endpoint["auth"]
|
|
|
|
|
label = (
|
|
|
|
|
f"{endpoint['method']} {endpoint['path']} ({endpoint['id']}, doc={auth})"
|
2026-06-09 18:48:08 +02:00
|
|
|
)
|
2026-06-14 09:48:10 +02:00
|
|
|
anon = _call(endpoint, JSON_auth_matrix)
|
feat: add api key auth, devii agent, openai gateway, and admin service management
This commit introduces a comprehensive set of new features including API key authentication with CLI management commands (get, reset, backfill), a Devii agentic assistant with WebSocket terminal and session bootstrap, an OpenAI-compatible LLM gateway service, and an admin service management panel. It also adds Playwright browser automation for bot support, configures internal gateway URLs, refactors content editing/deletion to support JSON API responses, and updates documentation across AGENTS.md, README.md, and the developer docs site.
2026-06-08 17:38:33 +02:00
|
|
|
|
2026-06-14 09:48:10 +02:00
|
|
|
if auth == "public":
|
|
|
|
|
if not _is_allowed(anon):
|
|
|
|
|
failures.append(
|
|
|
|
|
f"{label}: public but anonymous was rejected ({anon.status_code})"
|
|
|
|
|
)
|
|
|
|
|
continue
|
feat: add api key auth, devii agent, openai gateway, and admin service management
This commit introduces a comprehensive set of new features including API key authentication with CLI management commands (get, reset, backfill), a Devii agentic assistant with WebSocket terminal and session bootstrap, an OpenAI-compatible LLM gateway service, and an admin service management panel. It also adds Playwright browser automation for bot support, configures internal gateway URLs, refactors content editing/deletion to support JSON API responses, and updates documentation across AGENTS.md, README.md, and the developer docs site.
2026-06-08 17:38:33 +02:00
|
|
|
|
2026-06-14 09:48:10 +02:00
|
|
|
if not _is_auth_rejected(anon):
|
2026-06-09 18:48:08 +02:00
|
|
|
failures.append(
|
2026-06-14 09:48:10 +02:00
|
|
|
f"{label}: requires {auth} but anonymous was NOT rejected ({anon.status_code})"
|
2026-06-09 18:48:08 +02:00
|
|
|
)
|
feat: add api key auth, devii agent, openai gateway, and admin service management
This commit introduces a comprehensive set of new features including API key authentication with CLI management commands (get, reset, backfill), a Devii agentic assistant with WebSocket terminal and session bootstrap, an OpenAI-compatible LLM gateway service, and an admin service management panel. It also adds Playwright browser automation for bot support, configures internal gateway URLs, refactors content editing/deletion to support JSON API responses, and updates documentation across AGENTS.md, README.md, and the developer docs site.
2026-06-08 17:38:33 +02:00
|
|
|
|
2026-06-14 09:48:10 +02:00
|
|
|
if auth == "user" and endpoint["method"] == "GET":
|
|
|
|
|
mem = _call(endpoint, member)
|
|
|
|
|
if not _is_allowed(mem):
|
|
|
|
|
failures.append(
|
|
|
|
|
f"{label}: documented user but a member was rejected ({mem.status_code})"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if auth == "admin":
|
|
|
|
|
mem = _call(endpoint, member)
|
|
|
|
|
if not _is_role_rejected(mem):
|
|
|
|
|
failures.append(
|
|
|
|
|
f"{label}: documented admin but a non-admin member was NOT rejected ({mem.status_code})"
|
|
|
|
|
)
|
|
|
|
|
finally:
|
|
|
|
|
_clear_probe_jobs()
|
|
|
|
|
|
2026-06-09 18:48:08 +02:00
|
|
|
assert not failures, "Auth enforcement does not match documentation:\n" + "\n".join(
|
|
|
|
|
failures
|
|
|
|
|
)
|
feat: add api key auth, devii agent, openai gateway, and admin service management
This commit introduces a comprehensive set of new features including API key authentication with CLI management commands (get, reset, backfill), a Devii agentic assistant with WebSocket terminal and session bootstrap, an OpenAI-compatible LLM gateway service, and an admin service management panel. It also adds Playwright browser automation for bot support, configures internal gateway URLs, refactors content editing/deletion to support JSON API responses, and updates documentation across AGENTS.md, README.md, and the developer docs site.
2026-06-08 17:38:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_every_endpoint_documents_minimal_role(seeded_db):
|
|
|
|
|
for endpoint in _all_endpoints():
|
|
|
|
|
assert endpoint["min_role"] in ("Public", "Member", "Admin"), endpoint["id"]
|