Skip to content

Commit 34ca677

Browse files
committed
added key validation
1 parent 8a2e8c8 commit 34ca677

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packages/google-cloud-firestore/tests/system/test_pipeline_acceptance.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,28 @@ def yaml_loader(field="tests", dir_name="pipeline_e2e", attach_file_name=True):
7272
combined_yaml.update(extracted)
7373
elif isinstance(combined_yaml, list) and extracted:
7474
combined_yaml.extend(extracted)
75+
76+
# Validate test keys
77+
allowed_keys = {
78+
"description",
79+
"pipeline",
80+
"assert_proto",
81+
"assert_error",
82+
"assert_results",
83+
"assert_count",
84+
"assert_results_approximate",
85+
"assert_end_state",
86+
"file_name",
87+
}
88+
if field == "tests" and isinstance(combined_yaml, list):
89+
for item in combined_yaml:
90+
if isinstance(item, dict):
91+
for key in item:
92+
if key not in allowed_keys:
93+
raise ValueError(
94+
f"Unrecognized key '{key}' in test '{item.get('description', 'Unknown')}' in file '{item.get('file_name', 'Unknown')}'"
95+
)
96+
7597
return combined_yaml
7698

7799

0 commit comments

Comments
 (0)