From 4a59c375b6bfe2613618937f8e03c5d38193fc78 Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 9 Jul 2025 15:54:01 -0600 Subject: test: build a cedar entity with my user record id --- tests/authorization/cedar_authorizer_test.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/authorization/cedar_authorizer_test.rs b/tests/authorization/cedar_authorizer_test.rs index 27801bb1..4a319c09 100644 --- a/tests/authorization/cedar_authorizer_test.rs +++ b/tests/authorization/cedar_authorizer_test.rs @@ -4,6 +4,7 @@ mod tests { use authzd::Authorizer; use envoy_types::pb::envoy::service::auth::v3::attribute_context::HttpRequest; use std::collections::HashMap; + use std::str::FromStr; fn subject() -> authzd::CedarAuthorizer { subject_with(cedar_policy::Entities::empty()) @@ -145,13 +146,20 @@ mod tests { (String::from(":path"), item.path.to_string()), (String::from(":method"), item.method.to_string()), (String::from(":authority"), item.host.to_string()), - ( - String::from("x-jwt-claim-sub"), - "gid://gitlab/User/1".to_string(), - ), + (String::from("x-jwt-claim-sub"), "1675940".to_string()), ]); }); - let entities = cedar_policy::Entities::empty(); + + let user = cedar_policy::Entity::new( + cedar_policy::EntityUid::from_type_name_and_id( + cedar_policy::EntityTypeName::from_str("User").unwrap(), + cedar_policy::EntityId::from_str("1675940").unwrap(), + ), + std::collections::HashMap::new(), + std::collections::HashSet::new(), + ); + + let entities = cedar_policy::Entities::from_entities([user.unwrap()], None).unwrap(); let authorizer = subject_with(entities); assert!(authorizer.authorize(request)); } -- cgit v1.2.3