test: Wave 23 - facade and adapter snapshot tests#44
test: Wave 23 - facade and adapter snapshot tests#44EffortlessSteven wants to merge 1 commit intomainfrom
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Review Summary by QodoAdd snapshot tests for facade and adapter crates
WalkthroughsDescription• Adds 16 insta snapshot tests across 3 crates • Tests facade, rustls adapter, and tonic adapter outputs • Snapshots certificate/key shapes and TLS configurations • All crypto material redacted for security Diagramflowchart LR
facade["Facade Crate<br/>9 snapshot tests"]
rustls["Rustls Adapter<br/>4 snapshot tests"]
tonic["Tonic Adapter<br/>3 snapshot tests"]
insta["Insta Snapshots<br/>YAML format"]
facade -->|RSA, ECDSA, Ed25519| insta
facade -->|HMAC, Token, X509| insta
rustls -->|Cert DER lengths| insta
rustls -->|Private key types| insta
tonic -->|Config types| insta
tonic -->|Certificate shapes| insta
File Changes1. crates/uselesskey/tests/snapshots_facade.rs
|
|
Warning Rate limit exceeded
⌛ 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. ⛔ Files ignored due to path filters (17)
📒 Files selected for processing (8)
✨ 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 |
Code Review by Qodo
1. PEM markers committed in tests
|
There was a problem hiding this comment.
Pull request overview
Adds deterministic Insta snapshot tests to validate the public “facade” and adapter outputs (facade, rustls, tonic) without snapshotting raw secret material.
Changes:
- Added a new
snapshots_facade.rstest suite covering multiple key/cert/token “shape” outputs behind feature flags. - Added new
snapshots_rustls.rsandsnapshots_tonic.rssuites plus shared deterministictestutil::fx()helpers. - Added required
serde/instadev-dependencies and checked in generated.snapartifacts.
Reviewed changes
Copilot reviewed 24 out of 25 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/uselesskey/tests/snapshots_facade.rs | Adds facade-level snapshot tests for key/cert/token shapes across feature-gated modules |
| crates/uselesskey/tests/snapshots/snapshots_facade__x509_snapshots__facade_x509_self_signed_shape.snap | Snapshot output for facade X509 self-signed shape |
| crates/uselesskey/tests/snapshots/snapshots_facade__x509_snapshots__facade_x509_chain_shape.snap | Snapshot output for facade X509 chain shape |
| crates/uselesskey/tests/snapshots/snapshots_facade__token_snapshots__facade_token_shapes.snap | Snapshot output for facade token shapes |
| crates/uselesskey/tests/snapshots/snapshots_facade__rsa_snapshots__facade_rsa_pem_headers.snap | Snapshot output for facade RSA PEM header checks |
| crates/uselesskey/tests/snapshots/snapshots_facade__rsa_snapshots__facade_rsa_2048_shape.snap | Snapshot output for facade RSA-2048 shape |
| crates/uselesskey/tests/snapshots/snapshots_facade__hmac_snapshots__facade_hmac_shapes.snap | Snapshot output for facade HMAC shapes |
| crates/uselesskey/tests/snapshots/snapshots_facade__ed25519_snapshots__facade_ed25519_shape.snap | Snapshot output for facade Ed25519 shape |
| crates/uselesskey/tests/snapshots/snapshots_facade__ecdsa_snapshots__facade_ecdsa_p384_shape.snap | Snapshot output for facade ECDSA P-384 shape |
| crates/uselesskey/tests/snapshots/snapshots_facade__ecdsa_snapshots__facade_ecdsa_p256_shape.snap | Snapshot output for facade ECDSA P-256 shape |
| crates/uselesskey/Cargo.toml | Adds serde/insta as dev-dependencies for the new snapshots |
| crates/uselesskey-tonic/tests/testutil.rs | Adds deterministic Factory helper for tonic adapter tests |
| crates/uselesskey-tonic/tests/snapshots_tonic.rs | Adds tonic adapter snapshot tests around TLS config and cert/key shapes |
| crates/uselesskey-tonic/tests/snapshots/snapshots_tonic__tonic_self_signed_certificate_shapes.snap | Snapshot output for tonic self-signed cert/key shapes |
| crates/uselesskey-tonic/tests/snapshots/snapshots_tonic__tonic_chain_certificate_shapes.snap | Snapshot output for tonic chain cert/key shapes |
| crates/uselesskey-tonic/tests/snapshots/snapshots_tonic__tonic_available_config_types.snap | Snapshot output verifying tonic config constructors are available |
| crates/uselesskey-tonic/Cargo.toml | Adds serde/insta dev-dependencies for tonic snapshots |
| crates/uselesskey-rustls/tests/testutil.rs | Adds deterministic Factory helper for rustls adapter tests |
| crates/uselesskey-rustls/tests/snapshots_rustls.rs | Adds rustls adapter snapshot tests (cert DER lengths, key type) |
| crates/uselesskey-rustls/tests/snapshots/snapshots_rustls__rustls_self_signed_private_key_type.snap | Snapshot output for rustls self-signed private key type (redacted length) |
| crates/uselesskey-rustls/tests/snapshots/snapshots_rustls__rustls_self_signed_cert_der_len.snap | Snapshot output for rustls self-signed cert DER length |
| crates/uselesskey-rustls/tests/snapshots/snapshots_rustls__rustls_chain_private_key_type.snap | Snapshot output for rustls chain leaf private key type (redacted length) |
| crates/uselesskey-rustls/tests/snapshots/snapshots_rustls__rustls_chain_cert_der_lengths.snap | Snapshot output for rustls chain DER lengths/count |
| crates/uselesskey-rustls/Cargo.toml | Adds serde/insta dev-dependencies for rustls snapshots |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #![allow(unused)] | ||
|
|
There was a problem hiding this comment.
#![allow(unused)] at the crate level can mask genuine issues in tests (e.g., leftover dead code/imports). Prefer removing it, or scoping the allow to the smallest surface area (e.g., on a specific helper/module, or using a narrower lint like dead_code / unused_imports).
| #![allow(unused)] |
| leaf_cert_der_len: chain_certs[0].as_ref().len(), | ||
| intermediate_cert_der_len: chain_certs[1].as_ref().len(), |
There was a problem hiding this comment.
Indexing into chain_certs[0] and [1] will panic if the adapter ever returns an unexpected chain length (including regressions you may actually want to snapshot with a clearer assertion message). Prefer using .get(0)/.get(1) with an expect message (or derive lengths via iteration) so failures are explicit and diagnostics are clearer.
| leaf_cert_der_len: chain_certs[0].as_ref().len(), | |
| intermediate_cert_der_len: chain_certs[1].as_ref().len(), | |
| leaf_cert_der_len: chain_certs | |
| .get(0) | |
| .expect("expected leaf certificate at index 0 in chain_certs") | |
| .as_ref() | |
| .len(), | |
| intermediate_cert_der_len: chain_certs | |
| .get(1) | |
| .expect("expected intermediate certificate at index 1 in chain_certs") | |
| .as_ref() | |
| .len(), |
| TokenShape { | ||
| kind: "api_key", | ||
| value_len: t.value().len(), | ||
| value_non_empty: !t.value().is_empty(), | ||
| } | ||
| }, | ||
| { | ||
| let t = fx.token("snapshot-bearer", TokenSpec::bearer()); | ||
| TokenShape { | ||
| kind: "bearer", | ||
| value_len: t.value().len(), | ||
| value_non_empty: !t.value().is_empty(), | ||
| } | ||
| }, | ||
| { | ||
| let t = fx.token("snapshot-oauth", TokenSpec::oauth_access_token()); | ||
| TokenShape { | ||
| kind: "oauth_access_token", | ||
| value_len: t.value().len(), | ||
| value_non_empty: !t.value().is_empty(), |
There was a problem hiding this comment.
t.value() is called twice per case. If value() allocates or computes, this adds avoidable work and can make tests noisier. Consider binding the value once (e.g., let v = t.value();) and using v.len() / !v.is_empty().
| TokenShape { | |
| kind: "api_key", | |
| value_len: t.value().len(), | |
| value_non_empty: !t.value().is_empty(), | |
| } | |
| }, | |
| { | |
| let t = fx.token("snapshot-bearer", TokenSpec::bearer()); | |
| TokenShape { | |
| kind: "bearer", | |
| value_len: t.value().len(), | |
| value_non_empty: !t.value().is_empty(), | |
| } | |
| }, | |
| { | |
| let t = fx.token("snapshot-oauth", TokenSpec::oauth_access_token()); | |
| TokenShape { | |
| kind: "oauth_access_token", | |
| value_len: t.value().len(), | |
| value_non_empty: !t.value().is_empty(), | |
| let v = t.value(); | |
| TokenShape { | |
| kind: "api_key", | |
| value_len: v.len(), | |
| value_non_empty: !v.is_empty(), | |
| } | |
| }, | |
| { | |
| let t = fx.token("snapshot-bearer", TokenSpec::bearer()); | |
| let v = t.value(); | |
| TokenShape { | |
| kind: "bearer", | |
| value_len: v.len(), | |
| value_non_empty: !v.is_empty(), | |
| } | |
| }, | |
| { | |
| let t = fx.token("snapshot-oauth", TokenSpec::oauth_access_token()); | |
| let v = t.value(); | |
| TokenShape { | |
| kind: "oauth_access_token", | |
| value_len: v.len(), | |
| value_non_empty: !v.is_empty(), |
| chain_pem_cert_count: chain | ||
| .chain_pem() | ||
| .matches("-----BEGIN CERTIFICATE-----") | ||
| .count(), | ||
| root_pem_starts_with_cert_header: chain | ||
| .root_cert_pem() | ||
| .starts_with("-----BEGIN CERTIFICATE-----"), | ||
| leaf_pem_starts_with_cert_header: chain | ||
| .leaf_cert_pem() | ||
| .starts_with("-----BEGIN CERTIFICATE-----"), | ||
| leaf_key_pem_starts_with_key_header: chain | ||
| .leaf_private_key_pkcs8_pem() | ||
| .starts_with("-----BEGIN PRIVATE KEY-----"), | ||
| }; |
There was a problem hiding this comment.
1. Pem markers committed in tests 📘 Rule violation ⛨ Security
The new tonic snapshot tests contain literal PEM boundary markers (certificate/private key) in source code, which are secret-shaped strings that can trigger secret scanners. This violates the repository requirement to avoid committing secret-shaped PEM material.
Agent Prompt
## Issue description
The tonic snapshot tests add literal PEM boundary markers (e.g., `-----BEGIN PRIVATE KEY-----`) into committed source files. This is secret-shaped content and violates the no-PEM/DER/tokens-in-repo rule.
## Issue Context
Even without the base64 payload, these markers are commonly flagged by secret scanners and are explicitly called out in the compliance rule as content to avoid committing.
## Fix Focus Areas
- crates/uselesskey-tonic/tests/snapshots_tonic.rs[83-96]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| use serde::Serialize; | ||
| use testutil::fx; | ||
| use uselesskey_tonic::{TonicClientTlsExt, TonicIdentityExt, TonicMtlsExt, TonicServerTlsExt}; | ||
| use uselesskey_x509::{ChainSpec, X509FactoryExt, X509Spec}; | ||
|
|
There was a problem hiding this comment.
2. Tests break no-default builds 🐞 Bug ⛯ Reliability
The new tests/snapshots_*.rs integration tests in uselesskey-tonic and uselesskey-rustls unconditionally import and use X.509 adapters, so cargo test -p <crate> --no-default-features will fail to compile. This conflicts with the crates’ own feature modeling (default = ["x509"], with x509 optional) and the repo’s documented expectation of feature-matrix/no-default coverage.
Agent Prompt
### Issue description
The new integration snapshot tests in `uselesskey-tonic` and `uselesskey-rustls` unconditionally depend on X.509 APIs. Because both crates model `x509` as an **optional** feature (enabled by default), `cargo test -p <crate> --no-default-features` will fail to compile.
### Issue Context
The repo documents feature-matrix validation including `no-default` builds. The facade snapshot tests already show the desired pattern by gating X.509 snapshots behind `#[cfg(feature = "x509")]`.
### Fix Focus Areas
- crates/uselesskey-tonic/tests/snapshots_tonic.rs[1-12]
- crates/uselesskey-rustls/tests/snapshots_rustls.rs[1-12]
### Suggested change
Add a crate-level guard at the top of each file:
```rust
#![cfg(feature = "x509")]
```
Or wrap the entire contents in a feature-gated module:
```rust
#[cfg(feature = "x509")]
mod snapshot_tests { /* existing contents */ }
```
(Optionally, you can also add `[[test]]` sections with `required-features = ["x509"]` in each crate’s `Cargo.toml` if you prefer Cargo-level gating.)
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Adds insta snapshot tests for uselesskey facade, rustls adapter, and tonic adapter crates. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
d28f018 to
2642ae5
Compare
|
Closing: Persistent merge conflicts from many waves landing on main. Facade snapshot coverage is superseded by wave-17 snapshots (PR #41, merged) and upcoming doc-test waves. [Class D: superseded] |
Adds 16 insta snapshot tests across 3 crates: uselesskey facade (9), rustls (4), tonic (3). All crypto material redacted. Deterministic via seed.
Determinism impact: None
Policy impact: None