From 743c484d5ed62c01485ff275aca357ea3e7b45a8 Mon Sep 17 00:00:00 2001 From: mo khan Date: Fri, 4 Jul 2025 13:08:37 -0600 Subject: chore: add additional request logging --- tests/authorization/cedar_authorizer_test.rs | 30 ++++++++++++++++++++++------ tests/authorization/check_service_test.rs | 14 +++++++++++-- 2 files changed, 36 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/authorization/cedar_authorizer_test.rs b/tests/authorization/cedar_authorizer_test.rs index 76bf06df..79f83c00 100644 --- a/tests/authorization/cedar_authorizer_test.rs +++ b/tests/authorization/cedar_authorizer_test.rs @@ -45,9 +45,18 @@ mod tests { #[test] fn test_cedar_authorizer_allows_static_assets() { let request = build_request(|item: &mut HttpRequest| { - item.headers = build_with(|item: &mut HashMap| { - item.insert(String::from(":path"), String::from("/public/style.css")); - }); + let method = String::from("GET"); + let host = String::from("sparkle.staging.runway.gitlab.net"); + let path = "/public/style.css"; + + item.method = method.clone(); + item.path = path.to_string(); + item.host = host.to_string(); + item.headers = build_headers(vec![ + (String::from(":path"), path.to_string()), + (String::from(":method"), method), + (String::from(":authority"), host), + ]); }); assert!(build_cedar_authorizer().authorize(request)); @@ -55,10 +64,19 @@ mod tests { #[test] fn test_cedar_authorizer_allows_js_assets() { - let mut headers = HashMap::new(); - headers.insert(":path".to_string(), "/app.js".to_string()); let request = build_request(|item: &mut HttpRequest| { - item.headers = headers; + let method = String::from("GET"); + let host = String::from("sparkle.staging.runway.gitlab.net"); + let path = "/app.js"; + + item.method = method.clone(); + item.path = path.to_string(); + item.host = host.to_string(); + item.headers = build_headers(vec![ + (String::from(":path"), path.to_string()), + (String::from(":method"), method), + (String::from(":authority"), host), + ]); }); assert!(build_cedar_authorizer().authorize(request)); diff --git a/tests/authorization/check_service_test.rs b/tests/authorization/check_service_test.rs index 0a2997cf..a4b8f2ee 100644 --- a/tests/authorization/check_service_test.rs +++ b/tests/authorization/check_service_test.rs @@ -58,8 +58,18 @@ mod tests { ]; for path in static_paths { - let request = tonic::Request::new(build_request(|http| { - http.headers = build_headers(vec![(":path".to_string(), path.to_string())]); + let request = tonic::Request::new(build_request(|item: &mut HttpRequest| { + let method = String::from("GET"); + let host = String::from("sparkle.staging.runway.gitlab.net"); + + item.method = method.clone(); + item.path = path.to_string(); + item.host = host.to_string(); + item.headers = build_headers(vec![ + (String::from(":path"), path.to_string()), + (String::from(":method"), method), + (String::from(":authority"), host), + ]); })); let response = subject().check(request).await; -- cgit v1.2.3