feat: add tests for entity CRUD REST API endpoints#136
Merged
Keshoid merged 4 commits intoMay 13, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds automated Axum oneshot tests for the REST entity mutation endpoints (/v1/nodes, /v1/wallets, /v1/pools, /v1/bindings) and expands auth tests to verify role-based access control for these CRUD routes. It also introduces a test-only RuntimeConfigStore helper to allow writing persisted configs to a real temporary file.
Changes:
- Added a comprehensive new test module covering happy paths, validation/conflict cases, reference/constraint checks, and persistence-to-disk behavior for entity CRUD endpoints.
- Added auth tests ensuring nominator role is forbidden (403) on all entity mutation routes, while operator role can mutate when auth is enabled.
- Added a test-only
RuntimeConfigStore::from_app_config_with_pathhelper and wired the new test module intohttp/mod.rs.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/node-control/service/src/runtime_config.rs |
Adds a #[cfg(test)] constructor to override the persisted config file path for tests. |
src/node-control/service/src/http/mod.rs |
Registers the new entity CRUD test module under #[cfg(test)]. |
src/node-control/service/src/http/entity_crud_handlers_tests.rs |
New end-to-end-ish REST mutation tests for nodes/wallets/pools/bindings plus persistence assertions. |
src/node-control/service/src/http/auth_tests.rs |
Adds a DELETE bearer helper and new role-based access tests for entity CRUD mutation routes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Keshoid
approved these changes
May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds automated tests for the eight entity mutation REST endpoints (POST/DELETE for /v1/nodes, /v1/wallets, /v1/pools, /v1/bindings): happy paths, validation and conflict cases, persistence to disk after mutations, and role checks (nominator → 403, operator → allowed when auth is enabled).
Changes
entity_crud_handlers_tests.rs(new): Axum oneshot tests against routes(false, state) with RuntimeConfigStore::from_app_config, covering:Nodes: add/list, duplicate, invalid base64 pubkey, delete success/not-found, delete blocked when referenced by a binding
Wallets: add/list, reserved master_wallet, duplicate, delete blocked when referenced by binding, delete success and not-found
Pools (SNP): add with address only, reject when both address and owner missing, duplicate name, delete blocked when referenced by binding, delete success and not-found
Bindings: add, duplicate, missing node/wallet/pool, delete when idle vs non-idle status, delete not-found
Persistence: temp config path + read-back JSON after POST/DELETE node mutations
runtime_config.rs: #[cfg(test)] helper from_app_config_with_path so tests write config to a real temp file instead of the default "noop" pathauth_tests.rs: delete_bearer helper; nominator_forbidden_on_entity_crud_routes (all eight mutations return 403); operator_can_mutate_entity_crud_when_auth_enabled (smoke: POST+DELETE node with operator JWT)http/mod.rs: wire new test module under #[cfg(test)]