MCPcopy Create free account
hub / github.com/cedar-policy/cedar-java / assert_validates_with_errors

Function assert_validates_with_errors

CedarJavaFFI/src/helpers.rs:204–213  ·  view source on GitHub ↗
(json: serde_json::Value)

Source from the content-addressed store, hash-verified

202
203 #[track_caller]
204 fn assert_validates_with_errors(json: serde_json::Value) -> Vec<ValidationError> {
205 let ans = validate_with_level(serde_json::from_value(json).unwrap());
206 let ans_val = serde_json::to_value(ans).unwrap();
207 assert_matches!(ans_val.get("validationErrors"), Some(_)); // should be present, with this camelCased name
208 assert_matches!(ans_val.get("validationWarnings"), Some(_)); // should be present, with this camelCased name
209 let result: Result<ValidationAnswer, _> = serde_json::from_value(ans_val);
210 assert_matches!(result, Ok(ValidationAnswer::Success { validation_errors, validation_warnings: _, other_warnings: _ }) => {
211 validation_errors
212 })
213 }
214
215 #[test]
216 fn test_correct_policy_validates_without_errors() {

Calls 1

validate_with_levelFunction · 0.85