summaryrefslogtreecommitdiff
path: root/tests/authorization
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-06-27 12:45:13 -0600
committermo khan <mo@mokhan.ca>2025-06-27 12:45:13 -0600
commitf59c24589af439e0e22f43a2e42595cf88973ccf (patch)
tree463c52337d726056571d9dd6c085d6bc84075e22 /tests/authorization
parentafd9729146a7e90bd97bf36f9d2081e29de9da35 (diff)
test: extract factory_bot factory for cedar authorizer
Diffstat (limited to 'tests/authorization')
-rw-r--r--tests/authorization/cedar_authorizer_test.rs17
-rw-r--r--tests/authorization/check_service_test.rs5
2 files changed, 6 insertions, 16 deletions
diff --git a/tests/authorization/cedar_authorizer_test.rs b/tests/authorization/cedar_authorizer_test.rs
index 3073417d..656e0060 100644
--- a/tests/authorization/cedar_authorizer_test.rs
+++ b/tests/authorization/cedar_authorizer_test.rs
@@ -2,16 +2,9 @@
mod tests {
use crate::common::factory_bot::*;
use authzd::Authorizer;
- use authzd::CedarAuthorizer;
use envoy_types::pb::envoy::service::auth::v3::attribute_context::HttpRequest;
use std::collections::HashMap;
- fn authorizer() -> CedarAuthorizer {
- CedarAuthorizer::new_from(
- "/home/mokhax/src/gitlab.com/gitlab-org/software-supply-chain-security/authorization/authzd/etc/authzd",
- )
- }
-
#[test]
fn test_cedar_authorizer_allows_valid_token() {
let request = create_request(|item: &mut HttpRequest| {
@@ -23,7 +16,7 @@ mod tests {
});
});
- assert!(authorizer().authorize(request));
+ assert!(build_cedar_authorizer().authorize(request));
}
#[test]
@@ -37,7 +30,7 @@ mod tests {
});
});
- assert!(!authorizer().authorize(request));
+ assert!(!build_cedar_authorizer().authorize(request));
}
#[test]
@@ -46,7 +39,7 @@ mod tests {
item.headers = HashMap::new();
});
- assert!(!authorizer().authorize(request));
+ assert!(!build_cedar_authorizer().authorize(request));
}
#[test]
@@ -57,7 +50,7 @@ mod tests {
});
});
- assert!(authorizer().authorize(request));
+ assert!(build_cedar_authorizer().authorize(request));
}
#[test]
@@ -68,6 +61,6 @@ mod tests {
item.headers = headers;
});
- assert!(authorizer().authorize(request));
+ assert!(build_cedar_authorizer().authorize(request));
}
}
diff --git a/tests/authorization/check_service_test.rs b/tests/authorization/check_service_test.rs
index c101850c..cddbb6b0 100644
--- a/tests/authorization/check_service_test.rs
+++ b/tests/authorization/check_service_test.rs
@@ -1,7 +1,6 @@
#[cfg(test)]
mod tests {
use crate::common::factory_bot::*;
- use authzd::CedarAuthorizer;
use authzd::CheckService;
use envoy_types::ext_authz::v3::pb::Authorization;
use envoy_types::pb::envoy::service::auth::v3::attribute_context::HttpRequest;
@@ -9,9 +8,7 @@ mod tests {
use std::sync::Arc;
fn authorizer() -> Arc<dyn authzd::Authorizer + Send + Sync> {
- Arc::new(CedarAuthorizer::new_from(
- "/home/mokhax/src/gitlab.com/gitlab-org/software-supply-chain-security/authorization/authzd/etc/authzd",
- ))
+ Arc::new(build_cedar_authorizer())
}
#[tokio::test]