Skip to content

fix(tests): inject the outbound policy and licence instead of setting env vars (#445) - #505

Open
mblaauw wants to merge 1 commit into
mainfrom
fix/445-test-environment
Open

mblaauw wants to merge 1 commit into
mainfrom
fix/445-test-environment

Conversation

@mblaauw

@mblaauw mblaauw commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Closes #445 (finding 1; finding 2 was fixed in #472).

Summary

Integration tests set ORBIT_OUTBOUND_ALLOWED_HOSTS=127.0.0.1 (the outcome-writer
test and, through a Once, the output-delivery tests) and ORBIT_LICENSE_PUBLIC_KEYS
process-wide and never unset them. Every outbound check read the environment on each
call, so whether the Kubernetes guard test saw loopback refused depended on which test
ran first. The S3 delivery tests only passed because of that leak.

  • AppState gains outbound: OutboundPolicy, read once from ORBIT_OUTBOUND_* at
    startup. Work sources (dispatcher, team outcomes), output delivery and credential
    checks, provider and connection probes, connection URL validation and portable import
    use it instead of OutboundPolicy::from_env() / guarded_client.
  • S3Client::with_policy lets the API pass its policy; S3Client::new (the worker)
    still reads the environment. The orbit-s3 unit tests use the injected policy too.
  • Tests: test_app_allowing_loopback exempts 127.0.0.1 in one app's state only;
    licensed_test_app installs a verified licence status instead of signing a token
    against an env-supplied key. New outbound_policy_is_per_app_state shows a
    loopback-allowing app and a default app side by side. No std::env::set_var is left
    in crates/*/tests.
  • AGENTS.md: connector probes use the API's policy.

Finding 2 was fixed in #472, so this completes #445. The Kubernetes connector crate still reads the policy from
the environment (only the worker and the API's Kubernetes test path use it; #497 moves
it onto the client config).

Testing

  • cargo fmt --check, clippy --workspace --all-targets -D warnings: clean
  • cargo test --workspace with a database: 762 passed, 0 failed
  • grep std::env::set_var crates/*/tests: none
  • New outbound_policy_is_per_app_state; the Kubernetes guard test passes alone and in a single-threaded run with the 13 delivery tests
  • pnpm docs:check: passed

Removing the leak exposed three S3 delivery tests that only passed because another test had allowed loopback; S3Client::with_policy fixes that. Conflicts with #497 in catalog.rs and import_portable.rs (the validate_connection_config rename); whichever merges second needs a merge.

🤖 Generated with Claude Code

… env vars (#445)

Integration tests set ORBIT_OUTBOUND_ALLOWED_HOSTS=127.0.0.1 (the outcome-writer
test and, through a Once, the output-delivery tests) and ORBIT_LICENSE_PUBLIC_KEYS
process-wide and never unset them. Every outbound check read the environment on each
call, so whether the Kubernetes guard test saw loopback refused depended on which test
ran first. The S3 delivery tests only passed because of that leak.

- AppState gains `outbound: OutboundPolicy`, read once from ORBIT_OUTBOUND_* at
  startup. Work sources (dispatcher, team outcomes), output delivery and credential
  checks, provider and connection probes, connection URL validation and portable import
  use it instead of `OutboundPolicy::from_env()` / `guarded_client`.
- `S3Client::with_policy` lets the API pass its policy; `S3Client::new` (the worker)
  still reads the environment. The orbit-s3 unit tests use the injected policy too.
- Tests: `test_app_allowing_loopback` exempts 127.0.0.1 in one app's state only;
  `licensed_test_app` installs a verified licence status instead of signing a token
  against an env-supplied key. New `outbound_policy_is_per_app_state` shows a
  loopback-allowing app and a default app side by side. No `std::env::set_var` is left
  in crates/*/tests.
- AGENTS.md: connector probes use the API's policy.

Finding 2 was fixed in #472, so this completes #445. The Kubernetes connector crate still reads the policy from
the environment (only the worker and the API's Kubernetes test path use it; #497 moves
it onto the client config).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integration tests share process environment and can be skipped silently: outbound-allowlist leak between tests, and no CI check that database tests ran

1 participant