diff options
| author | mo khan <mo@mokhan.ca> | 2025-07-09 15:54:01 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-07-09 15:54:01 -0600 |
| commit | 4a59c375b6bfe2613618937f8e03c5d38193fc78 (patch) | |
| tree | 133a18648d750c5b85a1945f8926d424f6463753 /tests | |
| parent | e6a1c6661f3e900d47395695ccb8d8c9942be68f (diff) | |
test: build a cedar entity with my user record id
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/authorization/cedar_authorizer_test.rs | 18 |
1 files changed, 13 insertions, 5 deletions
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)); } |
