summaryrefslogtreecommitdiff
path: root/src/authorization
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-06-20 10:37:56 -0600
committermo khan <mo@mokhan.ca>2025-06-20 10:37:56 -0600
commite3fec7bf38d6070c9fb547ab08670e556ec974ab (patch)
treea223007e458743442f177a04b22a88e95275494a /src/authorization
parent2e26e151c273cbcc063eba2d08d28dc2ba5a33ec (diff)
refactor: experiment with rust generics
Diffstat (limited to 'src/authorization')
-rw-r--r--src/authorization/cedar_authorizer.rs38
1 files changed, 34 insertions, 4 deletions
diff --git a/src/authorization/cedar_authorizer.rs b/src/authorization/cedar_authorizer.rs
index 2efbda28..ff4c3c5b 100644
--- a/src/authorization/cedar_authorizer.rs
+++ b/src/authorization/cedar_authorizer.rs
@@ -41,11 +41,22 @@ mod tests {
use envoy_types::pb::envoy::service::auth::v3::{AttributeContext, attribute_context};
use std::collections::HashMap;
+ fn build<T: Default>() -> T {
+ T::default()
+ }
+
+ fn build_with<T: Default>(initializer: impl std::ops::FnOnce(T) -> T) -> T {
+ let item = build::<T>();
+ initializer(item)
+ }
+
fn create_test_request_with_headers(headers: HashMap<String, String>) -> CheckRequest {
- let http_request = attribute_context::HttpRequest {
- headers,
- ..Default::default()
- };
+ let http_request = build_with::<attribute_context::HttpRequest>(
+ |mut item: attribute_context::HttpRequest| {
+ item.headers = headers;
+ item
+ },
+ );
let request_context = attribute_context::Request {
http: Some(http_request),
@@ -100,4 +111,23 @@ mod tests {
let result = authorizer.authorize(request);
assert!(!result);
}
+
+ // test css passthrough
+ // test javascript passthrough
+ // test ico passthrough
+ // test png,jpg,bmp passthrough
+ // test html passthrough
+ // #[test]
+ // fn authorize_test_css_passthrough() {
+ // let authorizer = CedarAuthorizer::new();
+
+ // let request = CheckRequest {
+ // attributes: Some(AttributeContext {
+ // ..Default::default()
+ // }),
+ // };
+ // let result = authorizer.authorize(request);
+
+ // assert!(result)
+ // }
}