test(cli): cover materialize kinds and label-normalization edges#747
Conversation
Add `tests/materialize_kinds.rs` exercising paths that the binary-level CLI tests don't reach via the manifest CLI: - `MaterializeKind::PemBlockShape` emits a valid base64 body inside the normalized BEGIN/END markers (including label fallback when `label = None`). - `MaterializeKind::TokenApiKey` produces a non-empty, non-JWT-shaped token deterministically across runs. - `MaterializeKind::EntropyBytes` defaults to 32 bytes when `len` is unset. - `MaterializeKind::SshPublicKeyShape` falls back to the sanitized file stem as the SSH comment when `label = None`. - `materialize_manifest_to_dir` and `emit_include_bytes_module` reject empty manifests with `InvalidManifest`. - `emit_include_bytes_module` rejects two specs whose ids collide on the emitted constant name (`KEY_A`). - `emit_include_bytes_module` prefixes `_` for digit-leading ids (`2fa-secret` → `_2FA_SECRET`).
|
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 selected for processing (1)
✨ 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! |
Summary
Adds
crates/uselesskey-cli/tests/materialize_kinds.rsexercising materialize paths that the existing binary-level tests do not reach.Tests added (11):
Materialize kinds
PemBlockShapeproduces a valid-----BEGIN <LABEL>-----block with a base64 bodyPemBlockShapewith a label of only special chars normalizes to___PemBlockShapewithlabel = Nonefalls back to the file-stem-derived label (named.pem→NAMED)TokenApiKeyproduces a non-empty, dot-free token (distinguishes it from JWT shape)TokenApiKeyis deterministic across separate materialize runsSshPublicKeyShapewithlabel = Noneuses the sanitized file stem as the SSH commentEntropyBytesdefaults to 32 bytes whenlenis unsetError paths
materialize_manifest_to_dirreturnsInvalidManifeston an empty manifestemit_include_bytes_modulereturnsInvalidManifeston an empty manifestemit_include_bytes_modulerejects two specs whose ids both normalize toKEY_Aemit_include_bytes_moduleprefixes_for a digit-leading id (2fa-secret→_2FA_SECRET)Test plan
cargo test -p uselesskey-cli --test materialize_kinds— 11/11 passcargo clippy -p uselesskey-cli --tests --all-features— cleancargo fmt --checkGenerated by Claude Code