@@ -21,7 +21,10 @@ use cedar_drt::{
2121 extensions:: Extensions ,
2222 Entities , ValidatorSchema ,
2323} ;
24- use cedar_policy:: { entities_errors:: EntitiesError , entities_json_errors:: JsonSerializationError } ;
24+ use cedar_policy:: {
25+ conformance_errors:: EntitySchemaConformanceError , entities_errors:: EntitiesError ,
26+ entities_json_errors:: JsonSerializationError ,
27+ } ;
2528use cedar_policy_generators:: {
2629 hierarchy:: HierarchyGenerator , schema:: Schema , settings:: ABACSettings ,
2730} ;
@@ -107,14 +110,24 @@ fuzz_target!(|input: FuzzTargetInput| {
107110 Extensions :: all_available( ) ,
108111 TCComputation :: EnforceAlreadyComputed ,
109112 ) ;
110- let roundtripped_entities = eparser
111- . from_json_value( json. clone( ) )
112- . expect( "Should be able to parse serialized entity JSON" ) ;
113- // Weaker assertion for schema based parsing because it adds actions from the schema into entities.
114- for e in input. entities {
115- let roundtripped_e = roundtripped_entities
116- . entity( e. uid( ) )
117- . expect( "Schema-based roundtrip dropped entity" ) ;
118- assert_eq!( & e, roundtripped_e) ;
113+ // The entity store generator currently produces entities of enumerated entity types but with invalid EIDs,
114+ // which are rejected by entity validation
115+ match eparser. from_json_value( json. clone( ) ) {
116+ Ok ( roundtripped_entities) => {
117+ // Weaker assertion for schema based parsing because it adds actions from the schema into entities.
118+ for e in input. entities {
119+ let roundtripped_e = roundtripped_entities
120+ . entity( e. uid( ) )
121+ . expect( "Schema-based roundtrip dropped entity" ) ;
122+ assert_eq!( & e, roundtripped_e) ;
123+ }
124+ }
125+ Err ( err) => {
126+ // The error should only be `InvalidEnumEntity`
127+ assert!( matches!(
128+ err,
129+ EntitiesError :: InvalidEntity ( EntitySchemaConformanceError :: InvalidEnumEntity ( _) )
130+ ) ) ;
131+ }
119132 }
120133} ) ;
0 commit comments