Skip to content

feat: add tests for entity CRUD REST API endpoints#136

Merged
Keshoid merged 4 commits into
release/nodectl/v0.5.0from
feature/sma-71-add-tests-for-entity-crud-rest-api-endpoints
May 13, 2026
Merged

feat: add tests for entity CRUD REST API endpoints#136
Keshoid merged 4 commits into
release/nodectl/v0.5.0from
feature/sma-71-add-tests-for-entity-crud-rest-api-endpoints

Conversation

@mrnkslv
Copy link
Copy Markdown
Contributor

@mrnkslv mrnkslv commented May 7, 2026

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" path
  • auth_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)]

Copilot AI review requested due to automatic review settings May 7, 2026 12:08
@linear
Copy link
Copy Markdown

linear Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_path helper and wired the new test module into http/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.

Comment thread src/node-control/service/src/http/entity_crud_handlers_tests.rs Outdated
Comment thread src/node-control/service/src/http/auth_tests.rs Outdated
@mrnkslv mrnkslv requested review from Keshoid May 11, 2026 09:12
@Keshoid Keshoid merged commit 86228fb into release/nodectl/v0.5.0 May 13, 2026
5 of 8 checks passed
@Keshoid Keshoid deleted the feature/sma-71-add-tests-for-entity-crud-rest-api-endpoints branch May 13, 2026 08:01
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.

3 participants