From a4672cef861be2b130f24a885e3ebb967a8985c4 Mon Sep 17 00:00:00 2001 From: Aaron Eline Date: Thu, 12 Oct 2023 18:21:16 +0000 Subject: [PATCH] Bringing up to mainline --- cedar-policy/src/frontend/is_authorized.rs | 60 +++++++++++++++++----- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/cedar-policy/src/frontend/is_authorized.rs b/cedar-policy/src/frontend/is_authorized.rs index a48691626..694126396 100644 --- a/cedar-policy/src/frontend/is_authorized.rs +++ b/cedar-policy/src/frontend/is_authorized.rs @@ -905,9 +905,18 @@ mod test { #[test] fn test_authorized_fails_on_policy_collision_with_template() { let call = r#"{ - "principal" : "User::\"alice\"", - "action" : "Photo::\"view\"", - "resource" : "Photo::\"door\"", + "principal" : { + "type" : "User", + "id" : "alice" + }, + "action" : { + "type" : "Action", + "id" : "view" + }, + "resource" : { + "type" : "Photo", + "id" : "door" + }, "context" : {}, "slice" : { "policies" : { "ID0": "permit(principal, action, resource);" }, @@ -926,9 +935,18 @@ mod test { #[test] fn test_authorized_fails_on_duplicate_instantiations_ids() { let call = r#"{ - "principal" : "User::\"alice\"", - "action" : "Photo::\"view\"", - "resource" : "Photo::\"door\"", + "principal" : { + "type" : "User", + "id" : "alice" + }, + "action" : { + "type" : "Action", + "id" : "view" + }, + "resource" : { + "type" : "Photo", + "id" : "door" + }, "context" : {}, "slice" : { "policies" : {}, @@ -968,9 +986,18 @@ mod test { #[test] fn test_authorized_fails_on_template_instantiation_collision_with_template() { let call = r#"{ - "principal" : "User::\"alice\"", - "action" : "Photo::\"view\"", - "resource" : "Photo::\"door\"", + "principal" : { + "type" : "User", + "id" : "alice" + }, + "action" : { + "type" : "Action", + "id" : "view" + }, + "resource" : { + "type" : "Photo", + "id" : "door" + }, "context" : {}, "slice" : { "policies" : {}, @@ -1000,9 +1027,18 @@ mod test { #[test] fn test_authorized_fails_on_template_instantiation_collision_with_policy() { let call = r#"{ - "principal" : "User::\"alice\"", - "action" : "Photo::\"view\"", - "resource" : "Photo::\"door\"", + "principal" : { + "type" : "User", + "id" : "alice" + }, + "action" : { + "type" : "Action", + "id" : "view" + }, + "resource" : { + "type" : "Photo", + "id" : "door" + }, "context" : {}, "slice" : { "policies" : { "ID1": "permit(principal, action, resource);" },