mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-30 23:14:37 +00:00
🧪 Add tests for bearer_authorization_value (#1417)
This commit is contained in:
@@ -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"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user