Core Testing Strategy
Palyra’s testing is categorized into four primary domains:- Unit & Functional Tests: Located within individual crates (e.g.,
palyra-vault,palyra-identity) to verify core logic like envelope encryption crates/palyra-vault/src/lib.rs#1-20 and certificate management crates/palyra-identity/src/pairing/persistence.rs#56-66. - Daemon Integration Tests: End-to-end tests for
palyradthat exercise the REST/Admin API, gRPC gateway, and persistence layers using dynamic port allocation to prevent collision crates/palyra-daemon/tests/admin_surface.rs#31-33. - CLI Regression & Parity: Tests that verify the
palyraCLI correctly interacts with the daemon and maintains backward compatibility with protocol contracts crates/palyra-cli/tests/daemon_status.rs#19-37. - Fuzzing: Targeted libFuzzer campaigns against high-risk parsers (JSON, Webhooks, Workspace Patches) to identify memory safety issues or edge-case crashes.
Integration and Regression Tests
The integration suite focuses on the lifecycle of thepalyrad process. Tests in crates/palyra-daemon/tests/ typically utilize a ChildGuard pattern to ensure that background daemon processes are terminated even if a test panics crates/palyra-daemon/tests/health_endpoint.rs#160-181.
Key areas include:
- Admin Surface: Verifying that sensitive endpoints (like
/admin/v1/statusor/admin/v1/policy/explain) correctly enforce Bearer token authentication and rate limiting crates/palyra-daemon/tests/admin_surface.rs#30-72. - Health Checks: Ensuring the
/healthzendpoint accurately reflects the internal state of the gateway and its sub-services crates/palyra-daemon/tests/health_endpoint.rs#17-37. - CLI Parity: Validating that the
palyraCLI binary produces expected output formats (Text/JSON) and correctly handles error states like invalid ULIDs crates/palyra-cli/tests/daemon_status.rs#104-116.
Fuzzing Harness
The fuzzing infrastructure targets the “Natural Language to Code” boundary, specifically where external untrusted data enters the system. Nine distinct targets are maintained to stress-test the robustness of parsers for configurations, webhook payloads, and redaction routines. For details, see Fuzzing Harness.Deterministic Fixtures and Persistence Testing
Testing persistence requires deterministic environments. Palyra uses temporary state roots and isolated identity stores for every test run to ensure side-effect-free execution crates/palyra-cli/tests/daemon_status.rs#142-150.| Component | Test Approach | Code Entity |
|---|---|---|
| Vault | Cross-platform backend verification (DPAPI, Keychain, File) | BlobBackend crates/palyra-vault/src/backend.rs#88-93 |
| Identity | mTLS certificate generation and state generation locking | IdentityManager crates/palyra-identity/src/pairing/persistence.rs#56-66 |
| Wasm Plugins | Fuel-budgeted execution and capability grant isolation | WasmRuntime crates/palyra-plugins/runtime/src/lib.rs#105-108 |