GRI-1856: fix setup/session tests to use the real email field #98

Merged
vivy merged 1 commit from fix/GRI-1856-setup-session-email-field into dev 2026-11-10 00:57:00 +00:00
Member

Summary

Fixes two bugs in crates/server/tests/setup_session_integration.rs, merged in #96. Both are test bugs, not implementation bugs.

SetupRequest/LoginRequest (crates/server/src/auth/handlers.rs) have no username field — the real login identifier is email, and validate_email already rejects empty and malformed values. The old setup_body()/login_body() helpers sent "username": ..., which serde silently drops as an unrecognized field (no deny_unknown_fields), while always hard-coding a valid "email": "setup-test@example.test" underneath.

Two consequences, both fixed here:

  1. ac_1_02_setup_with_empty_username_is_rejected_and_creates_no_user was asserting on a field that does nothing, so it exercised the already-correct email validation path regardless — it was marked #[ignore] in #96 with a false "validation gap" finding. Un-ignored; it now asserts on the real email field and passes against dev unmodified.
  2. ac_1_06_login_for_unknown_username_is_rejected_the_same_way_as_wrong_password used the identical hard-coded real email for both its "wrong password" and "unknown user" cases, so it could never have caught a real username-enumeration leak. Fixed to use a genuinely distinct, never-registered email for the "unknown user" case.

Every other test in the file gets the same real-email treatment for consistency, with no behavioral change to those (they always happened to use the one real hard-coded email already).

Test plan

$ SIGNAGE_TEST_DATABASE_URL=postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable \
  cargo test -p server --test setup_session_integration -- --test-threads=1
running 6 tests
test ac_1_02_setup_with_empty_username_is_rejected_and_creates_no_user ... ok
test ac_1_02_setup_with_missing_password_field_is_rejected_and_creates_no_user ... ok
test ac_1_03_setup_is_refused_once_a_user_exists_and_creates_no_second_admin ... ok
test ac_1_04_login_with_correct_credentials_establishes_a_session ... ok
test ac_1_05_login_with_wrong_password_is_rejected_and_establishes_no_session ... ok
test ac_1_06_login_for_unknown_username_is_rejected_the_same_way_as_wrong_password ... ok
test result: ok. 6 passed; 0 failed; 0 ignored

./scripts/local-gates.sh — every gate passed.

## Summary Fixes two bugs in `crates/server/tests/setup_session_integration.rs`, merged in #96. Both are test bugs, not implementation bugs. `SetupRequest`/`LoginRequest` (`crates/server/src/auth/handlers.rs`) have no `username` field — the real login identifier is `email`, and `validate_email` already rejects empty and malformed values. The old `setup_body()`/`login_body()` helpers sent `"username": ...`, which serde silently drops as an unrecognized field (no `deny_unknown_fields`), while always hard-coding a valid `"email": "setup-test@example.test"` underneath. Two consequences, both fixed here: 1. `ac_1_02_setup_with_empty_username_is_rejected_and_creates_no_user` was asserting on a field that does nothing, so it exercised the already-correct `email` validation path regardless — it was marked `#[ignore]` in #96 with a false "validation gap" finding. **Un-ignored**; it now asserts on the real `email` field and passes against `dev` unmodified. 2. `ac_1_06_login_for_unknown_username_is_rejected_the_same_way_as_wrong_password` used the identical hard-coded real email for both its "wrong password" and "unknown user" cases, so it could never have caught a real username-enumeration leak. Fixed to use a genuinely distinct, never-registered email for the "unknown user" case. Every other test in the file gets the same real-`email` treatment for consistency, with no behavioral change to those (they always happened to use the one real hard-coded email already). ## Test plan ``` $ SIGNAGE_TEST_DATABASE_URL=postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable \ cargo test -p server --test setup_session_integration -- --test-threads=1 running 6 tests test ac_1_02_setup_with_empty_username_is_rejected_and_creates_no_user ... ok test ac_1_02_setup_with_missing_password_field_is_rejected_and_creates_no_user ... ok test ac_1_03_setup_is_refused_once_a_user_exists_and_creates_no_second_admin ... ok test ac_1_04_login_with_correct_credentials_establishes_a_session ... ok test ac_1_05_login_with_wrong_password_is_rejected_and_establishes_no_session ... ok test ac_1_06_login_for_unknown_username_is_rejected_the_same_way_as_wrong_password ... ok test result: ok. 6 passed; 0 failed; 0 ignored ``` `./scripts/local-gates.sh` — every gate passed.
GRI-1856: fix setup/session tests to use the real email field
Some checks failed
CI / the pre-push hook (pull_request) Successful in 5s
CI / cargo fmt (pull_request) Successful in 6s
CI / cargo deny (pull_request) Successful in 58s
CI / cargo deny advisories (pull_request) Failing after 1m42s
CI / repository boundary (pull_request) Successful in 8s
CI / cargo clippy (pull_request) Successful in 10m12s
CI / cargo test (pull_request) Successful in 11m3s
CI / frontend-web (pull_request) Successful in 10m1s
CI / CI (pull_request) Successful in 4s
CI / Notify gate failed (pull_request) Has been skipped
f6df9a0b89
vivy merged commit 9e984a729c into dev 2026-11-10 00:57:00 +00:00
vivy deleted branch fix/GRI-1856-setup-session-email-field 2026-11-10 00:57:00 +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!98
No description provided.