mirror of
https://github.com/0xWheatyz/handler.git
synced 2026-08-30 07:56:24 +00:00
eba0e19ec9
Implements the Phase 1 MVP from the README: a stateless control layer + HTTP API over a centralized database, with hook-enforced test/push gates. - DB layer: SQLAlchemy Core, one schema rendering both Postgres (BIGSERIAL / TIMESTAMPTZ / JSONB) and SQLite (INTEGER PK / TEXT / JSON) via portable types; native ON CONFLICT DO UPDATE checkmark upsert on both dialects. - Alembic dual-dialect migrations (render_as_batch for SQLite); tests run a real `alembic upgrade head`. - FastAPI: projects/agents/checkmark/log/answer/resume + shared log/context routes, single global bearer token, higher-trust token gating shared-context writes, project isolation on every route. - Hooks (`python -m handler.hooks <event>`): Stop test gate (block on red), PreToolUse AskUserQuestion defer + `git push` gate (tests then throwaway build), Notification generic webhook (no-op without WEBHOOK_URL). Identity via env injected at spawn; verify is the mock seam. - Control CLI: spawn/list/attach/kill, hard `.mise.toml [tasks.test]` gate, generated per-agent settings.json, identity + DATABASE_URL injected via tmux; tmux is the mock seam. - 45 tests (SQLite), ruff clean. Live claude/tmux/mise spawning deferred behind the mocked seams. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W5ZuS5pV1NS6eKsRZHXonY
21 lines
516 B
Python
21 lines
516 B
Python
"""Bearer auth on every route."""
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
def test_missing_token_is_401(client):
|
|
assert client.get("/projects").status_code == 401
|
|
|
|
|
|
def test_wrong_token_is_401(client):
|
|
r = client.get("/projects", headers={"Authorization": "Bearer nope"})
|
|
assert r.status_code == 401
|
|
|
|
|
|
def test_valid_token_is_200(client, auth):
|
|
assert client.get("/projects", headers=auth).status_code == 200
|
|
|
|
|
|
def test_health_needs_no_auth(client):
|
|
assert client.get("/health").status_code == 200
|