summaryrefslogtreecommitdiff
path: root/tests/authorization/cedar_authorizer_test.rs
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-06-26 15:46:00 -0600
committermo khan <mo@mokhan.ca>2025-06-26 15:46:00 -0600
commit9f4bf84825c5a725b0ea36d4474d4fa2cec916fd (patch)
tree2978b9eb6d7ed085076a57af4a60c07eac8565b3 /tests/authorization/cedar_authorizer_test.rs
parent187c02e9bf32f152cbca9fd5790f4a6070dbb37d (diff)
test: tidy up the tests
Diffstat (limited to 'tests/authorization/cedar_authorizer_test.rs')
-rw-r--r--tests/authorization/cedar_authorizer_test.rs33
1 files changed, 14 insertions, 19 deletions
diff --git a/tests/authorization/cedar_authorizer_test.rs b/tests/authorization/cedar_authorizer_test.rs
index 6e1591eb..d6742995 100644
--- a/tests/authorization/cedar_authorizer_test.rs
+++ b/tests/authorization/cedar_authorizer_test.rs
@@ -24,42 +24,38 @@ mod tests {
#[test]
fn test_cedar_authorizer_denies_invalid_token() {
let authorizer = CedarAuthorizer::default();
- let mut headers = HashMap::new();
- headers.insert(
- "authorization".to_string(),
- "Bearer invalid-token".to_string(),
- );
let request = create_request(|item: &mut HttpRequest| {
- item.headers = headers;
+ item.headers = build_with(|item: &mut HashMap<String, String>| {
+ item.insert(
+ String::from("authorization"),
+ String::from("Bearer invalid-token"),
+ );
+ });
});
- let result = authorizer.authorize(request);
- assert!(!result);
+ assert!(!authorizer.authorize(request));
}
#[test]
fn test_cedar_authorizer_denies_missing_header() {
let authorizer = CedarAuthorizer::default();
- let headers = HashMap::new();
let request = create_request(|item: &mut HttpRequest| {
- item.headers = headers;
+ item.headers = HashMap::new();
});
- let result = authorizer.authorize(request);
- assert!(!result);
+ assert!(!authorizer.authorize(request));
}
#[test]
fn test_cedar_authorizer_allows_static_assets() {
let authorizer = CedarAuthorizer::default();
- let mut headers = HashMap::new();
- headers.insert(":path".to_string(), "/public/style.css".to_string());
let request = create_request(|item: &mut HttpRequest| {
- item.headers = headers;
+ item.headers = build_with(|item: &mut HashMap<String, String>| {
+ item.insert(String::from(":path"), String::from("/public/style.css"));
+ });
});
- let result = authorizer.authorize(request);
- assert!(result);
+ assert!(authorizer.authorize(request));
}
#[test]
@@ -71,7 +67,6 @@ mod tests {
item.headers = headers;
});
- let result = authorizer.authorize(request);
- assert!(result);
+ assert!(authorizer.authorize(request));
}
}