Available on crate feature
testing only.Expand description
Conformance suite for SessionStore implementations.
Every built-in store runs this suite. Run it against your own store with
store_conformance!, which needs tokio (with the macros and
rt-multi-thread features) as a dev-dependency:
use session_guard::ValkeyStore;
session_guard::store_conformance!(|| async {
ValkeyStore::connect("redis://localhost:6379").await.unwrap()
});The tests use random ids and subjects and whole-second timestamps, so they can share one database with each other and with other data.
Every check panics when the store breaks the contract.
Functions§
- apply_
to_ missing_ session - Updating a session that does not exist is not an error.
- concurrent_
rotation_ has_ one_ winner - Of many concurrent
Exactrotations of one token, exactly one wins and the losers’ tokens are never stored. - current_
rotation Supersede::Currentrotates whatever token is current.- delete_
expired_ absolute_ and_ idle - Expired (absolute) and idle sessions are purged; live ones stay.
- delete_
session_ removes_ tokens - Deleting a session removes its tokens and reports whether it existed.
- delete_
subject_ sessions - Deleting a subject’s sessions returns their ids and leaves other subjects alone.
- event_
claims_ dedupe_ within_ window - A claim succeeds once per session and kind per window, across store handles.
- events_
record_ and_ purge - Events are recorded and purged strictly before the cutoff.
- exact_
rotation_ happens_ once Supersede::Exactrotates only while that token is current.- insert_
and_ find - An inserted session is found by its token, which starts current and unused.
- list_
subject_ sessions - Listing returns exactly the subject’s sessions.
- mark_
used_ reaches_ the_ rotated_ token mark_usedmay name the token the same update’s rotation inserts.- mark_
used_ sets_ once mark_usedsetsfirst_used_atonce and never moves it.- newer_
token_ used_ is_ tracked newer_token_usedreports whether a later token of the session has been presented.- none_
fields_ are_ preserved Nonefields leave stored values alone;Somefields replace them.- now_
secs - The current time truncated to whole seconds.
- prune_
superseded_ tokens - A rotation prunes the session’s tokens superseded before its cutoff, and only those.
- random_
hash - A fresh random token hash in bucket 0, so it pairs with the sessions
sample_session_forbuilds on sharded stores. - records_
round_ trip - Unicode subjects and a fully populated baseline survive storage unchanged.
- rotation_
if_ issued_ before Supersede::CurrentIssuedBeforeonly rotates a current token older than the instant.- sample_
session - A session for a random subject, created at
now, expiring in a day. - sample_
session_ for - A session for
subject(canonical JSON), created atnow, expiring in a day. - session_
without_ origin - A session without an origin (created before 0.2) is stored and read back as such.
- subject_
claims_ dedupe_ within_ window - A claim succeeds once per subject and kind per window, independent of session claims, and purging events removes old subject claims.
- unknown_
token_ is_ none - An unknown token finds nothing.