From dc7074bbf39aff895ba52abd5e7b7e9bb643cf27 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Tue, 28 Oct 2025 01:41:13 -0400 Subject: Convert the last stray tests to be generic over components deriveable from an App. There are a few places in the test fixtures that still call `App` methods directly, as they call `app.users()` (which, as per previous commits, has no `FromRef` impl). --- src/test/fixtures/identity.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/test/fixtures/identity.rs') diff --git a/src/test/fixtures/identity.rs b/src/test/fixtures/identity.rs index 93e4a38..20929f9 100644 --- a/src/test/fixtures/identity.rs +++ b/src/test/fixtures/identity.rs @@ -1,11 +1,15 @@ +use axum::extract::FromRef; + use crate::{ app::App, clock::RequestedAt, + login::app::Logins, name::Name, password::Password, test::fixtures, token::{ Token, + app::Tokens, extract::{Identity, IdentityCookie}, }, }; @@ -15,23 +19,30 @@ pub async fn create(app: &App, created_at: &RequestedAt) -> Identity { logged_in(app, &credentials, created_at).await } -pub async fn from_cookie( +pub async fn from_cookie( app: &App, cookie: &IdentityCookie, validated_at: &RequestedAt, -) -> Identity { +) -> Identity +where + Tokens: FromRef, +{ let secret = cookie.secret().expect("identity token has a secret"); - app.tokens() + Tokens::from_ref(app) .validate(&secret, validated_at) .await .expect("always validates newly-issued secret") } -pub async fn logged_in( +pub async fn logged_in( app: &App, credentials: &(Name, Password), issued_at: &RequestedAt, -) -> Identity { +) -> Identity +where + Tokens: FromRef, + Logins: FromRef, +{ let secret = fixtures::cookie::logged_in(app, credentials, issued_at).await; from_cookie(app, &secret, issued_at).await } -- cgit v1.2.3