caelum0x bd58228c14 feat: complete manifest services layer — decomposed modules + Rust gateway
Build the manifest's full decomposed services architecture as real, tested code:
- scheduler: 16 modules (queue/pool/policy/quota/placement/recovery + metrics/
  events/backoff/health/fairness/shutdown + honest nats seam) — 130 tests
- worker: 16 modules (execute/lease/resources/limits + heartbeat/events/telemetry/
  sandbox/recovery/cleanup/upload/artifacts + honest plugins seam) — 52 tests
- api: 20 modules (auth/authz/middleware + per-resource handlers + telemetry/
  facades), app.py now a thin composition root — 98 tests
- gateway: new std-only Rust reverse-proxy crate (proxy/routing/auth/cors/
  rate_limit/retry/timeouts/health/metrics/events/tracing + honest tls seam) — 110 tests

Every one of the 3,161 manifest files now exists. Extractions are behavior-
preserving (all prior tests green); new modules add real capability; nats/tls/
plugins/sandbox are honest documented seams, not fakes.

Rust workspace 352->605 tests; API 35->98. clippy -D warnings + fmt clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-17 19:55:26 +03:00

45 lines
1.6 KiB
Rust

use lawsynth_gateway::HttpResponse;
use lawsynth_gateway::cors::{OriginDecision, apply, classify, preflight};
fn allowlist() -> Vec<String> {
vec!["https://app.lawsynth.dev".to_owned()]
}
#[test]
fn only_exact_origins_are_allowed() {
assert_eq!(classify(Some("https://app.lawsynth.dev"), &allowlist()), OriginDecision::Allowed);
assert_eq!(
classify(Some("https://app.lawsynth.dev.evil"), &allowlist()),
OriginDecision::Denied
);
assert_eq!(classify(None, &allowlist()), OriginDecision::NotCrossOrigin);
}
#[test]
fn preflight_for_allowed_origin_is_a_204_with_headers() {
let response = preflight("OPTIONS", Some("https://app.lawsynth.dev"), &allowlist()).unwrap();
assert_eq!(response.status, 204);
assert_eq!(response.header("access-control-allow-origin"), Some("https://app.lawsynth.dev"));
assert_eq!(response.header("access-control-allow-credentials"), Some("true"));
}
#[test]
fn preflight_for_denied_origin_is_forbidden() {
let response = preflight("OPTIONS", Some("https://evil.example"), &allowlist()).unwrap();
assert_eq!(response.status, 403);
}
#[test]
fn non_preflight_requests_are_not_intercepted() {
assert!(preflight("GET", Some("https://app.lawsynth.dev"), &allowlist()).is_none());
}
#[test]
fn apply_reflects_only_allowed_origins() {
let allowed = apply(HttpResponse::empty(200), Some("https://app.lawsynth.dev"), &allowlist());
assert_eq!(allowed.header("access-control-allow-origin"), Some("https://app.lawsynth.dev"));
let denied = apply(HttpResponse::empty(200), Some("https://evil.example"), &allowlist());
assert_eq!(denied.header("access-control-allow-origin"), None);
}