From 359310bad8c625f03661936b406e21b519059f37 Mon Sep 17 00:00:00 2001 From: Steven Enamakel <31011319+senamakel@users.noreply.github.com> Date: Sat, 9 May 2026 14:02:49 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20Add=20tests=20for=20bearer=5Faut?= =?UTF-8?q?horization=5Fvalue=20(#1417)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/jwt.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/api/jwt.rs b/src/api/jwt.rs index ce1e70894..30b8f0374 100644 --- a/src/api/jwt.rs +++ b/src/api/jwt.rs @@ -7,3 +7,32 @@ pub use crate::openhuman::credentials::{APP_SESSION_PROVIDER, DEFAULT_AUTH_PROFI pub fn bearer_authorization_value(token: &str) -> String { format!("Bearer {}", token.trim()) } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_bearer_authorization_value() { + // Standard token + assert_eq!(bearer_authorization_value("my_token"), "Bearer my_token"); + + // Token with leading/trailing spaces + assert_eq!( + bearer_authorization_value(" spaced_token "), + "Bearer spaced_token" + ); + + // Empty string + assert_eq!(bearer_authorization_value(""), "Bearer "); + + // Whitespace only string + assert_eq!(bearer_authorization_value(" "), "Bearer "); + + // Token with internal spaces (should not be trimmed) + assert_eq!( + bearer_authorization_value("token with spaces"), + "Bearer token with spaces" + ); + } +}