lawsynth/services/gateway/tests/routing_test.rs
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

48 lines
1.4 KiB
Rust

use lawsynth_gateway::{RouteDecision, resolve_route};
#[test]
fn public_health_route_needs_no_token() {
assert_eq!(
resolve_route("GET", "/v1/health", "/v1"),
RouteDecision::Proxy { protected: false }
);
}
#[test]
fn protected_routes_are_marked_protected() {
assert_eq!(
resolve_route("POST", "/v1/artifacts", "/v1"),
RouteDecision::Proxy { protected: true }
);
assert_eq!(
resolve_route("GET", "/v1/artifacts/deadbeef", "/v1"),
RouteDecision::Proxy { protected: true }
);
}
#[test]
fn unknown_paths_are_not_found() {
assert_eq!(resolve_route("GET", "/v1/does-not-exist", "/v1"), RouteDecision::NotFound);
assert_eq!(resolve_route("GET", "/healthz", "/v1"), RouteDecision::NotFound);
}
#[test]
fn known_path_unknown_method_reports_allow() {
match resolve_route("PATCH", "/v1/runs/abc", "/v1") {
RouteDecision::MethodNotAllowed { allow } => {
assert!(allow.contains(&"GET".to_owned()));
assert!(allow.contains(&"DELETE".to_owned()));
}
other => panic!("expected method-not-allowed, got {other:?}"),
}
}
#[test]
fn routing_honours_a_custom_prefix() {
assert_eq!(
resolve_route("GET", "/api/health", "/api"),
RouteDecision::Proxy { protected: false }
);
assert_eq!(resolve_route("GET", "/v1/health", "/api"), RouteDecision::NotFound);
}