uselesskey-token
Token-shaped fixtures for tests, built on uselesskey-core.
Generates deterministic or random token strings so authorization code paths can be tested without committing secret-looking blobs.
Token specification, base62, shape, and negative-token internals are owned by
this crate under uselesskey_token::srp::*; users should normally import
TokenSpec, NegativeToken, TokenFactoryExt, and TokenFixture from the
crate root or from the uselesskey facade.
Part of the uselesskey workspace. Use
the facade crate for the simplest experience, or depend on this crate directly
for minimal compile time.
What It Provides
- API-key style tokens:
uk_test_<base62> - Opaque bearer tokens: base64url data
- OAuth access tokens in JWT shape:
header.payload.signature - Scanner-safe negative token shapes for parser and validator error paths
Usage
use Factory;
use ;
let fx = random;
let api_key = fx.token;
let bearer = fx.token;
let oauth = fx.token;
assert!;
assert!;
assert_eq!;
let expired = oauth.negative_value;
let near_miss_api_key = api_key.negative_value;
assert_eq!;
assert!;
assert!;
Deterministic Mode
use ;
use ;
let seed = from_env_value.unwrap;
let fx = deterministic;
// Same seed + label + spec = same token
let t1 = fx.token;
let t2 = fx.token;
assert_eq!;
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
See the uselesskey crate for full
documentation.