Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds additional unit test coverage for bucket CORS CLI helper parsing logic, focusing on edge cases around empty/blank inputs and input-source selection.
Changes:
- Added regression tests ensuring empty
allowedOrigins/allowedMethodsentries are rejected. - Added regression test ensuring whitespace-only
allowedHeaders/exposeHeadersnormalize toNonewhile methods are still uppercased. - Added regression test ensuring conflicting positional vs
--fileinputs are rejected bycors_input_source.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+591
to
+606
| #[test] | ||
| fn test_parse_cors_configuration_rejects_empty_allowed_origin() { | ||
| let error = parse_cors_configuration( | ||
| r#"{ | ||
| "rules": [ | ||
| { | ||
| "allowedOrigins": [" https://app.example.com ", " "], | ||
| "allowedMethods": ["GET"] | ||
| } | ||
| ] | ||
| }"#, | ||
| ) | ||
| .expect_err("empty allowed origin"); | ||
|
|
||
| assert!(error.contains("empty allowed origin")); | ||
| } |
There was a problem hiding this comment.
PR description says this change adds two targeted unit tests, but this diff adds four new tests (two additional cases for empty allowed origins/methods). Please update the PR description (or trim the change) so the summary matches what’s actually being added.
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 regression coverage for two untested helper paths in the new bucket CORS command parser. The new tests confirm that blank optional header lists are normalized away during JSON parsing and that conflicting input-source arguments are rejected consistently at the helper layer.
Background
Bucket CORS support was added recently, and the first pass included solid happy-path coverage for command parsing and CORS document normalization. A few narrow branches in the helper logic were still untested, which left low-level behavior around source selection and optional-field cleanup dependent on manual reasoning instead of executable checks.
Root Cause
The CORS parser tests covered successful JSON/XML parsing, invalid methods, and missing sources, but they did not exercise the branch that rejects simultaneous positional and
--fileinputs or the branch that collapses whitespace-only optional header collections toNone.Solution
I added two targeted unit tests in
crates/cli/src/commands/cors.rs:parse_cors_configurationdrops blankallowedHeadersandexposeHeadersentries while still normalizing method casecors_input_sourcerejects conflicting positional and--fileinputsThe implementation is unchanged; this PR only tightens regression coverage for the newly added CORS command helpers.
Validation
I attempted
make pre-commit, but this repository currently has nopre-commitmake target.I then ran the equivalent required checks directly:
cargo fmt --all --checkcargo clippy --workspace -- -D warningscargo test --workspace