Skip to main content

Module testing

Module testing 

Source
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 Exact rotations of one token, exactly one wins and the losers’ tokens are never stored.
current_rotation
Supersede::Current rotates 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::Exact rotates 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_used may name the token the same update’s rotation inserts.
mark_used_sets_once
mark_used sets first_used_at once and never moves it.
newer_token_used_is_tracked
newer_token_used reports whether a later token of the session has been presented.
none_fields_are_preserved
None fields leave stored values alone; Some fields 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_for builds on sharded stores.
records_round_trip
Unicode subjects and a fully populated baseline survive storage unchanged.
rotation_if_issued_before
Supersede::CurrentIssuedBefore only 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 at now, 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.