test(cli): cover cors required field validation#106
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This change adds focused unit coverage for a few CORS validation branches that were introduced by the recent bucket CORS work but were still untested on
main.It specifically locks down three cases in
crates/cli/src/commands/cors.rs:local/Problem
Recent CORS parser and bucket-path fixes rely on these branches to reject malformed input early, but the current test suite only covered adjacent cases such as blank values inside lists and trailing slash normalization. That left the direct empty-list and slash-only path paths unpinned.
If one of these branches regressed, users could get looser parsing for invalid CORS configs or bucket paths without a targeted test failure pointing at the exact behavior change.
Root cause
The recent feature and follow-up fixes added the validation logic, but the unit tests did not yet cover every validation branch. The suite asserted nearby malformed inputs, not the explicit empty-list and slash-only inputs handled by the parser.
Fix
Add three small unit tests that exercise the missing validation paths without changing runtime behavior:
local/inparse_bucket_pathallowedOriginslistallowedMethodslistValidation
I first ran the focused CORS unit tests:
cargo test -p rustfs-cli cors::testsThen I ran the repo's CI-equivalent checks from
.github/workflows/ci.yml:cargo fmt --all --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspaceNote: this repository does not currently define a checked-in
make pre-committarget, so I used the exact commands the CI workflow runs instead.