From 81c6991616ef0f9cd4134d398c5b7cee2c6665de Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 16 Jul 2025 10:45:04 -0600 Subject: test: start to flush out test for spice authorizer --- src/authorization/spice/authorizer.rs | 6 ++++++ tests/authorization/mod.rs | 1 + tests/authorization/spice/authorizer_test.rs | 18 ++++++++++++++++++ tests/authorization/spice/mod.rs | 1 + 4 files changed, 26 insertions(+) create mode 100644 tests/authorization/spice/authorizer_test.rs create mode 100644 tests/authorization/spice/mod.rs diff --git a/src/authorization/spice/authorizer.rs b/src/authorization/spice/authorizer.rs index da2805b9..d906752f 100644 --- a/src/authorization/spice/authorizer.rs +++ b/src/authorization/spice/authorizer.rs @@ -1,6 +1,12 @@ #[derive(Debug)] pub struct Authorizer {} +impl Authorizer { + pub fn new() -> Authorizer { + Authorizer {} + } +} + impl crate::authorization::authorizer::Authorizer for Authorizer { fn authorize(&self, _request: envoy_types::ext_authz::v3::pb::CheckRequest) -> bool { false diff --git a/tests/authorization/mod.rs b/tests/authorization/mod.rs index 675247d4..7cad6c25 100644 --- a/tests/authorization/mod.rs +++ b/tests/authorization/mod.rs @@ -1,3 +1,4 @@ mod cedar_authorizer_test; mod check_service_test; mod server_test; +mod spice; diff --git a/tests/authorization/spice/authorizer_test.rs b/tests/authorization/spice/authorizer_test.rs new file mode 100644 index 00000000..b295b64b --- /dev/null +++ b/tests/authorization/spice/authorizer_test.rs @@ -0,0 +1,18 @@ +#[cfg(test)] +mod tests { + use crate::support::factory_bot::*; + use authzd::Authorizer; + + #[test] + fn test_example() { + let authorizer = authzd::authorization::spice::Authorizer::new(); + let request = build_request( + |item: &mut envoy_types::pb::envoy::service::auth::v3::attribute_context::HttpRequest| { + item.method = "GET".to_string(); + item.path = "/".to_string(); + }, + ); + + assert!(authorizer.authorize(request)) + } +} diff --git a/tests/authorization/spice/mod.rs b/tests/authorization/spice/mod.rs new file mode 100644 index 00000000..6aa0bfab --- /dev/null +++ b/tests/authorization/spice/mod.rs @@ -0,0 +1 @@ +mod authorizer_test; -- cgit v1.2.3