diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/authorization/cedar_authorizer_test.rs | 17 | ||||
| -rw-r--r-- | tests/authorization/check_service_test.rs | 5 | ||||
| -rw-r--r-- | tests/common/factory_bot.rs | 6 | ||||
| -rw-r--r-- | tests/integration_tests.rs | 4 |
4 files changed, 13 insertions, 19 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] diff --git a/tests/common/factory_bot.rs b/tests/common/factory_bot.rs index 2389c858..3c3810a7 100644 --- a/tests/common/factory_bot.rs +++ b/tests/common/factory_bot.rs @@ -37,3 +37,9 @@ pub fn build_headers(headers: Vec<(String, String)>) -> HashMap<String, String> pub fn create_token() -> String { return String::from("valid-token"); } + +pub fn build_cedar_authorizer() -> authzd::CedarAuthorizer { + authzd::CedarAuthorizer::new_from( + "/home/mokhax/src/gitlab.com/gitlab-org/software-supply-chain-security/authorization/authzd/etc/authzd", + ) +} diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 8bf433d1..63aaaadc 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -8,9 +8,7 @@ mod authorization; mod common; 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(factory_bot::build_cedar_authorizer()) } #[tokio::test] |
