Skip to content

test(bmc-proxy): enumerate ACL parsing and matching#3979

Merged
chet merged 1 commit into
NVIDIA:mainfrom
chet:gh-issue-3977
Jul 23, 2026
Merged

test(bmc-proxy): enumerate ACL parsing and matching#3979
chet merged 1 commit into
NVIDIA:mainfrom
chet:gh-issue-3977

Conversation

@chet

@chet chet commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

BMC proxy ACL tests were spread across one-off assertion functions, with equivalent path cases repeated at both the entry and configuration layers. This consolidates parser, matcher, and policy checks into grouped carbide-test-support scenarios, trims the overlapping cases, and adds the missing method, URI, wildcard-boundary, and request-path coverage.

The private AclVerb conversions and direct deserializer had no callers. Removing them keeps the coverage result focused on supported behavior instead of adding tests for unreachable interfaces.

Related issues

Closes #3977

Part of #3914

Type of Change

  • Add - New feature or capability
  • Change - Changes in existing functionality
  • Fix - Bug fixes
  • Remove - Removed features or deprecated functionality
  • Internal - Internal changes (refactoring, tests, docs, etc.)

Breaking Changes

  • This PR contains breaking changes

Testing

  • Unit tests added/updated

  • Integration tests added/updated

  • Manual testing performed

  • No testing required (docs, internal refactor, etc.)

  • cargo test --locked -p carbide-bmc-proxy --bin carbide-bmc-proxy acl::tests

  • Full carbide-bmc-proxy binary suite under cargo llvm-cov (39 tests)

  • cargo make format-nightly

  • cargo make clippy

  • cargo make carbide-lints

Additional Notes

Coverage below is for production executable lines in crates/bmc-proxy/src/acl.rs; test-module lines are excluded.

Checkpoint Lines Coverage Notes
Original 212/234 90.60% Existing one-off tests
Converted 212/222 95.50% Existing behavior preserved; 12 unreachable private-impl lines removed
Expanded 221/222 99.55% Nine previously uncovered behavior lines exercised

The remaining uncovered line propagates an injected formatter I/O error. Covering it would require an artificial failing formatter rather than a meaningful ACL behavior case.

Consolidate ACL parser, matcher, and policy checks into grouped tables while removing equivalent cases and unused private verb conversions.

Add the missing method normalization, URI validation, wildcard boundaries, and request path guards.

This supports NVIDIA#3977

Signed-off-by: Chet Nichols III <chetn@nvidia.com>
@chet
chet requested a review from a team as a code owner July 23, 2026 12:44
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of ACL request verbs with case-insensitive parsing and consistent formatting.
    • Preserved ACL path matching behavior, wildcard support, configuration evaluation order, and default-deny semantics.
  • Tests
    • Expanded scenario-based coverage for ACL parsing, matching, configuration evaluation, including handling of invalid request paths.

Walkthrough

ACL verb conversion now uses string parsing and display formatting without Serde deserialization. ACL parsing, path matching, and configuration behavior tests were consolidated into labeled scenario-driven cases covering normalization, wildcards, invalid paths, ordering, and default denial.

Changes

ACL validation

Layer / File(s) Summary
ACL verb parsing and formatting
crates/bmc-proxy/src/acl.rs
AclVerb parses case-normalized GET, POST, PUT, PATCH, DELETE, and HEAD values through FromStr, rejects invalid verbs, and formats via Display.
Scenario-driven ACL tests
crates/bmc-proxy/src/acl.rs
Shared input fixtures and scenario tables cover entry canonicalization, path and method matching, wildcard boundaries, invalid request paths, first-match-wins behavior, and default denial.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the PR’s main focus on enumerating ACL parsing and matching tests.
Description check ✅ Passed The description accurately describes the test consolidation, added coverage, and removal of unused ACL conversions.
Linked Issues check ✅ Passed The changes satisfy the linked issue’s parser, matcher, separation, removal, coverage, and behavior-preservation requirements.
Out of Scope Changes check ✅ Passed The PR stays within scope: ACL test refactoring, coverage updates, and removal of unused private ACL code.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@chet

chet commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full_review, thanks!

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

@chet: Understood. I’ll perform a complete re-review of all changes in #3979.

🐇🔍

✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/bmc-proxy/src/acl.rs (1)

391-407: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Normalize the error text to lowercase. AclPathParseError renders err directly into the user-facing message, so "Invalid verb" should be "invalid verb" to match the repository convention.

🔧 Proposed fix
             _ => Err(AclPathParseError {
                 orig: s.to_string(),
-                err: "Invalid verb".to_string(),
+                err: "invalid verb".to_string(),
             }),
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/bmc-proxy/src/acl.rs` around lines 391 - 407, Update the error text in
the AclVerb::from_str implementation so the invalid-verb message uses lowercase,
changing the err value from “Invalid verb” to “invalid verb” while preserving
the existing parsing behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@crates/bmc-proxy/src/acl.rs`:
- Around line 391-407: Update the error text in the AclVerb::from_str
implementation so the invalid-verb message uses lowercase, changing the err
value from “Invalid verb” to “invalid verb” while preserving the existing
parsing behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 503b8ca4-690c-4c5a-915d-468818a5c50b

📥 Commits

Reviewing files that changed from the base of the PR and between 03480be and a6252d9.

📒 Files selected for processing (1)
  • crates/bmc-proxy/src/acl.rs

@chet

chet commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai Thanks -- declining the out-of-diff casing suggestion. This PR intentionally leaves production diagnostics unchanged, and sibling AclPathParseError messages in the same parser are already sentence-cased (for example, "Path must..." and "ACL entry..."). Lowercasing only "Invalid verb" would not establish a consistent convention and is outside this test-only change.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@chet Thanks for the clarification. Agreed—the isolated casing change would be inconsistent with sibling diagnostics and is outside this PR’s test-focused scope. I’m withdrawing that suggestion.

🐇

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@chet Acknowledged. Preserving the existing diagnostic wording is appropriate here: changing only this message would be inconsistent with the parser’s established sentence-cased errors and outside this test-focused PR’s scope.

🐇

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/bmc-proxy/src/acl.rs (1)

391-407: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Error phrasing should conform to the lowercase convention.

The FromStr allowlist itself is sound and appropriately restrictive. However, the diagnostic string "Invalid verb" begins with a capital letter, which departs from the repository's error-message casing convention (note the sibling "ACL entry cannot be empty" is intentionally capitalized only because ACL is an acronym). Please normalize to a lowercase phrase.

As per coding guidelines: "Error display messages must be lowercase phrases without trailing periods."

✏️ Proposed casing fix
             _ => Err(AclPathParseError {
                 orig: s.to_string(),
-                err: "Invalid verb".to_string(),
+                err: "invalid verb".to_string(),
             }),
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/bmc-proxy/src/acl.rs` around lines 391 - 407, Update the error message
returned by AclVerb::from_str for unsupported verbs to use a lowercase phrase
without trailing punctuation, changing only the existing "Invalid verb"
diagnostic while preserving the allowlist and error structure.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@crates/bmc-proxy/src/acl.rs`:
- Around line 391-407: Update the error message returned by AclVerb::from_str
for unsupported verbs to use a lowercase phrase without trailing punctuation,
changing only the existing "Invalid verb" diagnostic while preserving the
allowlist and error structure.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8ee9a56d-cee0-4d1b-9ca9-2a61ca11aa80

📥 Commits

Reviewing files that changed from the base of the PR and between 03480be and a6252d9.

📒 Files selected for processing (1)
  • crates/bmc-proxy/src/acl.rs

@chet
chet merged commit 8a8bb95 into NVIDIA:main Jul 23, 2026
61 checks passed
@chet
chet deleted the gh-issue-3977 branch July 23, 2026 13:44
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.

test(bmc-proxy): enumerate ACL parsing and matching

2 participants