summaryrefslogtreecommitdiff
path: root/tests/authorization/cedar_authorizer_test.rs
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-09 17:50:37 -0600
committermo khan <mo@mokhan.ca>2025-07-09 17:50:37 -0600
commitb3cbfaed168b8c28d1c740f705d92008608b6dcd (patch)
tree9521d16877a25c304675d2313ec1f6915eae50c1 /tests/authorization/cedar_authorizer_test.rs
parentc50336c0bd581c7e9c5799188212e81318f829a2 (diff)
refactor: extract build_user function
Diffstat (limited to 'tests/authorization/cedar_authorizer_test.rs')
-rw-r--r--tests/authorization/cedar_authorizer_test.rs15
1 files changed, 3 insertions, 12 deletions
diff --git a/tests/authorization/cedar_authorizer_test.rs b/tests/authorization/cedar_authorizer_test.rs
index 88357058..8add9868 100644
--- a/tests/authorization/cedar_authorizer_test.rs
+++ b/tests/authorization/cedar_authorizer_test.rs
@@ -5,7 +5,6 @@ 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 {
common::setup();
@@ -73,7 +72,7 @@ mod tests {
// * delete sparkles: `:delete, gid://sparkle/Sparkle/*`
// * delete single sparkle: `:delete, gid://sparkle/Sparkle/:id`
#[test]
- fn test_authenticated_sparkle_endpoints() {
+ fn test_authenticated_create_sparkle() {
let request = build_request(|item: &mut HttpRequest| {
item.method = "GET".to_string();
item.path = "/sparkles".to_string();
@@ -86,16 +85,8 @@ mod tests {
]);
});
- 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 user = build_user("1675940");
+ let entities = cedar_policy::Entities::from_entities([user], None).unwrap();
let authorizer = subject_with(entities);
assert!(authorizer.authorize(request));
}