Skip to content

fix: update tests for admin-auth-required GET endpoints (PR #6197 reviewer feedback)#6807

Closed
BossChaos wants to merge 1 commit into
Scottcjn:mainfrom
BossChaos:fix/pr-6191-6197-reviewer-feedback
Closed

fix: update tests for admin-auth-required GET endpoints (PR #6197 reviewer feedback)#6807
BossChaos wants to merge 1 commit into
Scottcjn:mainfrom
BossChaos:fix/pr-6191-6197-reviewer-feedback

Conversation

@BossChaos
Copy link
Copy Markdown
Contributor

Summary

Addresses reviewer feedback on PRs #6191 and #6197.

PR #6197 — test_machine_passport.py fixes

All Machine Passport GET endpoints now require admin auth. Tests updated accordingly:

Test Before After
test_list_passports_empty 200 401 (unauthenticated)
test_list_passports_rejects_non_integer_limit 400 401 (auth checked before parsing)
test_list_passports_rejects_negative_offset 400 401 (auth checked before parsing)
test_list_passports_clamps_large_limit unauthenticated X-Admin-Key: expected-admin-key
test_get_nonexistent_passport 404 401 (auth checked before existence check)
test_update_passport_rejects_owner_claim GET call unauthenticated X-Admin-Key: expected-admin-key
test_mutating_subresources_fail_closed GET call unauthenticated X-Admin-Key: expected-admin-key

PR #6191 — get_contracts() already fixed

node/beacon_api.py get_contracts() already uses admin-only auth in HEAD. The broken agent-signature fallback (_authenticate_contract_agent(get_db(), [], ...)) was removed. No additional code change needed.

…6197 reviewer feedback)

- test_list_passports_empty: unauthenticated GET now returns 401
- test_list_passports_rejects_non_integer_limit: return 401 before parsing
- test_list_passports_rejects_negative_offset: return 401 before parsing
- test_list_passports_clamps_large_limit: add valid admin auth header
- test_get_nonexistent_passport: unauthenticated returns 401 not 404
- test_update_passport_rejects_owner_claim: add auth header to GET call
- test_mutating_subresources_fail_closed: add auth header to GET call
@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) node Node server related tests Test suite changes size/S PR: 11-50 lines labels Jun 3, 2026
Copy link
Copy Markdown

@qingfeng312 qingfeng312 left a comment

Choose a reason for hiding this comment

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

This updates the tests for the new admin-auth gate, but it also removes the original endpoint behavior coverage.

The list pagination tests now only assert that unauthenticated requests return 401 for limit=abc and offset=-1. That no longer proves authenticated admin requests still reject invalid pagination with the documented 400 responses. Similarly, test_get_nonexistent_passport now only covers the unauthenticated 401 path, so the authenticated passport_not_found / 404 behavior is no longer tested. A regression that accepts invalid pagination, ignores the offset validation, or returns the wrong result for a missing passport after valid admin auth would pass this test suite.

Please preserve the original behavior coverage by either adding valid X-Admin-Key headers to the existing validation tests, or splitting them into separate auth-gate tests plus authenticated behavior tests.

Validation:

  • Inspected the PR diff for node/tests/test_machine_passport.py.
  • Confirmed the changed tests cover unauthenticated 401 paths but remove the authenticated invalid-pagination and missing-passport assertions.

Copy link
Copy Markdown
Contributor

@JesusMP22 JesusMP22 left a comment

Choose a reason for hiding this comment

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

Code Review for PR #6807

Summary

Reviewed 1 file(s) changed in this PR: node/tests/test_machine_passport.py

Changes Analyzed

node/tests/test_machine_passport.py

  • Changes: +25/-19
  • Test coverage looks appropriate for the changes.

Overall Assessment

The changes look good and address the stated purpose. The implementation is clean and follows the existing codebase patterns.

Recommendation

Approve — Ready to merge after any minor feedback is addressed.


Review by OWL (jesusmp) — claiming code review bounty

@Scottcjn
Copy link
Copy Markdown
Owner

Scottcjn commented Jun 3, 2026

Closing — these tests assert behavior that doesn't exist (and conflicts with policy)

Two problems:

  1. The tests fail against main. They now assert 401 (admin required) on GET /api/machine-passport (list + the pagination-validation cases), but list_passports() on main has no admin check — it returns 200. I ran them: 5 failures. The server change these tests assume (fix: require admin auth on all Machine Passport GET endpoints #6197, "require admin auth on all Machine Passport GETs") is still open, not merged.

  2. The underlying direction conflicts with policy. Machine passports are hardware-provenance / preservation showcase data (architecture, repair logs, lineage, benchmarks) — conceptually like the public Green Tracker. We keep query GET endpoints public; admin-gating the passport listing is the same pattern we declined on test: restore repo-wide CI baseline expectations #6711.

If there's a real reason a specific passport field is sensitive (e.g. it leaks fingerprint/serial detail that aids anti-VM spoofing), the fix is to redact that field from the public response, not lock the whole listing behind admin. Happy to help with that. Closing this test-only PR since it can't be green without #6197, and #6197 itself needs the policy call first.

@Scottcjn Scottcjn closed this Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) node Node server related size/S PR: 11-50 lines tests Test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants