From 3f3923fa58e4729c7325a4dcd4a75e885e31710b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Slowenski?= Date: Thu, 2 Nov 2023 09:58:23 +0100 Subject: [PATCH] schemathesis tests: Cleanup after openapi fixes Change-Id: Idead524bc3c4715a93d6a48b682d09cc50c89c82 --- tests/schemathesis_openapi/hooks.py | 97 ++++++-------------------- tests/schemathesis_openapi/settings.py | 14 +--- 2 files changed, 24 insertions(+), 87 deletions(-) diff --git a/tests/schemathesis_openapi/hooks.py b/tests/schemathesis_openapi/hooks.py index abd5d9192c3..b30dbf87c4f 100644 --- a/tests/schemathesis_openapi/hooks.py +++ b/tests/schemathesis_openapi/hooks.py @@ -37,33 +37,26 @@ def hook_before_load_schema( # pylint: disable=too-many-branches # SCHEMA modifications require_properties(raw_schema, "InputRuleObject", ["raw_value", "conditions"], "CMK-TODO") - require_properties(raw_schema, "LicenseSettings", ["settings"], "CMK-14100") - - require_properties(raw_schema, "UpdateContactGroup", ["attributes"], "CMK-14291") - require_properties(raw_schema, "UpdateHostGroup", ["attributes"], "CMK-14291") - require_properties(raw_schema, "UpdateServiceGroup", ["attributes"], "CMK-14291") - require_properties(raw_schema, "CheckboxWithStrValue", ["state"], "CMK-TODO", merge=False) require_properties( raw_schema, "NotificationBulkingCheckbox", ["state"], "CMK-TODO", merge=False ) - update_property(raw_schema, "BulkDeleteHost", "entries", {"minItems": 1}, "CMK-14259") - update_property( raw_schema, - "TimeAllowedRange", - "start", - {"pattern": "^\\d\\d:\\d\\d(:\\d\\d)?$"}, - "CMK-14314", + "HostOrServiceCondition", + "match_on", + {"items": {"type": "string", "minLength": 1}}, + "CMK-15035", ) - update_property( - raw_schema, - "TimeAllowedRange", - "end", - {"pattern": "^\\d\\d:\\d\\d(:\\d\\d)?$"}, - "CMK-14314", + require_properties(raw_schema, "HostOrServiceCondition", ["operator", "match_on"], "CMK-15035") + require_properties( + raw_schema, "TagConditionScalarSchemaBase", ["key", "operator", "value"], "CMK-15035" ) + require_properties( + raw_schema, "TagConditionConditionSchemaBase", ["key", "operator", "value"], "CMK-15035" + ) + require_properties(raw_schema, "LabelCondition", ["operator"], "CMK-15035") # NOTE: CMK-12182 is mostly done, but fixing InputPassword was apparently overlooked update_property( @@ -74,14 +67,6 @@ def hook_before_load_schema( # pylint: disable=too-many-branches "CMK-12182", ) - update_property( - raw_schema, - "InputHostTagGroup", - "ident", - {"pattern": "^[a-zA-Z_]+[-0-9a-zA-Z_]$"}, - "CMK-14263", - ) - update_property( raw_schema, "HostExtensionsEffectiveAttributes", @@ -97,28 +82,6 @@ def hook_before_load_schema( # pylint: disable=too-many-branches "CMK-TODO", ) - update_property( - raw_schema, - "HostExtensions", - "effective_attributes", - {"nullable": True}, - "CMK-14110", - ) - update_property( - raw_schema, - "NetworkScanResult", - "start", - {"nullable": True}, - "CMK-14261", - ) - update_property( - raw_schema, - "NetworkScanResult", - "end", - {"nullable": True}, - "CMK-14261", - ) - update_property( raw_schema, "CreateFolder", @@ -269,10 +232,6 @@ def hook_before_load_schema( # pylint: disable=too-many-branches path, ) responses.update(problem_response("404", "Not found")) - if "CMK-12421" in settings.suppressed_issues: - paths["/domain-types/activation_run/actions/activate-changes/invoke"]["post"][ - "responses" - ].update(problem_response("204", "No Content")) # ignore some endpoints (via deprecating them) to avoid failures during parametrization for path, methods in { @@ -332,7 +291,6 @@ def hook_after_call( # pylint: disable=too-many-branches valid_body=False, body={}, set_body={"links": []}, - ticket_id="CMK-14101", ) else: fix_response( @@ -348,15 +306,6 @@ def hook_after_call( # pylint: disable=too-many-branches }, ticket_id="INVALID-JSON", ) - fix_response( - case, - response, - method="GET", - path="/domain-types/audit_log/collections/all", - status_code=200, - set_body={"links": []}, - ticket_id="CMK-14403", - ) # generic: empty response Content-Type fix_response( @@ -414,19 +363,6 @@ def hook_after_call( # pylint: disable=too-many-branches ) # invalid status: 500 instead of 400 - fix_response( - case, - response, - method="POST|PUT", - path="/objects/bi_aggregation/{aggregation_id}", - status_code=500, - traceback=".*\nKeyError:.*", - valid_body=True, - set_status_code=400, - update_headers={"Content-Type": "{problem}"}, - set_body={"title": "Bad Request", "status": 400, "detail": "Bad Request"}, - ticket_id="CMK-14416", - ) fix_response( case, response, @@ -485,5 +421,16 @@ def hook_after_call( # pylint: disable=too-many-branches ) # invalid status: 500 instead of 404 + fix_response( + case, + response, + method="DELETE", + path="/objects/bi_pack/{pack_id}", + status_code=500, + body={"detail": "The requested pack_id does not exist"}, + set_status_code=400, + update_body={"title": "Bad Request", "status": 404}, + ticket_id="CMK-14991", + ) # invalid status: 500 instead of 409 diff --git a/tests/schemathesis_openapi/settings.py b/tests/schemathesis_openapi/settings.py index af527c11c2d..fc398516c47 100644 --- a/tests/schemathesis_openapi/settings.py +++ b/tests/schemathesis_openapi/settings.py @@ -24,25 +24,15 @@ suppressed_issues.update( { "CMK-12182", # mostly done, but fixing InputPassword was apparently overlooked - # "CMK-12421", # NOTE: problem with redirects in Schemathesis, need to investigate! "CMK-13216", - "CMK-14100", - "CMK-14101", - "CMK-14110", - "CMK-14259", - "CMK-14261", - "CMK-14263", "CMK-14273", - "CMK-14291", - "CMK-14314", # follow-up of CMK-12235 - "CMK-14366", # follow-up of CMK-12261 # "CMK-14375", # "CMK-14375.1", # "CMK-14375.2", "CMK-14381", - "CMK-14403", - "CMK-14416", "CMK-TODO", + "CMK-14991", + "CMK-15035", } ) for issue in set(getenv("TEST_OPENAPI_ALLOW", "").upper().split(",")):