test(x509): cover params helpers and clone-share invariants#742
Conversation
Add focused unit-test coverage for under-tested paths in uselesskey-x509:
- cert/params.rs: DaysFromNow not_before path on positive fixtures, SAN
dedup observable in the generated cert, with_is_ca(true) alone, and
the all-false key_usage_purposes branch.
- chain/params.rs: intermediate validity / not_before overrides reach the
cert, and intermediate_is_ca(Some(true)) keeps the CA flag and CA key
usage (the explicit-true arm of unwrap_or(true)).
- Derived-trait invariants: X509Negative / ChainNegative round-trip
through HashMap / HashSet (Eq / Hash / Clone / Debug), and the
NotBeforeOffset default value.
- Arc sharing: X509Cert::clone and X509Chain::clone reuse the same
underlying buffers, verified via slice pointer equality.
Uses uselesskey_test_support::{ensure, ensure_eq, require_ok,
require_some} throughout to avoid new no-panic-family debt.
https://claude.ai/code/session_0116SGvHnLaoXXd6wz2U9SvM
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary
Adds a single new test file
crates/uselesskey-x509/tests/params_helper_coverage.rs(11 small tests, ~370 lines) that fills focused gaps inuselesskey-x509:cert/params.rshelper branchesapply_not_before(DaysFromNow)on a positive (non-negative) fixture — the existing tests only exerciseDaysFromNowindirectly via theNotYetValidnegative variant.add_sorted_dns_sansdedup observable in the actual generated cert (currently only thestable_bytesdedup is asserted).ca_constrainttrue arm viawith_is_ca(true)alone — separate fromself_signed_cawhich flips bothis_caandkey_usage.key_usage_purposesempty-vec branch when everyKeyUsagebit is false.chain/params.rsbuilder brancheswith_intermediate_validity_daysandwith_intermediate_not_beforeactually reach the generated intermediate cert.intermediate_is_ca(Some(true))keeps the CA flag — the explicitSome(true)arm ofunwrap_or(true)(theNonearm is covered by every good-chain test).Derived-trait and clone invariants
X509Negative/ChainNegativeround-trip throughHashMap/HashSet(Eq/Hash/Clone/Debug), includingHostnameMismatchfield equality.NotBeforeOffset::default() == DaysAgo(1).X509Cert::cloneandX509Chain::cloneshare the underlyingArc<Inner>buffers (verified via slice pointer equality oncert_der()/cert_pem()).Uses
uselesskey_test_support::{ensure, ensure_eq, require_ok, require_some}— no.unwrap()or.expect()in tests, no new no-panic-family debt introduced.Test plan
cargo test -p uselesskey-x509 --test params_helper_coverage(11/11 pass)cargo test -p uselesskey-x509(full suite, all targets pass)cargo clippy -p uselesskey-x509 --all-targets -- -D warningscargo xtask check-no-panic-family— new file introduces no new debt (the 3 new-debt sites flagged by the tool are pre-existing insrc/cert.rs:486,src/cert/material.rs:18,src/cert/params.rs:96onorigin/mainfrom the SRP refactor; not touched by this PR).https://claude.ai/code/session_0116SGvHnLaoXXd6wz2U9SvM
Generated by Claude Code