Test refactor

This commit is contained in:
2025-08-06 18:35:34 -04:00
parent cd1c0dd7b6
commit c8edff82b6

View File

@@ -131,6 +131,19 @@ pub fn create_token(
mod tests { mod tests {
use super::*; use super::*;
fn test_key() -> String {
String::from("c3092urmc2219ix320i40m293ic29IM09IN0u879Y8B98YB8yb86TN7B55R4yv4RCVU6Bi8YO8U")
}
fn test_resource() -> TokenResource {
TokenResource {
issuer: String::from("icarus_auth_test"),
message: String::from("Authorization"),
audiences: vec![String::from("icarus_test")],
id: uuid::Uuid::nil(),
}
}
#[test] #[test]
fn test_token_scope_check() { fn test_token_scope_check() {
let mut token = Token::default(); let mut token = Token::default();
@@ -148,15 +161,8 @@ mod tests {
#[test] #[test]
fn test_token_creation() { fn test_token_creation() {
let key = String::from( let key = test_key();
"c3092urmc2219ix320i40m293ic29IM09IN0u879Y8B98YB8yb86TN7B55R4yv4RCVU6Bi8YO8U", let test_token_resource = test_resource();
);
let test_token_resource = TokenResource {
issuer: String::from("icarus_auth_test"),
message: String::from("Authorization"),
audiences: vec![String::from("icarus_test")],
id: uuid::Uuid::nil(),
};
let token_expiration_duration = time::Duration::hours(2); let token_expiration_duration = time::Duration::hours(2);
match create_token(&key, &test_token_resource, token_expiration_duration) { match create_token(&key, &test_token_resource, token_expiration_duration) {