GRI-1856: independent acceptance tests for enrolment over WebSocket #102

Merged
vivy merged 1 commit from test/GRI-1856-enrolment-acceptance-tests into dev 2026-11-10 03:49:07 +00:00
Member

Independent acceptance tests for device enrolment over WebSocket (GRI-1873, PR #94), not derived from the implementer's own ws_integration.rs.

Criterion-to-test mapping (plan/tests/mvp-acceptance.md section 2; AC-2-01/AC-2-02 are E2E, out of scope here; AC-2-06 is already covered by the implementer's a_known_device_with_a_valid_token_is_simply_accepted; AC-2-11/AC-2-12 are findings below, not tests):

  • ac_2_03_a_rejected_pending_device_stays_unregistered
  • ac_2_05_an_auto_approve_ip_registers_automatically_with_no_pending_step
  • ac_2_07_a_registered_device_on_the_blocklist_is_dropped_when_the_setting_applies
  • ac_2_08_a_registered_device_on_the_blocklist_is_admitted_when_the_setting_is_off (#[ignore]d — see finding below)
  • ac_2_09_a_trusted_proxy_header_is_honoured_from_a_trusted_proxy
  • ac_2_10_a_forged_forwarded_for_header_is_rejected_from_an_untrusted_peer

Fail-first, verified by temporarily breaking each contract in the implementation and reverting (not committed):

cargo test -p server --test enrolment_acceptance_integration -- --test-threads=1
  • AC-2-03: disabled the Blocked branch in handle_temporary_reconnect → left: Pending, right: Rejected.
  • AC-2-05: disabled the auto-approve match in AdmissionRules::decide → left: Pending, right: Accepted.
  • AC-2-07: disabled blocklist_only_drop's check → the blocklisted peer was upgraded instead of refused.
  • AC-2-09: forced TrustedProxies::client_ip to always return the peer → left: Pending, right: Accepted.
  • AC-2-10: forced TrustedProxies::is_trusted to always return true → left: Accepted, right: Pending.

All five pass cleanly against the real (unmodified) code:

test ac_2_03_a_rejected_pending_device_stays_unregistered ... ok
test ac_2_05_an_auto_approve_ip_registers_automatically_with_no_pending_step ... ok
test ac_2_07_a_registered_device_on_the_blocklist_is_dropped_when_the_setting_applies ... ok
test ac_2_09_a_trusted_proxy_header_is_honoured_from_a_trusted_proxy ... ok
test ac_2_10_a_forged_forwarded_for_header_is_rejected_from_an_untrusted_peer ... ok
test result: ok. 5 passed; 0 failed; 1 ignored

Finding for the CTO, to route to the back-end engineer (not fixed here): AC-2-08 is genuinely broken. ws::upgrade's pre-upgrade blocklist_only_drop check reads its rules from devices::load_admission_rules, which hardcodes blocklist_applies_to_registered: true and never learns the server's actual configured setting — only handle_socket, reached after the upgrade, overrides it from EnrolmentState. So a blocklisted registered device is refused with a 403 at the upgrade stage before its token is ever read, regardless of whether the admin turned the setting off. Likely a one-line fix: upgrade() should apply state.blocklist_applies_to_registered to the rules it loads, the same way handle_socket does, before calling blocklist_only_drop. Left #[ignore]d with that reason; un-ignoring it is the regression check once fixed.

Findings, not tested (no design change needed to work around, but no current API surface to test against):

  • AC-2-11 ("a pending registration does not expire on its own") has no admin-facing list route yet (POST /devices/{id}/approve and friends are signage #13, not built), so there is nothing to assert "the panel still lists it" against. No time-based expiry code exists in the reconnect path either, so there's nothing a regression test could currently catch breaking.
  • AC-2-12 ("the pending cap is per IP") has no implementation at all: EnrolmentConfig has no cap field, and neither devices::create_pending nor ws::admit enforces one anywhere. This needs a design decision (where the cap lives, how it's configured) before a test can be written against it, not just a route.

./scripts/local-gates.sh: all gates passed.

CI verdict: fj ci

Independent acceptance tests for device enrolment over WebSocket (GRI-1873, PR #94), not derived from the implementer's own `ws_integration.rs`. Criterion-to-test mapping (`plan/tests/mvp-acceptance.md` section 2; AC-2-01/AC-2-02 are E2E, out of scope here; AC-2-06 is already covered by the implementer's `a_known_device_with_a_valid_token_is_simply_accepted`; AC-2-11/AC-2-12 are findings below, not tests): - `ac_2_03_a_rejected_pending_device_stays_unregistered` - `ac_2_05_an_auto_approve_ip_registers_automatically_with_no_pending_step` - `ac_2_07_a_registered_device_on_the_blocklist_is_dropped_when_the_setting_applies` - `ac_2_08_a_registered_device_on_the_blocklist_is_admitted_when_the_setting_is_off` (`#[ignore]`d — see finding below) - `ac_2_09_a_trusted_proxy_header_is_honoured_from_a_trusted_proxy` - `ac_2_10_a_forged_forwarded_for_header_is_rejected_from_an_untrusted_peer` Fail-first, verified by temporarily breaking each contract in the implementation and reverting (not committed): ``` cargo test -p server --test enrolment_acceptance_integration -- --test-threads=1 ``` - AC-2-03: disabled the `Blocked` branch in `handle_temporary_reconnect` → `left: Pending, right: Rejected`. - AC-2-05: disabled the auto-approve match in `AdmissionRules::decide` → `left: Pending, right: Accepted`. - AC-2-07: disabled `blocklist_only_drop`'s check → the blocklisted peer was upgraded instead of refused. - AC-2-09: forced `TrustedProxies::client_ip` to always return the peer → `left: Pending, right: Accepted`. - AC-2-10: forced `TrustedProxies::is_trusted` to always return `true` → `left: Accepted, right: Pending`. All five pass cleanly against the real (unmodified) code: ``` test ac_2_03_a_rejected_pending_device_stays_unregistered ... ok test ac_2_05_an_auto_approve_ip_registers_automatically_with_no_pending_step ... ok test ac_2_07_a_registered_device_on_the_blocklist_is_dropped_when_the_setting_applies ... ok test ac_2_09_a_trusted_proxy_header_is_honoured_from_a_trusted_proxy ... ok test ac_2_10_a_forged_forwarded_for_header_is_rejected_from_an_untrusted_peer ... ok test result: ok. 5 passed; 0 failed; 1 ignored ``` **Finding for the CTO, to route to the back-end engineer (not fixed here):** AC-2-08 is genuinely broken. `ws::upgrade`'s pre-upgrade `blocklist_only_drop` check reads its rules from `devices::load_admission_rules`, which hardcodes `blocklist_applies_to_registered: true` and never learns the server's actual configured setting — only `handle_socket`, reached *after* the upgrade, overrides it from `EnrolmentState`. So a blocklisted registered device is refused with a 403 at the upgrade stage before its token is ever read, regardless of whether the admin turned the setting off. Likely a one-line fix: `upgrade()` should apply `state.blocklist_applies_to_registered` to the rules it loads, the same way `handle_socket` does, before calling `blocklist_only_drop`. Left `#[ignore]`d with that reason; un-ignoring it is the regression check once fixed. **Findings, not tested (no design change needed to work around, but no current API surface to test against):** - AC-2-11 ("a pending registration does not expire on its own") has no admin-facing list route yet (`POST /devices/{id}/approve` and friends are signage #13, not built), so there is nothing to assert "the panel still lists it" against. No time-based expiry code exists in the reconnect path either, so there's nothing a regression test could currently catch breaking. - AC-2-12 ("the pending cap is per IP") has no implementation at all: `EnrolmentConfig` has no cap field, and neither `devices::create_pending` nor `ws::admit` enforces one anywhere. This needs a design decision (where the cap lives, how it's configured) before a test can be written against it, not just a route. `./scripts/local-gates.sh`: all gates passed. CI verdict: `fj ci`
GRI-1856: independent acceptance tests for enrolment over WebSocket
Some checks failed
CI / the pre-push hook (pull_request) Successful in 5s
CI / cargo fmt (pull_request) Successful in 5s
CI / cargo deny (pull_request) Successful in 54s
CI / cargo deny advisories (pull_request) Failing after 49s
CI / repository boundary (pull_request) Successful in 5s
CI / cargo clippy (pull_request) Successful in 9m47s
CI / cargo test (pull_request) Successful in 10m52s
CI / frontend-web (pull_request) Successful in 9m45s
CI / CI (pull_request) Successful in 4s
CI / Notify gate failed (pull_request) Has been skipped
8ad3840700
vivy merged commit a0ee4fac0b into dev 2026-11-10 03:49:07 +00:00
vivy deleted branch test/GRI-1856-enrolment-acceptance-tests 2026-11-10 03:49:07 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Grimoirix/grimoire-of-digital-signage!102
No description provided.