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

Function get_cedar_schema_internal_valid

CedarJavaFFI/src/interface.rs:1810–1846  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1808
1809 #[test]
1810 fn get_cedar_schema_internal_valid() {
1811 let mut env = JVM.attach_current_thread().unwrap();
1812 let json_input = r#"{
1813 "schema": {
1814 "entityTypes": {
1815 "User": {
1816 "memberOfTypes": ["Group"]
1817 },
1818 "Group": {},
1819 "File": {}
1820 },
1821 "actions": {
1822 "read": {
1823 "appliesTo": {
1824 "principalTypes": ["User"],
1825 "resourceTypes": ["File"]
1826 }
1827 }
1828 }
1829 }
1830 }"#;
1831
1832 let jstr = env.new_string(json_input).unwrap();
1833 let result = get_cedar_schema_internal(&mut env, jstr);
1834 assert!(result.is_ok(), "Expected Cedar conversion to succeed");
1835
1836 let cedar_jval = result.unwrap();
1837 let cedar_jstr = JString::cast(&mut env, cedar_jval.l().unwrap()).unwrap();
1838 let cedar_str = String::from(env.get_string(&cedar_jstr).unwrap());
1839
1840 let expected_cedar = "namespace schema {\n entity File;\n\n entity Group;\n\n entity User in [Group];\n\n action \"read\" appliesTo {\n principal: [User],\n resource: [File],\n context: {}\n };\n}";
1841 assert_eq!(
1842 cedar_str.trim(),
1843 expected_cedar,
1844 "Cedar schema output did not match expected"
1845 );
1846 }
1847
1848 #[test]
1849 fn get_cedar_schema_internal_invalid() {

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected