🧪 Add tests for bearer_authorization_value (#1417)

This commit is contained in:
Steven Enamakel
2026-05-09 14:02:49 -07:00
committed by GitHub
parent 6e2d69792d
commit 359310bad8
+29
View File
@@ -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"
);
}
}