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

37 lines
1.2 KiB
Rust

mod support;
use lawsynth_gateway::HttpRequest;
use lawsynth_gateway::auth::{AuthDecision, authorize};
#[test]
fn public_routes_do_not_require_a_token() {
assert_eq!(authorize(false, None), AuthDecision::Authorized);
}
#[test]
fn protected_route_missing_header_is_rejected() {
assert_eq!(authorize(true, None), AuthDecision::Missing);
}
#[test]
fn bearer_scheme_is_case_insensitive() {
assert_eq!(authorize(true, Some("Bearer token-value")), AuthDecision::Authorized);
assert_eq!(authorize(true, Some("bEaReR token-value")), AuthDecision::Authorized);
}
#[test]
fn malformed_credentials_are_rejected() {
assert_eq!(authorize(true, Some("Basic abc")), AuthDecision::Malformed);
assert_eq!(authorize(true, Some("Bearer ")), AuthDecision::Malformed);
}
#[test]
fn gateway_rejects_protected_route_without_token() {
// No upstream is contacted; the 401 is produced at the edge.
let gateway = support::gateway("127.0.0.1:9", 0);
let request = HttpRequest::new("POST", "/v1/runs", Vec::new(), Vec::new());
let response = gateway.handle(&request, "127.0.0.1");
assert_eq!(response.status, 401);
assert_eq!(response.header("www-authenticate"), Some("Bearer"));
}