diff options
Diffstat (limited to 'tests/authorization')
| -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)); } |
