Skip to content

test: add API surface stability and smoke tests#203

Merged
EffortlessSteven merged 1 commit into
mainfrom
wave-172/impl
Mar 5, 2026
Merged

test: add API surface stability and smoke tests#203
EffortlessSteven merged 1 commit into
mainfrom
wave-172/impl

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Add 44 API surface stability tests covering all public traits, types, methods, negative fixtures, and insta snapshots for the uselesskey workspace. Tests are gated behind the api-surface feature flag.

@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.

@coderabbitai

coderabbitai Bot commented Mar 3, 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 10 minutes and 47 seconds before requesting another review.

⌛ 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.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 900ad3d1-7466-401c-9ffd-ea8bd64b75e9

📥 Commits

Reviewing files that changed from the base of the PR and between 683c78a and 5095aee.

⛔ Files ignored due to path filters (9)
  • Cargo.lock is excluded by !**/*.lock
  • tests/snapshots/api_surface__api_shape_snapshots__core_types_shape.snap is excluded by !**/*.snap
  • tests/snapshots/api_surface__api_shape_snapshots__ecdsa_api_shape.snap is excluded by !**/*.snap
  • tests/snapshots/api_surface__api_shape_snapshots__ed25519_api_shape.snap is excluded by !**/*.snap
  • tests/snapshots/api_surface__api_shape_snapshots__hmac_api_shape.snap is excluded by !**/*.snap
  • tests/snapshots/api_surface__api_shape_snapshots__negative_fixtures_shape.snap is excluded by !**/*.snap
  • tests/snapshots/api_surface__api_shape_snapshots__rsa_api_shape.snap is excluded by !**/*.snap
  • tests/snapshots/api_surface__api_shape_snapshots__token_api_shape.snap is excluded by !**/*.snap
  • tests/snapshots/api_surface__api_shape_snapshots__x509_api_shape.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • tests/Cargo.toml
  • tests/api_surface.rs

Walkthrough

This PR introduces a comprehensive API surface test suite by adding configuration to tests/Cargo.toml (new dependencies: uselesskey-token and insta, plus an api-surface feature) and creating tests/api_surface.rs with 611 lines of tests exercising public APIs across multiple cryptographic modules using snapshot-based verification.

Changes

Cohort / File(s) Summary
Test Configuration
tests/Cargo.toml
Added optional dependencies (uselesskey-token, insta) and created new api-surface feature aggregating multiple uselesskey crypto modules. Extended all-integration-tests list and registered new api_surface test binary with feature guard.
API Surface Tests
tests/api_surface.rs
Introduced comprehensive test suite (611 lines) covering factory modes, conditional crypto modules (RSA, ECDSA, Ed25519, HMAC, Token, X.509), serialization formats (PEM/DER/JWK/JWKS), snapshot-based API shape verification via insta, debug safety checks, error handling with negative fixtures, and cross-type interoperability.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 Hops through crypto lands so wide,
Testing surfaces, side by side,
RSA, ECDSA, Ed25519's gleam,
Snapshots verify the API dream!
🔐✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding API surface stability and smoke tests, which aligns with the changeset that introduces 44 API surface stability tests and modifies Cargo.toml to support the new api-surface feature.
Description check ✅ Passed The description is directly related to the changeset, providing specific details about the 44 API surface stability tests, coverage of public traits/types/methods, negative fixtures, insta snapshots, and the api-surface feature flag.
Docstring Coverage ✅ Passed Docstring coverage is 94.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch wave-172/impl

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/api_surface.rs`:
- Line 1: Add the crate-level attribute to forbid unsafe code by inserting the
directive #![forbid(unsafe_code)] as the very first line of tests/api_surface.rs
(before the existing module doc comment `//! API surface stability and smoke
tests.`) so the test crate disallows unsafe blocks; ensure the attribute is the
top-most item in the file.
- Around line 587-593: The test file uses function-scoped imports (e.g., use
uselesskey_core::{Factory, Seed}; and the various use uselesskey_*::{...} lines)
in one spot but the project guideline requires crate-level imports; change these
function-scoped imports to top-of-file (crate-level) imports and apply the same
transformation consistently to every test in this file (all occurrences matching
the patterns EcdsaFactoryExt/EcdsaSpec, Ed25519FactoryExt/Ed25519Spec,
HmacFactoryExt/HmacSpec, RsaFactoryExt/RsaSpec, TokenFactoryExt/TokenSpec,
X509FactoryExt/X509Spec and uselesskey_core::{Factory, Seed}) so that imports
are consolidated at module scope and no individual test functions retain their
own duplicate use statements.

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7805f42 and 683c78a.

⛔ Files ignored due to path filters (9)
  • Cargo.lock is excluded by !**/*.lock
  • tests/snapshots/api_surface__api_shape_snapshots__core_types_shape.snap is excluded by !**/*.snap
  • tests/snapshots/api_surface__api_shape_snapshots__ecdsa_api_shape.snap is excluded by !**/*.snap
  • tests/snapshots/api_surface__api_shape_snapshots__ed25519_api_shape.snap is excluded by !**/*.snap
  • tests/snapshots/api_surface__api_shape_snapshots__hmac_api_shape.snap is excluded by !**/*.snap
  • tests/snapshots/api_surface__api_shape_snapshots__negative_fixtures_shape.snap is excluded by !**/*.snap
  • tests/snapshots/api_surface__api_shape_snapshots__rsa_api_shape.snap is excluded by !**/*.snap
  • tests/snapshots/api_surface__api_shape_snapshots__token_api_shape.snap is excluded by !**/*.snap
  • tests/snapshots/api_surface__api_shape_snapshots__x509_api_shape.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • tests/Cargo.toml
  • tests/api_surface.rs

Comment thread tests/api_surface.rs
@@ -0,0 +1,611 @@
//! API surface stability and smoke tests.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check if forbid(unsafe_code) exists at the start of the file
echo "=== Checking for #![forbid(unsafe_code)] ==="
rg -n '^\s*#!\[forbid\(unsafe_code\)\]' tests/api_surface.rs || echo "NOT FOUND"

echo ""
echo "=== First 20 lines of file ==="
head -20 tests/api_surface.rs

echo ""
echo "=== Check for function-local imports around lines 587-593 ==="
sed -n '585,595p' tests/api_surface.rs | cat -n

Repository: EffortlessMetrics/uselesskey

Length of output: 1586


Add #![forbid(unsafe_code)] to crate root.

Line 1 must include #![forbid(unsafe_code)] so unsafe blocks cannot be introduced in this test crate, as required by the coding guidelines for all **/*.rs files.

Proposed fix
+#![forbid(unsafe_code)]
 //! API surface stability and smoke tests.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
//! API surface stability and smoke tests.
#![forbid(unsafe_code)]
//! API surface stability and smoke tests.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/api_surface.rs` at line 1, Add the crate-level attribute to forbid
unsafe code by inserting the directive #![forbid(unsafe_code)] as the very first
line of tests/api_surface.rs (before the existing module doc comment `//! API
surface stability and smoke tests.`) so the test crate disallows unsafe blocks;
ensure the attribute is the top-most item in the file.

Comment thread tests/api_surface.rs
Comment on lines +587 to +593
use uselesskey_core::{Factory, Seed};
use uselesskey_ecdsa::{EcdsaFactoryExt, EcdsaSpec};
use uselesskey_ed25519::{Ed25519FactoryExt, Ed25519Spec};
use uselesskey_hmac::{HmacFactoryExt, HmacSpec};
use uselesskey_rsa::{RsaFactoryExt, RsaSpec};
use uselesskey_token::{TokenFactoryExt, TokenSpec};
use uselesskey_x509::{X509FactoryExt, X509Spec};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

🧩 Analysis chain

🏁 Script executed:

# First, let's check the file exists and examine lines around 587-593
wc -l tests/api_surface.rs

Repository: EffortlessMetrics/uselesskey

Length of output: 96


🏁 Script executed:

# Read the actual content at lines 587-593
sed -n '580,600p' tests/api_surface.rs

Repository: EffortlessMetrics/uselesskey

Length of output: 1050


🏁 Script executed:

# Check the broader context of the test function and imports
sed -n '575,610p' tests/api_surface.rs

Repository: EffortlessMetrics/uselesskey

Length of output: 1618


🏁 Script executed:

# Search for all function-scoped imports in the file
rg -n '^\s{4,}use\s+uselesskey_' tests/api_surface.rs | head -20

Repository: EffortlessMetrics/uselesskey

Length of output: 1188


🏁 Script executed:

# Check if there are module-level imports with cfg guards
rg -n '#\[cfg.*api-surface' tests/api_surface.rs | head -10

Repository: EffortlessMetrics/uselesskey

Length of output: 358


Apply crate-level imports consistently across all test functions in this file.

The coding guideline requires crate-level imports in Rust source files. However, note that lines 587-593 follow the same function-scoped import pattern used in every other test function in this file (lines 37, 76, 133, 163, 191, 216, 244, 297, 343, 392). If moving to crate-level is required, apply this change uniformly across all tests in this file for consistency rather than in isolation.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/api_surface.rs` around lines 587 - 593, The test file uses
function-scoped imports (e.g., use uselesskey_core::{Factory, Seed}; and the
various use uselesskey_*::{...} lines) in one spot but the project guideline
requires crate-level imports; change these function-scoped imports to
top-of-file (crate-level) imports and apply the same transformation consistently
to every test in this file (all occurrences matching the patterns
EcdsaFactoryExt/EcdsaSpec, Ed25519FactoryExt/Ed25519Spec,
HmacFactoryExt/HmacSpec, RsaFactoryExt/RsaSpec, TokenFactoryExt/TokenSpec,
X509FactoryExt/X509Spec and uselesskey_core::{Factory, Seed}) so that imports
are consolidated at module scope and no individual test functions retain their
own duplicate use statements.

@EffortlessSteven EffortlessSteven force-pushed the wave-172/impl branch 2 times, most recently from bd3a6d4 to f80e015 Compare March 5, 2026 14:21
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@EffortlessSteven EffortlessSteven merged commit 3b730cc into main Mar 5, 2026
3 of 4 checks passed
@EffortlessSteven EffortlessSteven deleted the wave-172/impl branch March 5, 2026 15:27
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.

1 participant