Skip to content

test(pgp): cover tempfile writers, untested CorruptPem arms, and clone identity#739

Merged
EffortlessSteven merged 1 commit into
mainfrom
claude/cover-pgp-writers-and-corrupt
May 16, 2026
Merged

test(pgp): cover tempfile writers, untested CorruptPem arms, and clone identity#739
EffortlessSteven merged 1 commit into
mainfrom
claude/cover-pgp-writers-and-corrupt

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Summary

Adds 14 tests in crates/uselesskey-pgp/tests/writers_and_negative_variants.rs
that close real coverage gaps in the uselesskey-pgp crate. Production code
is untouched.

Coverage closed

  • Tempfile writers: write_private_key_armored / write_public_key_armored
    were never exercised. The new tests verify on-disk presence, the .asc
    extension, contents byte-equality with the armored accessors, and that the
    two writers produce distinct paths.
  • CorruptPem arms BadFooter, Truncate, ExtraBlankLine: only
    BadHeader and BadBase64 had been wired through the PGP wrapper.
  • Deterministic corruption varies by variant string: existing tests only
    checked stability for a single variant. New tests cycle through 6-8 variants
    and assert at least two shape-distinct outputs for both armored and binary
    corruption helpers.
  • private_key_binary_truncated boundaries: len = 0 yields an empty
    parser-rejected buffer; len beyond the original returns the full input
    verbatim (saturating semantics).
  • Mismatch cache + RSA path: mismatched_public_key_* is cache-stable
    per identity and differs per label. RSA-2048 mismatch is now parsed and
    fingerprint-compared (this path was only exercised for Ed25519 before).
  • Clone shares Arc<Inner>: cloned PgpKeyPair accessors return
    pointer-identical buffers, confirming clones do not re-derive.

Safety / policy

Test plan

  • cargo test -p uselesskey-pgp (all targets, including the new test
    file with 14 / 14 passing)
  • cargo clippy -p uselesskey-pgp --all-targets -- -D warnings clean
  • cargo xtask check-no-panic-family does not flag the new file

https://claude.ai/code/session_0116SGvHnLaoXXd6wz2U9SvM


Generated by Claude Code

…e identity

Adds 14 tests in `crates/uselesskey-pgp/tests/writers_and_negative_variants.rs`
that close real coverage gaps in `uselesskey-pgp`:

- `write_private_key_armored` / `write_public_key_armored` tempfile sinks:
  ext, on-disk presence, contents byte-equal the armored accessor, and the
  two writers produce distinct paths. These Result-returning APIs were never
  exercised before.
- `CorruptPem::BadFooter`, `Truncate`, and `ExtraBlankLine` strategies via
  the PGP wrapper. The pre-existing tests only touched `BadBase64` and
  `BadHeader`.
- `private_key_armored_corrupt_deterministic` and
  `private_key_binary_corrupt_deterministic` produce at least two distinct
  outputs as the variant string changes; previously only stability for a
  single variant was checked.
- `private_key_binary_truncated(0)` returns an empty buffer that the PGP
  parser rejects, and a `len` larger than the original returns the original
  bytes verbatim (saturating semantics).
- `mismatched_public_key_binary` / `_armored` are cache-stable per identity
  and differ per label; the RSA-2048 mismatch parses as a valid public key
  whose fingerprint differs from the issuer (mismatch path was only tested
  for Ed25519 before).
- `Clone` on `PgpKeyPair` shares the `Arc<Inner>` so accessor pointers are
  identical without re-deriving.

No production code changes. All Result paths use `match` / `let else` plus
`assert!` on `is_ok()`; no `unwrap`/`expect`/`panic!` are introduced, so the
no-panic-family ledger is unaffected.

https://claude.ai/code/session_0116SGvHnLaoXXd6wz2U9SvM
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented May 16, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@EffortlessSteven has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 29 minutes and 17 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d123d524-b910-4794-afa3-416411fc41a5

📥 Commits

Reviewing files that changed from the base of the PR and between ac9aba2 and a3f542f.

📒 Files selected for processing (1)
  • crates/uselesskey-pgp/tests/writers_and_negative_variants.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/cover-pgp-writers-and-corrupt

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.

❤️ Share

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

@EffortlessSteven EffortlessSteven marked this pull request as ready for review May 16, 2026 09:44
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@EffortlessSteven EffortlessSteven merged commit e0d4fa7 into main May 16, 2026
6 checks passed
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.

2 participants