diff --git a/cedar-policy-cli/tests/integration_tests/example_use_cases_doc.rs b/cedar-policy-cli/tests/integration_tests/example_use_cases_doc.rs index 074e2141b..94441ceb9 100644 --- a/cedar-policy-cli/tests/integration_tests/example_use_cases_doc.rs +++ b/cedar-policy-cli/tests/integration_tests/example_use_cases_doc.rs @@ -68,7 +68,9 @@ fn scenario_4a() { // note: 4b currently omitted because it requires date/timestamp functionality /// currently failing, as the validator does not support action attributes -#[should_panic] +#[should_panic( + expected = "error occurred while evaluating policy `policy0`: `Action::\\\"view\\\"` does not have the attribute `readOnly`" +)] #[test] fn scenario_4c() { perform_integration_test_from_json(folder().join("4c.json")); diff --git a/cedar-policy-core/src/ast/extension.rs b/cedar-policy-core/src/ast/extension.rs index e09476e8a..2eaba71d2 100644 --- a/cedar-policy-core/src/ast/extension.rs +++ b/cedar-policy-core/src/ast/extension.rs @@ -408,7 +408,7 @@ impl Eq for ExtensionValueWithArgs {} impl PartialOrd for ExtensionValueWithArgs { fn partial_cmp(&self, other: &Self) -> Option { - self.value.partial_cmp(&other.value) + Some(self.cmp(other)) } } diff --git a/cedar-policy-core/src/ast/value.rs b/cedar-policy-core/src/ast/value.rs index 37f0636b4..ab27aea84 100644 --- a/cedar-policy-core/src/ast/value.rs +++ b/cedar-policy-core/src/ast/value.rs @@ -296,9 +296,7 @@ impl Eq for Set {} // HashSet doesn't implement PartialOrd impl PartialOrd for Set { fn partial_cmp(&self, other: &Set) -> Option { - self.authoritative - .as_ref() - .partial_cmp(other.authoritative.as_ref()) + Some(self.cmp(other)) } } diff --git a/cedar-policy-core/src/parser/text_to_cst.rs b/cedar-policy-core/src/parser/text_to_cst.rs index c888eb94a..0050f7d7e 100644 --- a/cedar-policy-core/src/parser/text_to_cst.rs +++ b/cedar-policy-core/src/parser/text_to_cst.rs @@ -335,8 +335,7 @@ mod tests { assert!(policy.is_ok()); } - #[test] - #[should_panic] // we no longer support structs + #[test] // we no longer support named structs fn member7() { let policy = parse_policy( r#" @@ -346,7 +345,15 @@ mod tests { }; "#, ); - assert!(policy.is_ok()); + let errs = match policy.err() { + Some(pes) => pes, + _ => panic!("Expected parsing policy to error"), + }; + assert!(errs.len() == 2); + assert!(format!("{:?}", errs[0]) + .contains("ToCST(ToCSTError { err: UnrecognizedToken { token: (98, \"{\", 99)")); + assert!(format!("{:?}", errs[1]) + .contains("ToCST(ToCSTError { err: UnrecognizedToken { token: (141, \"}\", 142)")); } #[test] diff --git a/cedar-policy-validator/src/schema.rs b/cedar-policy-validator/src/schema.rs index 11523b91e..99bf4c77c 100644 --- a/cedar-policy-validator/src/schema.rs +++ b/cedar-policy-validator/src/schema.rs @@ -2629,7 +2629,6 @@ mod test { } #[test] - #[should_panic] fn cross_fragment_duplicate_type() { let fragment1: ValidatorSchemaFragment = serde_json::from_value::(json!({ "A": { @@ -2655,12 +2654,13 @@ mod test { .unwrap() .try_into() .unwrap(); - let schema = ValidatorSchema::from_schema_fragments([fragment1, fragment2]).unwrap(); - assert_eq!( - schema.entity_types.iter().next().unwrap().1.attributes, - Attributes::with_required_attributes([("a".into(), Type::primitive_long())]) - ); + let schema = ValidatorSchema::from_schema_fragments([fragment1, fragment2]); + + match schema { + Err(SchemaError::DuplicateCommonType(s)) if s.contains("A::MyLong") => (), + _ => panic!("should have errored because schema fragments have duplicate types"), + }; } #[test] diff --git a/cedar-policy/src/api.rs b/cedar-policy/src/api.rs index b617c1d32..583f7744c 100644 --- a/cedar-policy/src/api.rs +++ b/cedar-policy/src/api.rs @@ -496,6 +496,10 @@ impl Default for Authorizer { impl Authorizer { /// Create a new `Authorizer` + /// + /// The authorizer uses the `stacker` crate to manage stack size and tries to use a sane default. + /// If the default is not right for you, you can try wrapping the authorizer or individual calls + /// to `is_authorized` in `stacker::grow`. /// ``` /// # use cedar_policy::{Authorizer, Context, Entities, EntityId, EntityTypeName, /// # EntityUid, Request,PolicySet}; diff --git a/cedar-policy/tests/example_use_cases_doc.rs b/cedar-policy/tests/example_use_cases_doc.rs index fa909d8e3..c323125c9 100644 --- a/cedar-policy/tests/example_use_cases_doc.rs +++ b/cedar-policy/tests/example_use_cases_doc.rs @@ -68,7 +68,9 @@ fn scenario_4a() { // note: 4b currently omitted because it requires date/timestamp functionality /// currently failing, as the validator does not support action attributes -#[should_panic] +#[should_panic( + expected = "error occurred while evaluating policy `policy0`: entity `Action::\\\"view\\\"` does not exist" +)] #[test] fn scenario_4c() { perform_integration_test_from_json(folder().join("4c.json"));