From 715e2324305203483c63af4b9af312f3cebd51a6 Mon Sep 17 00:00:00 2001 From: piquel Date: Sun, 22 Nov 2026 19:51:56 +0100 Subject: [PATCH] chore(lint): paths already in scope are no longer written in full --- Cargo.toml | 1 + apps/auth-service/src/account/tests.rs | 2 +- .../src/deliveries/email/tests.rs | 2 +- .../src/federation/tests/linking.rs | 4 +-- apps/auth-service/src/federation/tests/mod.rs | 14 +++++------ .../src/federation/tests/sign_in.rs | 2 +- .../src/federation/tests/signup.rs | 12 ++++----- apps/auth-service/src/notifications/tests.rs | 25 +++++++++++-------- apps/auth-service/src/oidc/error.rs | 2 +- apps/auth-service/src/oidc/tests/errors.rs | 4 +-- apps/auth-service/src/oidc/tests/logout.rs | 6 ++--- apps/auth-service/src/oidc/tests/mod.rs | 10 +++----- apps/auth-service/src/oidc/tests/protocol.rs | 2 +- .../auth-service/src/oidc/tests/sdk_routes.rs | 14 +++++------ apps/auth-service/src/oidc/tests/tokens.rs | 5 +--- apps/auth-service/src/passkey/tests/mod.rs | 6 ++--- apps/auth-service/src/security/http.rs | 2 +- apps/auth-service/src/security/mod.rs | 2 +- apps/auth-service/src/security/tests/mod.rs | 2 +- .../src/security/tests/rate_limits.rs | 2 +- apps/auth-service/src/tests.rs | 4 +-- .../auth-service/src/web/admin/tests/frame.rs | 6 ++--- apps/web/src/site/tests.rs | 5 +--- crates/auth-sdk/src/axum/tests/backchannel.rs | 2 +- crates/auth-sdk/src/tests.rs | 8 +++--- crates/common/src/form.rs | 4 +-- crates/common/src/notifications/tests.rs | 2 +- crates/common/src/protocol/oauth.rs | 2 +- crates/common/src/tests.rs | 14 +++++------ crates/crypto/src/signing/tests.rs | 3 +-- crates/database/src/connection/tests.rs | 14 +++++------ .../src/repositories/deletions/tests.rs | 2 +- .../src/repositories/deliveries/mod.rs | 5 +--- 33 files changed, 89 insertions(+), 101 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 16baab021..b7b23e85e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,6 +28,7 @@ version = "0.1.0" [workspace.lints.rust] unsafe_code = "forbid" missing_docs = "warn" +unused_qualifications = "warn" # Every Clippy warning fails CI: `just rust lint` runs Clippy with `-D warnings`. # The groups sit at priority -1 so the single lints below can override them. diff --git a/apps/auth-service/src/account/tests.rs b/apps/auth-service/src/account/tests.rs index df5314f47..7aadc0e96 100644 --- a/apps/auth-service/src/account/tests.rs +++ b/apps/auth-service/src/account/tests.rs @@ -334,7 +334,7 @@ impl AccountOperation { Self::ListNotifications => service.notifications(viewer, None).await.map(drop), // Checked before it looks the notification up, so any ID will do. Self::ViewNotification => service - .notification(viewer, sourceorigin_common::NotificationId::new()) + .notification(viewer, NotificationId::new()) .await .map(drop), Self::ViewNotificationPreferences => { diff --git a/apps/auth-service/src/deliveries/email/tests.rs b/apps/auth-service/src/deliveries/email/tests.rs index 7335163c5..20ee59420 100644 --- a/apps/auth-service/src/deliveries/email/tests.rs +++ b/apps/auth-service/src/deliveries/email/tests.rs @@ -729,7 +729,7 @@ async fn security_emails_carry_the_sign_out_link() { panic!("a security notification's email carries the link"); }; let link = url::Url::parse(&link).expect("URL"); - assert_eq!(link.path(), routes::page::SIGN_OUT); + assert_eq!(link.path(), page::SIGN_OUT); let query: std::collections::HashMap<_, _> = link.query_pairs().into_owned().collect(); let checked = config.sign_out_links.check(&crate::notifications::Link { id: query["id"].parse().expect("notification"), diff --git a/apps/auth-service/src/federation/tests/linking.rs b/apps/auth-service/src/federation/tests/linking.rs index 562153ad6..bde6fd936 100644 --- a/apps/auth-service/src/federation/tests/linking.rs +++ b/apps/auth-service/src/federation/tests/linking.rs @@ -13,7 +13,7 @@ impl TestApp { ) -> Result { let account = AccountService::new(self.app.database.clone()); let owner = account - .owner(security::RequestContext::TEST, &Self::cookies(cookie)) + .owner(RequestContext::TEST, &Self::cookies(cookie)) .await .expect("session lookup") .expect("signed in"); @@ -76,7 +76,7 @@ async fn linking_requires_target_confirmation_and_unlink_releases_subject_withou test.app .database .sessions() - .confirm_passkey(target_session, PasskeyId::new(), chrono::Utc::now()) + .confirm_passkey(target_session, PasskeyId::new(), Utc::now()) .await .expect("confirm"); let return_to = test diff --git a/apps/auth-service/src/federation/tests/mod.rs b/apps/auth-service/src/federation/tests/mod.rs index 9aa30bae0..54dc37146 100644 --- a/apps/auth-service/src/federation/tests/mod.rs +++ b/apps/auth-service/src/federation/tests/mod.rs @@ -50,7 +50,7 @@ impl Drop for TestApp { impl TestApp { /// The federation routes and the shared settings, as the public listener /// serves them. - fn routes(&self) -> axum::Router { + fn routes(&self) -> Router { self.app .clone() .routes() @@ -64,9 +64,7 @@ impl TestApp { async fn with_email(email: Option<&str>) -> Self { let database = crate::tests::Replicas::database().await; let subject = u64::from_be_bytes( - sourceorigin_crypto::Secret::generate() - .expect("random") - .as_bytes()[..8] + Secret::generate().expect("random").as_bytes()[..8] .try_into() .expect("eight bytes"), ) @@ -108,7 +106,7 @@ impl TestApp { database, &FederationConfig { origin: "https://auth.sourceorigin.dev/" - .parse::() + .parse::() .expect("origin"), providers: BTreeMap::from([(Provider::GitHub, config)]), }, @@ -252,7 +250,7 @@ impl TestApp { if confirmed { database .sessions() - .confirm_passkey(browser.session_id, PasskeyId::new(), chrono::Utc::now()) + .confirm_passkey(browser.session_id, PasskeyId::new(), Utc::now()) .await .expect("confirm"); } @@ -276,7 +274,7 @@ impl TestApp { .to_str() .expect("location"); let target = Url::parse(location).expect("target"); - assert_eq!(target.path(), crate::routes::page::LOGIN); + assert_eq!(target.path(), routes::page::LOGIN); assert!( target .query_pairs() @@ -296,7 +294,7 @@ impl TestApp { body: &serde_json::Value, ) -> Request { let mut request = Request::builder() - .extension(crate::security::RequestContext::TEST) + .extension(RequestContext::TEST) .method(method) .uri(path) .header(header::CONTENT_TYPE, "application/json"); diff --git a/apps/auth-service/src/federation/tests/sign_in.rs b/apps/auth-service/src/federation/tests/sign_in.rs index 0e6e67b8b..a14ffc417 100644 --- a/apps/auth-service/src/federation/tests/sign_in.rs +++ b/apps/auth-service/src/federation/tests/sign_in.rs @@ -13,7 +13,7 @@ impl TestApp { .insert_identity(&InsertExternalIdentity { id: TokenId::new(), user_id, - provider: sourceorigin_common::Provider::GitHub, + provider: Provider::GitHub, issuer: ProviderEndpoints::new(Provider::GitHub) .expect("GitHub facts") .issuer diff --git a/apps/auth-service/src/federation/tests/signup.rs b/apps/auth-service/src/federation/tests/signup.rs index 8033f644f..5f99ac603 100644 --- a/apps/auth-service/src/federation/tests/signup.rs +++ b/apps/auth-service/src/federation/tests/signup.rs @@ -14,7 +14,7 @@ impl TestApp { headers: &HeaderMap, user: UserId, ) -> Result, FederationError> { - let actor = security::RequestContext::TEST.actor(Actor::Anonymous); + let actor = RequestContext::TEST.actor(Actor::Anonymous); FederationApplication::attach_signup(tx, &actor, &self.email, ip, pending, headers, user) .await } @@ -40,7 +40,7 @@ async fn onboarding_commits_only_with_first_key_and_browser_and_never_claims_exi assert!( test.attach( &mut tx, - security::RequestContext::TEST.client_ip, + RequestContext::TEST.client_ip, pending.id, &headers, user @@ -54,7 +54,7 @@ async fn onboarding_commits_only_with_first_key_and_browser_and_never_claims_exi assert!( test.attach( &mut tx, - security::RequestContext::TEST.client_ip, + RequestContext::TEST.client_ip, pending.id, &HeaderMap::new(), user @@ -64,7 +64,7 @@ async fn onboarding_commits_only_with_first_key_and_browser_and_never_claims_exi ); test.attach( &mut tx, - security::RequestContext::TEST.client_ip, + RequestContext::TEST.client_ip, pending.id, &headers, user, @@ -90,7 +90,7 @@ async fn onboarding_commits_only_with_first_key_and_browser_and_never_claims_exi assert!( test.attach( &mut tx, - security::RequestContext::TEST.client_ip, + RequestContext::TEST.client_ip, pending.id, &headers, user @@ -202,7 +202,7 @@ async fn signup_skips_an_address_an_account_being_deleted_holds() { let mut tx = test.app.database.begin().await.expect("tx"); test.attach( &mut tx, - security::RequestContext::TEST.client_ip, + RequestContext::TEST.client_ip, pending.id, &headers, user, diff --git a/apps/auth-service/src/notifications/tests.rs b/apps/auth-service/src/notifications/tests.rs index 2d0e31965..d5041f962 100644 --- a/apps/auth-service/src/notifications/tests.rs +++ b/apps/auth-service/src/notifications/tests.rs @@ -281,7 +281,7 @@ async fn owners_choose_which_notifications_are_emailed() { let service = AccountService::new(harness.database.clone()); service - .unsubscribe(alice.user_id, crate::security::RequestContext::TEST) + .unsubscribe(alice.user_id, RequestContext::TEST) .await .expect("unsubscribe"); assert_eq!(preferences(&alice).await, announcements(false)); @@ -314,7 +314,7 @@ async fn the_sign_out_link_works_once_within_seven_days() { .expect("inbox")[0] .id; let service = AccountService::new(harness.database.clone()); - let context = crate::security::RequestContext::TEST; + let context = RequestContext::TEST; let passkeys = harness .database .passkeys() @@ -360,13 +360,16 @@ async fn the_sign_out_link_works_once_within_seven_days() { }) .collect(); assert_eq!(reasons.len(), 2, "{reasons:?}"); - assert!(reasons.iter().all(|(reason, actor)| *reason - == sourceorigin_common::events::RevocationReason::SignOutLink - && *actor - == Actor::User { - user_id: alice.user_id, - session_id: None - })); + assert!( + reasons + .iter() + .all(|(reason, actor)| *reason == RevocationReason::SignOutLink + && *actor + == Actor::User { + user_id: alice.user_id, + session_id: None + }) + ); assert!( !service .sign_out_everywhere(id, context) @@ -443,7 +446,7 @@ async fn support_signing_an_account_out_tells_its_owner_once() { &context, alice.user_id, sourceorigin_repository::SessionScope::All, - &sourceorigin_common::events::RevocationReason::Admin, + &RevocationReason::Admin, ) .await .expect("revoke"); @@ -501,7 +504,7 @@ async fn every_use_of_the_sign_out_link_is_in_the_history() { }) .collect() }; - let context = crate::security::RequestContext::TEST; + let context = RequestContext::TEST; let first = latest().await; assert!( service diff --git a/apps/auth-service/src/oidc/error.rs b/apps/auth-service/src/oidc/error.rs index 294e13e78..dcf1da2ec 100644 --- a/apps/auth-service/src/oidc/error.rs +++ b/apps/auth-service/src/oidc/error.rs @@ -149,7 +149,7 @@ pub(crate) enum OAuthError { Url(#[from] url::ParseError), /// A generated cookie could not be represented as an HTTP header. #[error("OIDC cookie header is invalid")] - CookieHeader(#[from] axum::http::header::InvalidHeaderValue), + CookieHeader(#[from] header::InvalidHeaderValue), /// The address of the page the browser goes on to could not be written. #[error("a page's address could not be written")] PageAddress(#[from] QueryError), diff --git a/apps/auth-service/src/oidc/tests/errors.rs b/apps/auth-service/src/oidc/tests/errors.rs index 59253a81f..f6a31ff8c 100644 --- a/apps/auth-service/src/oidc/tests/errors.rs +++ b/apps/auth-service/src/oidc/tests/errors.rs @@ -167,7 +167,7 @@ async fn userinfo_needs_the_openid_scope() { sub: flow.user_id.to_string(), aud: sourceorigin_common::protocol::claims::Audience::One("api".into()), client_id: flow.client.id.clone(), - jti: sourceorigin_common::TokenId::new(), + jti: TokenId::new(), scope: "profile".parse().expect("scopes"), iat: Utc::now(), exp: Utc::now() + chrono::Duration::minutes(5), @@ -176,7 +176,7 @@ async fn userinfo_needs_the_openid_scope() { sourceorigin_common::protocol::claims::AuthenticationClaims::default(), act: None, cnf: None, - profile: sourceorigin_common::protocol::claims::ProfileClaims::default(), + profile: ProfileClaims::default(), extra: (), }, ) diff --git a/apps/auth-service/src/oidc/tests/logout.rs b/apps/auth-service/src/oidc/tests/logout.rs index 4bd63a787..1797f2738 100644 --- a/apps/auth-service/src/oidc/tests/logout.rs +++ b/apps/auth-service/src/oidc/tests/logout.rs @@ -16,9 +16,9 @@ async fn logout_receiver() -> ( Arc>>, ) { let posted = Arc::new(Mutex::new(Vec::new())); - let receiver = axum::Router::new().route( + let receiver = Router::new().route( "/backchannel-logout", - axum::routing::post({ + post({ let posted = Arc::clone(&posted); async move |axum::Form(form): axum::Form>| { posted @@ -290,7 +290,7 @@ async fn an_unverifiable_hint_still_signs_out_and_stays_on_auth() { async fn a_hint_naming_another_account_says_so() { let flow = Flow::new(true, true).await; let (hint, sid) = id_token(&flow).await; - let other = crate::tests::Browser::new_account(&flow.app.database).await; + let other = Browser::new_account(&flow.app.database).await; let elsewhere = Flow { cookie: other.cookie, ..flow.clone() diff --git a/apps/auth-service/src/oidc/tests/mod.rs b/apps/auth-service/src/oidc/tests/mod.rs index e6fe7680f..802f37f87 100644 --- a/apps/auth-service/src/oidc/tests/mod.rs +++ b/apps/auth-service/src/oidc/tests/mod.rs @@ -45,7 +45,7 @@ struct Flow { app: OidcApplication, /// Where requests go: the OIDC routes and their pages, or a replica of the whole /// service. - router: axum::Router, + router: Router, /// The scenario's client, registered through [`ClientRegistry`](crate::ClientRegistry). client: ClientRegistration, /// The secret of a confidential scenario client. @@ -89,9 +89,7 @@ impl Flow { base64::engine::general_purpose::STANDARD.encode(format!("{}:{secret}", client.id)) ) }); - let origin = origin - .parse::() - .expect("issuer"); + let origin = origin.parse::().expect("issuer"); let config = AuthConfig::test(&origin); let federation = FederationApplication::new(db.clone(), &config.federation).expect("federation"); @@ -121,7 +119,7 @@ impl Flow { } } /// The same scenario, sending its requests to `router`, such as one of [`Replicas`]. - fn on(&self, router: &axum::Router) -> Self { + fn on(&self, router: &Router) -> Self { Self { router: router.clone(), ..self.clone() @@ -346,7 +344,7 @@ impl Flow { } /// The scenario's account, as the owner of its browser session. async fn owner(&self) -> crate::account::Owner { - let mut headers = axum::http::HeaderMap::new(); + let mut headers = HeaderMap::new(); headers.insert(header::COOKIE, self.cookie.parse().expect("cookie")); crate::account::AccountService::new(self.app.database.clone()) .owner(RequestContext::TEST, &headers) diff --git a/apps/auth-service/src/oidc/tests/protocol.rs b/apps/auth-service/src/oidc/tests/protocol.rs index 65e591144..dfa39e602 100644 --- a/apps/auth-service/src/oidc/tests/protocol.rs +++ b/apps/auth-service/src/oidc/tests/protocol.rs @@ -235,7 +235,7 @@ async fn oauth_failures_preserve_sources_and_statuses() { assert_eq!(response.status(), StatusCode::INTERNAL_SERVER_ERROR); let error = OAuthCode::InvalidGrant.reject_with( "code is \"malformed\" \u{2014} retry", - sourceorigin_crypto::CryptoError::SecretLength, + CryptoError::SecretLength, ); assert!(error.source().is_some()); let response = error.into_response(); diff --git a/apps/auth-service/src/oidc/tests/sdk_routes.rs b/apps/auth-service/src/oidc/tests/sdk_routes.rs index f715c4579..03e4b0016 100644 --- a/apps/auth-service/src/oidc/tests/sdk_routes.rs +++ b/apps/auth-service/src/oidc/tests/sdk_routes.rs @@ -67,11 +67,11 @@ impl LoginApp { let api = Router::new() .route( "/settings", - axum::routing::get(|_: RequireAuthentication| async { "settings" }), + get(|_: RequireAuthentication| async { "settings" }), ) .route( "/stubborn", - axum::routing::get(|| async { + get(|| async { let challenge = BearerChallenge::step_up(StepUpRequirement::default()); ( StatusCode::UNAUTHORIZED, @@ -117,12 +117,12 @@ impl LoginApp { let app = Router::new() .route( "/notes", - axum::routing::get(|user: SignedIn| async move { - user.login().access_token().expose().to_owned() - }), + get( + |user: SignedIn| async move { user.login().access_token().expose().to_owned() }, + ), ) - .route("/settings", axum::routing::get(call_api("/settings"))) - .route("/stubborn", axum::routing::get(call_api("/stubborn"))) + .route("/settings", get(call_api("/settings"))) + .route("/stubborn", get(call_api("/stubborn"))) .nest("/auth", auth.router()) .layer(auth.layer()); Self { flow, app, clock } diff --git a/apps/auth-service/src/oidc/tests/tokens.rs b/apps/auth-service/src/oidc/tests/tokens.rs index f7c9aa52c..ddcc1cb08 100644 --- a/apps/auth-service/src/oidc/tests/tokens.rs +++ b/apps/auth-service/src/oidc/tests/tokens.rs @@ -309,10 +309,7 @@ async fn concurrent_refreshes_across_replicas() { successors.push(json(response).await["refresh_token"].clone()); } if confidential { - assert!( - successors.iter().all(serde_json::Value::is_null), - "{successors:?}" - ); + assert!(successors.iter().all(Value::is_null), "{successors:?}"); assert_eq!(a.refresh(&token).await.status(), StatusCode::OK, "kept"); continue; } diff --git a/apps/auth-service/src/passkey/tests/mod.rs b/apps/auth-service/src/passkey/tests/mod.rs index 60177063b..76f3cb8b9 100644 --- a/apps/auth-service/src/passkey/tests/mod.rs +++ b/apps/auth-service/src/passkey/tests/mod.rs @@ -52,7 +52,7 @@ pub(crate) struct Fixture { /// Routes and persistence under test. app: PasskeyApplication, /// Where requests go: the passkey routes, or a replica of the whole service. - router: axum::Router, + router: Router, /// The software key that signs. key: SoftKey, /// HTTPS origin passed to the authenticator. @@ -153,7 +153,7 @@ impl Fixture { id } /// Sends the next requests to `router`, such as one of [`Replicas`]. - fn on(&mut self, router: &axum::Router) -> &mut Self { + fn on(&mut self, router: &Router) -> &mut Self { self.router = router.clone(); self } @@ -183,7 +183,7 @@ impl Fixture { .clone() .oneshot( request - .extension(crate::security::RequestContext::TEST) + .extension(RequestContext::TEST) .header("x-sourceorigin-csrf", "1") .body(Body::from(body)) .expect("request"), diff --git a/apps/auth-service/src/security/http.rs b/apps/auth-service/src/security/http.rs index d38677715..63b0ea952 100644 --- a/apps/auth-service/src/security/http.rs +++ b/apps/auth-service/src/security/http.rs @@ -162,7 +162,7 @@ pub(crate) enum HttpSecurityError { MultipleForwardedHeaders, /// The forwarded header is not valid HTTP text. #[error("forwarded address is not HTTP text")] - ForwardedHeader(#[from] axum::http::header::ToStrError), + ForwardedHeader(#[from] header::ToStrError), /// The forwarded header does not contain a single IP address. #[error("forwarded address is not a single IP address")] ForwardedAddress(#[from] std::net::AddrParseError), diff --git a/apps/auth-service/src/security/mod.rs b/apps/auth-service/src/security/mod.rs index e4ac18774..ff21e6055 100644 --- a/apps/auth-service/src/security/mod.rs +++ b/apps/auth-service/src/security/mod.rs @@ -214,7 +214,7 @@ impl IntoResponse for ApiError { }), ) .into_response(); - response.extensions_mut().insert(page::Explanation(message)); + response.extensions_mut().insert(Explanation(message)); if let Some(retry_after) = self.retry_after { response.headers_mut().insert( header::RETRY_AFTER, diff --git a/apps/auth-service/src/security/tests/mod.rs b/apps/auth-service/src/security/tests/mod.rs index c9312a05c..800497769 100644 --- a/apps/auth-service/src/security/tests/mod.rs +++ b/apps/auth-service/src/security/tests/mod.rs @@ -115,7 +115,7 @@ impl SecurityFixture { &crate::tests::WEB_ORIGIN.parse().expect("web origin"), ), }, - content: super::content::ContentPolicy::auth(&crate::AuthConfig::test( + content: content::ContentPolicy::auth(&crate::AuthConfig::test( &crate::tests::AUTH_ORIGIN.parse().expect("auth origin"), )) .expect("policy"), diff --git a/apps/auth-service/src/security/tests/rate_limits.rs b/apps/auth-service/src/security/tests/rate_limits.rs index f84605329..2e09bdc72 100644 --- a/apps/auth-service/src/security/tests/rate_limits.rs +++ b/apps/auth-service/src/security/tests/rate_limits.rs @@ -305,7 +305,7 @@ fn the_dashboard_search_has_its_own_budget() { ] { let mut request = HttpRequest::get(path); if live { - request = request.header(crate::security::endpoint::LIVE_HEADER, "1"); + request = request.header(endpoint::LIVE_HEADER, "1"); } let request = request.body(Body::empty()).expect("request"); assert_eq!( diff --git a/apps/auth-service/src/tests.rs b/apps/auth-service/src/tests.rs index 468116f56..c366aa2dd 100644 --- a/apps/auth-service/src/tests.rs +++ b/apps/auth-service/src/tests.rs @@ -848,7 +848,7 @@ impl TlsListener { tcp, acceptor: tokio_rustls::TlsAcceptor::from(Arc::new(config)), }; - let router = router.layer(axum::Extension(crate::security::RequestContext::TEST)); + let router = router.layer(Extension(RequestContext::TEST)); tokio::spawn(async move { axum::serve(listener, router).await }); reqwest::Certificate::from_der(certified.cert.der()).expect("trusted certificate") } @@ -856,7 +856,7 @@ impl TlsListener { impl axum::serve::Listener for TlsListener { type Io = tokio_rustls::server::TlsStream; - type Addr = std::net::SocketAddr; + type Addr = SocketAddr; /// Retries until a connection completes its handshake. async fn accept(&mut self) -> (Self::Io, Self::Addr) { diff --git a/apps/auth-service/src/web/admin/tests/frame.rs b/apps/auth-service/src/web/admin/tests/frame.rs index 183433f08..42cd21bdf 100644 --- a/apps/auth-service/src/web/admin/tests/frame.rs +++ b/apps/auth-service/src/web/admin/tests/frame.rs @@ -154,15 +154,15 @@ async fn the_top_bar_finds_pages_and_accounts() { /// what the update changed. #[test] fn a_read_started_before_forgetting_is_not_kept() { - let mut cache = super::AttentionCache::default(); + let mut cache = AttentionCache::default(); let Err(started) = cache.fresh() else { panic!("nothing found yet"); }; cache.forget(); - cache.keep(started, super::Attention::default()); + cache.keep(started, Attention::default()); let Err(now) = cache.fresh() else { panic!("the earlier read is dropped"); }; - cache.keep(now, super::Attention::default()); + cache.keep(now, Attention::default()); assert!(cache.fresh().is_ok(), "a read started since is kept"); } diff --git a/apps/web/src/site/tests.rs b/apps/web/src/site/tests.rs index 486d873db..bc01ffb31 100644 --- a/apps/web/src/site/tests.rs +++ b/apps/web/src/site/tests.rs @@ -63,10 +63,7 @@ async fn sends_every_other_path_to_auth() { assert_eq!(headers[header::CONTENT_SECURITY_POLICY], POLICY); assert_eq!(headers["cross-origin-opener-policy"], "same-origin"); assert_eq!(headers["cross-origin-resource-policy"], "same-origin"); - assert_eq!( - headers["permissions-policy"], - sourceorigin_common::protocol::isolation::PERMISSIONS_POLICY - ); + assert_eq!(headers["permissions-policy"], isolation::PERMISSIONS_POLICY); } /// Every answer forbids transforming its body, so the edge never rewrites the diff --git a/crates/auth-sdk/src/axum/tests/backchannel.rs b/crates/auth-sdk/src/axum/tests/backchannel.rs index de988d507..28df248f3 100644 --- a/crates/auth-sdk/src/axum/tests/backchannel.rs +++ b/crates/auth-sdk/src/axum/tests/backchannel.rs @@ -71,7 +71,7 @@ async fn backchannel_logout_hands_tokens_to_the_handler() { ); let received = Arc::new(Mutex::new(Vec::new())); - let fail = Arc::new(std::sync::atomic::AtomicBool::new(false)); + let fail = Arc::new(AtomicBool::new(false)); let app = login_app_with(&issuer, |routes| { let (received, fail) = (received.clone(), fail.clone()); routes.on_backchannel_logout(move |token: crate::LogoutToken| { diff --git a/crates/auth-sdk/src/tests.rs b/crates/auth-sdk/src/tests.rs index af054b752..c2a93e4ad 100644 --- a/crates/auth-sdk/src/tests.rs +++ b/crates/auth-sdk/src/tests.rs @@ -562,7 +562,7 @@ fn cache_control_is_read_like_a_cache() { let max_age = |value: &str| { let mut headers = header::HeaderMap::new(); headers.insert(header::CACHE_CONTROL, value.parse().expect("header")); - crate::http::Reply::max_age(&headers) + http::Reply::max_age(&headers) }; assert_eq!(max_age("public, max-age=600"), Some(600)); assert_eq!(max_age(r#"Max-Age="60""#), Some(60)); @@ -584,7 +584,7 @@ async fn hanging_servers_time_out() { .expect("URL"); let http = Http::plain(reqwest::Client::builder()); assert!(matches!( - http.get(&url, crate::http::Authorization::None).await, + http.get(&url, http::Authorization::None).await, Err(NetworkError::TimedOut { .. }) )); } @@ -620,7 +620,7 @@ async fn redirects_are_refused_whatever_the_client() { .post_form( &url, &[("refresh_token", "prt_v1_secret")], - crate::http::Authorization::None, + http::Authorization::None, ) .await; assert!(matches!( @@ -840,7 +840,7 @@ async fn userinfo_must_name_the_signed_in_user() { credentials: Credentials::None, redirect_uri: "https://client.example.com/callback".parse().expect("URL"), }); - let claims: crate::IdTokenClaims = serde_json::from_value(claims).expect("ID token claims"); + let claims: IdTokenClaims = serde_json::from_value(claims).expect("ID token claims"); let info = client .userinfo(&BearerToken::new("mine".into()), &claims) .await diff --git a/crates/common/src/form.rs b/crates/common/src/form.rs index 54bd62b30..6c31d03cd 100644 --- a/crates/common/src/form.rs +++ b/crates/common/src/form.rs @@ -20,14 +20,14 @@ impl Checkbox { impl Serialize for Checkbox { /// Writes `on` when checked, as browsers send it. - fn serialize(&self, serializer: S) -> std::result::Result { + fn serialize(&self, serializer: S) -> Result { self.0.then_some("on").serialize(serializer) } } impl<'de> Deserialize<'de> for Checkbox { /// Checked, whatever the value: an unchecked box is not sent at all. - fn deserialize>(deserializer: D) -> std::result::Result { + fn deserialize>(deserializer: D) -> Result { IgnoredAny::deserialize(deserializer).map(|_| Self(true)) } } diff --git a/crates/common/src/notifications/tests.rs b/crates/common/src/notifications/tests.rs index 4e676f380..c674ba9a3 100644 --- a/crates/common/src/notifications/tests.rs +++ b/crates/common/src/notifications/tests.rs @@ -238,7 +238,7 @@ fn sessionless_steps_and_known_browsers_alert_no_one() { session_id: None, }; let added = DomainEvent::PasskeyAdded { - passkey_id: crate::PasskeyId::new(), + passkey_id: PasskeyId::new(), }; assert_eq!(added.notification(&signing_up), None); assert_eq!(added.notification(&Actor::Anonymous), None); diff --git a/crates/common/src/protocol/oauth.rs b/crates/common/src/protocol/oauth.rs index 787914169..d1f8dbc9d 100644 --- a/crates/common/src/protocol/oauth.rs +++ b/crates/common/src/protocol/oauth.rs @@ -115,7 +115,7 @@ impl Interaction { } match (none, login, consent) { (true, false, false) => Some(Self::None), - (true, _, _) => Option::None, + (true, _, _) => None, (false, false, false) => Some(Self::AsNeeded), (false, true, false) => Some(Self::Login), (false, false, true) => Some(Self::Consent), diff --git a/crates/common/src/tests.rs b/crates/common/src/tests.rs index edd01152a..c4d409bff 100644 --- a/crates/common/src/tests.rs +++ b/crates/common/src/tests.rs @@ -256,9 +256,7 @@ fn one_event_per_kind() -> Vec { }, DomainEvent::EmailAdded { email_id: EmailId::new(), - address: Personal::Value( - email::NormalizedEmail::parse("a@example.com").expect("email"), - ), + address: Personal::Value(NormalizedEmail::parse("a@example.com").expect("email")), provider: None, }, DomainEvent::EmailVerified { @@ -327,8 +325,8 @@ fn one_event_per_kind() -> Vec { alert_id: AlertId::new(), alert, }, - DomainEvent::NotificationPreferenceChanged(crate::notifications::NotificationPreference { - category: crate::notifications::EmailCategory::Announcements, + DomainEvent::NotificationPreferenceChanged(notifications::NotificationPreference { + category: notifications::EmailCategory::Announcements, email: false, }), ] @@ -345,14 +343,14 @@ fn one_event_per_kind_covers_every_variant() { /// Captures the variant names serde expects when it reads an unknown tag. #[derive(Debug)] struct Tags(&'static [&'static str]); - impl std::fmt::Display for Tags { - fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + impl fmt::Display for Tags { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { write!(formatter, "{:?}", self.0) } } impl std::error::Error for Tags {} impl serde::de::Error for Tags { - fn custom(message: T) -> Self { + fn custom(message: T) -> Self { panic!("expected an unknown variant, not: {message}") } fn unknown_variant(_: &str, expected: &'static [&'static str]) -> Self { diff --git a/crates/crypto/src/signing/tests.rs b/crates/crypto/src/signing/tests.rs index b023a7382..4d2438dc0 100644 --- a/crates/crypto/src/signing/tests.rs +++ b/crates/crypto/src/signing/tests.rs @@ -88,8 +88,7 @@ fn rejects_algorithm_confusion_and_unrecognized_headers() { let header = URL_SAFE_NO_PAD.encode(br#"{"alg":"HS256","kid":"headers","typ":"JWT"}"#); let payload = URL_SAFE_NO_PAD.encode(serde_json::to_vec(&claims).expect("claims")); let input = format!("{header}.{payload}"); - let signature = - crate::Digest::hmac(key.public_key().pem().as_bytes(), input.as_bytes()).encoded(); + let signature = Digest::hmac(key.public_key().pem().as_bytes(), input.as_bytes()).encoded(); let token = format!("{input}.{signature}"); assert!(matches!( keys.verify::(&token, TokenType::Id, "https://auth.example"), diff --git a/crates/database/src/connection/tests.rs b/crates/database/src/connection/tests.rs index 4a6ef9c00..1c4c5754f 100644 --- a/crates/database/src/connection/tests.rs +++ b/crates/database/src/connection/tests.rs @@ -127,7 +127,7 @@ fn configuration_errors_name_the_setting_without_credentials() { #[ignore = "requires a disposable TEST_DATABASE_URL"] async fn cleanup_skips_rows_locked_by_requests() { let pool = Database::test_pool().await; - let bucket = uuid::Uuid::now_v7().as_bytes().to_vec(); + let bucket = Uuid::now_v7().as_bytes().to_vec(); // Concurrent tests purge too and can delete the expired row before it is // locked, so insert it again until the request holds it. let request = loop { @@ -173,7 +173,7 @@ async fn cleanup_skips_rows_locked_by_requests() { async fn cleanup_keeps_redeemed_codes_while_their_session_is_live() { let pool = Database::test_pool().await; let database = Database { pool: pool.clone() }; - let [user, session, code, family] = [(); 4].map(|()| uuid::Uuid::now_v7()); + let [user, session, code, family] = [(); 4].map(|()| Uuid::now_v7()); let client = format!("purge_{user}"); // One statement keeps the fixture short; foreign keys are checked at its end. sqlx::query( @@ -209,7 +209,7 @@ async fn cleanup_keeps_redeemed_codes_while_their_session_is_live() { .await .expect("redeemed grant"); let link = || async { - sqlx::query_scalar::<_, Option>( + sqlx::query_scalar::<_, Option>( "SELECT authorization_code_id FROM refresh_token_families WHERE id = $1", ) .bind(family) @@ -270,7 +270,7 @@ fn runtime_roles_need_plain_names() { &"a".repeat(64), ] { assert!( - matches!(role(user), Err(crate::DatabaseConnectionError::RoleName)), + matches!(role(user), Err(DatabaseConnectionError::RoleName)), "accepted {user}" ); } @@ -285,7 +285,7 @@ fn runtime_roles_need_plain_names() { #[ignore = "requires a disposable TEST_DATABASE_URL"] async fn runtime_role_has_only_row_privileges() { let owner = Database::test().await; - let name = format!("sourceorigin_auth_{}", uuid::Uuid::now_v7().simple()); + let name = format!("sourceorigin_auth_{}", Uuid::now_v7().simple()); let config = config_for(&name); let role = RuntimeRole::new(&config, "runtime password").expect("role"); // Overlapping runs, as two `migrate` jobs: one creates the role, the other @@ -403,7 +403,7 @@ fn config_for(user: &str) -> DatabaseConfig { #[ignore = "requires a disposable TEST_DATABASE_URL"] async fn provisioning_resets_what_it_does_not_grant() { let owner = Database::test().await; - let name = format!("sourceorigin_auth_{}", uuid::Uuid::now_v7().simple()); + let name = format!("sourceorigin_auth_{}", Uuid::now_v7().simple()); let role = RuntimeRole::new(&config_for(&name), "password").expect("role"); owner.provision(&role).await.expect("create"); let database: String = sqlx::query_scalar("SELECT current_database()::text") @@ -456,7 +456,7 @@ async fn provisioning_refuses_roles_that_could_do_more() { .expect_err("the owner is refused"); assert!(format!("{error:?}").contains("must not be the schema owner")); - let name = format!("sourceorigin_auth_{}", uuid::Uuid::now_v7().simple()); + let name = format!("sourceorigin_auth_{}", Uuid::now_v7().simple()); let role = RuntimeRole::new(&config_for(&name), "password").expect("role"); for (setup, undo, refusal) in [ ( diff --git a/crates/database/src/repositories/deletions/tests.rs b/crates/database/src/repositories/deletions/tests.rs index f1e310923..438322031 100644 --- a/crates/database/src/repositories/deletions/tests.rs +++ b/crates/database/src/repositories/deletions/tests.rs @@ -103,7 +103,7 @@ async fn restore_tokens_expire_and_end_with_the_deletion() { // Leaving 'deleting' any other way, through a plain enable or disable, ends // the schedule too. - let mut users = crate::UserRepository::from_pool(&pool); + let mut users = UserRepository::from_pool(&pool); users .set_status(user, AccountStatus::Deleting) .await diff --git a/crates/database/src/repositories/deliveries/mod.rs b/crates/database/src/repositories/deliveries/mod.rs index 694148eca..e8df0b921 100644 --- a/crates/database/src/repositories/deliveries/mod.rs +++ b/crates/database/src/repositories/deliveries/mod.rs @@ -229,10 +229,7 @@ impl DeliveryRepository<'_> { /// /// Returns [`DatabaseError`] if the query fails. #[cfg(any(test, feature = "test-util"))] - pub async fn payloads( - &mut self, - destination: &str, - ) -> Result, DatabaseError> { + pub async fn payloads(&mut self, destination: &str) -> Result, DatabaseError> { run!( self, fetch_all,