fmt fix
EBO <eric.bouhana@softalys.com> committé le 2026-06-05 07:29
8fab6769f91ad6f0c7e2b4a6bf6aea4b783fca2e
1 parent(s)
2 fichiers modifiés
+29
-11
M
crates/rustwarden-core/tests/csrf_protection.rs
+10
-2
@@ -129,7 +129,11 @@ async fn prime_token(app: &Router) -> (String, String) {
| 129 | 129 | .body(Body::empty()) |
| 130 | 130 | .expect("request"); |
| 131 | 131 | let resp = app.clone().oneshot(req).await.expect("oneshot"); |
| 132 | - assert_eq!(resp.status(), StatusCode::OK, "token priming GET must succeed"); | |
| 132 | + assert_eq!( | |
| 133 | + resp.status(), | |
| 134 | + StatusCode::OK, | |
| 135 | + "token priming GET must succeed" | |
| 136 | + ); | |
| 133 | 137 | let cookie = extract_session_cookie(&resp).expect("session cookie set"); |
| 134 | 138 | let token = body_string(resp).await; |
| 135 | 139 | assert_eq!(token.len(), 64, "token must be 64 hex chars"); |
@@ -217,7 +221,11 @@ async fn t10_echo_route_without_handler_csrf_code_is_protected() {
| 217 | 221 | .body(Body::empty()) |
| 218 | 222 | .unwrap(); |
| 219 | 223 | let resp = app.clone().oneshot(req).await.unwrap(); |
| 220 | - assert_eq!(resp.status(), StatusCode::FORBIDDEN, "no token must be rejected"); | |
| 224 | + assert_eq!( | |
| 225 | + resp.status(), | |
| 226 | + StatusCode::FORBIDDEN, | |
| 227 | + "no token must be rejected" | |
| 228 | + ); | |
| 221 | 229 | |
| 222 | 230 | // With a valid token (header channel) → 200. |
| 223 | 231 | let (cookie, token) = prime_token(&app).await; |
M
crates/rustwarden-fediverse-ui/tests/csrf_seam.rs
+19
-9
@@ -80,14 +80,17 @@ fn browser_app() -> Router {
| 80 | 80 | csrf_protection_with_config, |
| 81 | 81 | )); |
| 82 | 82 | |
| 83 | - browser_router | |
| 84 | - .with_state(mock_db()) | |
| 85 | - .layer(session_layer()) | |
| 83 | + browser_router.with_state(mock_db()).layer(session_layer()) | |
| 86 | 84 | } |
| 87 | 85 | |
| 88 | 86 | /// Extract the `id` session cookie value so it can be replayed. |
| 89 | 87 | fn extract_session_cookie(resp: &axum::response::Response) -> Option<String> { |
| 90 | - let raw = resp.headers().get(header::SET_COOKIE)?.to_str().ok()?.to_string(); | |
| 88 | + let raw = resp | |
| 89 | + .headers() | |
| 90 | + .get(header::SET_COOKIE)? | |
| 91 | + .to_str() | |
| 92 | + .ok()? | |
| 93 | + .to_string(); | |
| 91 | 94 | Some(raw.split(';').next()?.to_string()) |
| 92 | 95 | } |
| 93 | 96 |
@@ -106,7 +109,11 @@ async fn prime_token(app: &Router) -> (String, String) {
| 106 | 109 | .body(Body::empty()) |
| 107 | 110 | .expect("request"); |
| 108 | 111 | let resp = app.clone().oneshot(req).await.expect("oneshot"); |
| 109 | - assert_eq!(resp.status(), StatusCode::OK, "token priming GET must succeed"); | |
| 112 | + assert_eq!( | |
| 113 | + resp.status(), | |
| 114 | + StatusCode::OK, | |
| 115 | + "token priming GET must succeed" | |
| 116 | + ); | |
| 110 | 117 | let cookie = extract_session_cookie(&resp).expect("session cookie set"); |
| 111 | 118 | let token = body_string(resp).await; |
| 112 | 119 | assert_eq!(token.len(), 64, "token must be 64 hex chars"); |
@@ -166,7 +173,11 @@ async fn t10c_consent_post_with_valid_form_token_is_not_csrf_rejected() {
| 166 | 173 | // fail with 400 (bad form) or 415 (unsupported media type). Asserting their |
| 167 | 174 | // absence proves the handler actually received and parsed the replayed body, |
| 168 | 175 | // not just that the CSRF gate let the request through. |
| 169 | - assert_ne!(status, StatusCode::BAD_REQUEST, "form body must be reparsed, not rejected as malformed"); | |
| 176 | + assert_ne!( | |
| 177 | + status, | |
| 178 | + StatusCode::BAD_REQUEST, | |
| 179 | + "form body must be reparsed, not rejected as malformed" | |
| 180 | + ); | |
| 170 | 181 | assert_ne!( |
| 171 | 182 | status, |
| 172 | 183 | StatusCode::UNSUPPORTED_MEDIA_TYPE, |
@@ -198,9 +209,8 @@ fn machine_app_with_inbox() -> Router {
| 198 | 209 | rustwarden_core::config::auth::AuthConfig::from_env() |
| 199 | 210 | .expect("AuthConfig::from_env with JWT_SECRET set must succeed"), |
| 200 | 211 | ); |
| 201 | - let resolver: Arc<dyn rustwarden_fediverse::resolver::LocalUserResolver> = Arc::new( | |
| 202 | - rustwarden_fediverse::resolver::SeaOrmLocalUserResolver::new(db.clone()), | |
| 203 | - ); | |
| 212 | + let resolver: Arc<dyn rustwarden_fediverse::resolver::LocalUserResolver> = | |
| 213 | + Arc::new(rustwarden_fediverse::resolver::SeaOrmLocalUserResolver::new(db.clone())); | |
| 204 | 214 | let verifier: Arc< |
| 205 | 215 | dyn rustwarden_fediverse::services::fediverse_signal_service::SignatureVerifier, |
| 206 | 216 | > = Arc::new( |
GitRust