Skip to content

Commit

Permalink
test: fix schema fuzzing test
Browse files Browse the repository at this point in the history
Since adding the top-level properties key to the schema, the fuzz test
will only generate empty tests. Update the test to remove/ignore the
top-level keys along with ensuring fuzzed additionalProperties are
removed from the test.
  • Loading branch information
TheRealFalcon committed Nov 29, 2023
1 parent 16ad372 commit 9ac7d3c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/unittests/config/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2140,6 +2140,8 @@ def clean_schema(
remove_modules(schema, set(modules))
if defs:
remove_defs(schema, set(defs))
del schema["properties"]
del schema["additionalProperties"]
return schema


Expand All @@ -2153,7 +2155,12 @@ class TestSchemaFuzz:

@skipUnlessHypothesisJsonSchema()
@given(from_schema(SCHEMA))
def test_validate_full_schema(self, config):
def test_validate_full_schema(self, orig_config):
config = deepcopy(orig_config)
valid_props = get_schema()["properties"].keys()
for key in orig_config.keys():
if key not in valid_props:
del config[key]
try:
validate_cloudconfig_schema(config, strict=True)
except SchemaValidationError as ex:
Expand Down

0 comments on commit 9ac7d3c

Please sign in to comment.