diff options
| author | mo khan <mo@mokhan.ca> | 2025-07-09 17:50:37 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-07-09 17:50:37 -0600 |
| commit | b3cbfaed168b8c28d1c740f705d92008608b6dcd (patch) | |
| tree | 9521d16877a25c304675d2313ec1f6915eae50c1 /tests/support | |
| parent | c50336c0bd581c7e9c5799188212e81318f829a2 (diff) | |
refactor: extract build_user function
Diffstat (limited to 'tests/support')
| -rw-r--r-- | tests/support/factory_bot.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/support/factory_bot.rs b/tests/support/factory_bot.rs index 14969f87..969080a3 100644 --- a/tests/support/factory_bot.rs +++ b/tests/support/factory_bot.rs @@ -3,6 +3,7 @@ use envoy_types::pb::envoy::service::auth::v3::AttributeContext; use envoy_types::pb::envoy::service::auth::v3::attribute_context::{HttpRequest, Request}; use std::collections::HashMap; use std::net::SocketAddr; +use std::str::FromStr; use tonic::transport::Channel; #[allow(dead_code)] @@ -56,3 +57,15 @@ where { f(build_channel(addr).await) } + +pub fn build_user(id: &str) -> cedar_policy::Entity { + cedar_policy::Entity::new( + cedar_policy::EntityUid::from_type_name_and_id( + cedar_policy::EntityTypeName::from_str("User").unwrap(), + cedar_policy::EntityId::from_str(id).unwrap(), + ), + std::collections::HashMap::new(), + std::collections::HashSet::new(), + ) + .unwrap() +} |
