[claude] add testkit coverage for relay moderation endpoints (#39) #62

Merged
Rockachopa merged 1 commits from claude/issue-39 into main 2026-03-23 14:51:22 +00:00
Collaborator

Fixes #39

Summary

The relay event moderation feature (shadow-queue + Timmy AI auto-review) was already fully implemented across the codebase:

  • relay_event_queue DB table with all required columns
  • POST /api/relay/policy with elite bypass and non-elite shadow-queue logic
  • injectEvent() helper for strfry HTTP import
  • ModerationService with enqueue(), autoReview(), decide(), processPending()
  • Background poll loop (30s interval, 10 events per cycle)
  • Admin endpoints: GET /api/admin/relay/queue, approve, reject
  • GET /api/admin/relay/stats with event counts by status
  • Admin HTML dashboard at /admin/relay

This PR adds 10 testkit tests (T41–T50) to verify all relay moderation and admin relay endpoints:

  • T41: Relay policy health check (GET /api/relay/policy)
  • T42: Admin relay stats field verification
  • T43: Admin relay queue list structure
  • T44: Invalid status filter → 400
  • T45–T46: Approve/reject non-existent event → 404
  • T47: Admin grant write access + verify in accounts list
  • T48: Admin revoke access
  • T49–T50: Input validation guards (invalid pubkey, invalid access level)

Admin tests are gated on endpoint accessibility and skip gracefully when ADMIN_TOKEN is not configured and localhost fallback is unavailable.

Test plan

  • curl -s $BASE/api/testkit | bash passes with all new T41–T50 tests
  • Existing T1–T40 tests continue to pass
  • Admin tests skip cleanly when ADMIN_TOKEN is not set and not running from localhost

🤖 Generated with Claude Code

Fixes #39 ## Summary The relay event moderation feature (shadow-queue + Timmy AI auto-review) was already fully implemented across the codebase: - `relay_event_queue` DB table with all required columns - `POST /api/relay/policy` with elite bypass and non-elite shadow-queue logic - `injectEvent()` helper for strfry HTTP import - `ModerationService` with `enqueue()`, `autoReview()`, `decide()`, `processPending()` - Background poll loop (30s interval, 10 events per cycle) - Admin endpoints: `GET /api/admin/relay/queue`, approve, reject - `GET /api/admin/relay/stats` with event counts by status - Admin HTML dashboard at `/admin/relay` This PR adds **10 testkit tests (T41–T50)** to verify all relay moderation and admin relay endpoints: - **T41**: Relay policy health check (GET /api/relay/policy) - **T42**: Admin relay stats field verification - **T43**: Admin relay queue list structure - **T44**: Invalid status filter → 400 - **T45–T46**: Approve/reject non-existent event → 404 - **T47**: Admin grant write access + verify in accounts list - **T48**: Admin revoke access - **T49–T50**: Input validation guards (invalid pubkey, invalid access level) Admin tests are gated on endpoint accessibility and skip gracefully when `ADMIN_TOKEN` is not configured and localhost fallback is unavailable. ## Test plan - [ ] `curl -s $BASE/api/testkit | bash` passes with all new T41–T50 tests - [ ] Existing T1–T40 tests continue to pass - [ ] Admin tests skip cleanly when ADMIN_TOKEN is not set and not running from localhost 🤖 Generated with [Claude Code](https://claude.com/claude-code)
claude added 1 commit 2026-03-23 02:08:23 +00:00
test: add testkit coverage for relay moderation endpoints (T41–T50)
Some checks failed
CI / Typecheck & Lint (pull_request) Failing after 0s
e2b850e122
Adds 10 new testkit tests covering the relay moderation shadow-queue
and admin relay management endpoints introduced by the moderation
feature:

- T41: GET /api/relay/policy health check
- T42: GET /api/admin/relay/stats field verification
- T43: GET /api/admin/relay/queue list structure
- T44: Invalid status filter → 400
- T45–T46: Approve/reject non-existent event → 404
- T47: Admin grant write access + verify in accounts list
- T48: Admin revoke access
- T49–T50: Input validation guards (invalid pubkey, invalid level)

Admin tests are gated on endpoint accessibility — they skip gracefully
when ADMIN_TOKEN is not set and localhost fallback is unavailable.

Refs #39

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Rockachopa merged commit c191d556b1 into main 2026-03-23 14:51:22 +00:00
This repo is archived. You cannot comment on pull requests.