test(icaptcha-client): bind new()'s empty-API-key filter (#216) - #245
Open
beardthelion wants to merge 1 commit into
Open
test(icaptcha-client): bind new()'s empty-API-key filter (#216)#245beardthelion wants to merge 1 commit into
beardthelion wants to merge 1 commit into
Conversation
IcaptchaCfg::new normalizes an empty GITLAWB_ICAPTCHA_API_KEY to None via .filter(|s| !s.is_empty()) before storing api_key. No test drove the empty-string value through new(), so a regression would attach an empty bearer token to the challenge and answer requests and ship green. The new test drives an empty key through new() on a trusted operator origin and asserts it normalizes to None, with a contrast arm showing a real key still attaches. Mutation check: removing the filter fails this test and no other.
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a unit test covering empty API key normalization and preservation of non-empty keys for trusted iCaptcha origins, with environment isolation and restoration. ChangesiCaptcha API key normalization coverage
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Collaborator
Author
|
@kevincodex1 ready for merge. jatmn approved the current head ( |
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
Adds a guard test that drives an empty
GITLAWB_ICAPTCHA_API_KEYthroughIcaptchaCfg::newon a trusted operator origin and asserts it normalizes toNone, with a contrast arm showing a real key still attaches.Motivation & context
Closes #216
new()normalizes an empty key toNonevia.filter(|s| !s.is_empty())(crates/icaptcha-client/src/lib.rs:213). No test exercised the empty-string value, so dropping the filter shipped green and a trusted-origin solve would send an empty bearer token on the challenge and answer requests (lib.rs:317,lib.rs:342).Kind of change
What changed
crates/icaptcha-client/src/lib.rs: addednew_normalizes_empty_api_key_to_none_on_trusted_originHow a reviewer can verify
cargo test -p icaptcha-clientMutation check: remove
.filter(|s| !s.is_empty())from theapi_keyread innew(). The new test fails; the other 21 lib tests stay green.Before you request review
cargo test --workspacepasses locallycargo clippy --workspace --all-targets -- -D warningsis cleantest(...)).env.exampleupdated if behavior or config changed (N/A: test only)key_trustedgate, not the emptiness filter)Protocol & signing impact
No protocol impact.
Notes for reviewers
The test follows the same env-handling pattern as the sibling tests in the file: it saves and restores both env vars and releases
ICAPTCHA_ENV_LOCKbefore asserting, so a failure cannot poison the shared lock or cascade into a sibling.Summary by CodeRabbit