From b28ef2fa68c1d4da56b973ae2f22a50a9388736e Mon Sep 17 00:00:00 2001 From: Solomon Jacobs Date: Fri, 31 Jan 2025 14:00:58 +0100 Subject: [PATCH] http migrate: add examples * checks `expect_response` inside `migratable` * adds forgotten examples to tests CMK-21248 Change-Id: If8921545b9d274cb2eb644f4aaeee512d28cffa6 --- cmk/update_config/http/main.py | 4 ++++ tests/unit/cmk/update_config/http/test_main.py | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/cmk/update_config/http/main.py b/cmk/update_config/http/main.py index f8137535715..b4127a56b8f 100755 --- a/cmk/update_config/http/main.py +++ b/cmk/update_config/http/main.py @@ -138,6 +138,10 @@ def _migratable(rule_value: Mapping[str, object]) -> bool: "HEAD", ): return False + try: + _migrate_expect_response(value.mode[1].expect_response or []) + except ValueError: + return False type_ = _classify(value.host.address[1]) if type_ is HostType.EMBEDDABLE: # This might have some issues, since customers can put a port, uri, and really mess with diff --git a/tests/unit/cmk/update_config/http/test_main.py b/tests/unit/cmk/update_config/http/test_main.py index 36fc077dbda..2a57069a030 100644 --- a/tests/unit/cmk/update_config/http/test_main.py +++ b/tests/unit/cmk/update_config/http/test_main.py @@ -572,6 +572,9 @@ EXAMPLE_57, EXAMPLE_58, EXAMPLE_64, + EXAMPLE_65, + EXAMPLE_66, + EXAMPLE_67, ], ) def test_migrateable_rules(rule_value: Mapping[str, object]) -> None: @@ -637,6 +640,14 @@ def test_migrate_url(rule_value: Mapping[str, object], expected: str) -> None: page_size=None, ), ), + ( + EXAMPLE_67, + Document( + document_body=DocumentBodyOption.IGNORE, + max_age=111.0, + page_size=None, + ), + ), ], ) def test_migrate_document(rule_value: Mapping[str, object], expected: object) -> None: @@ -804,6 +815,7 @@ def test_migrate_ssl(rule_value: Mapping[str, object], expected: str) -> None: EXAMPLE_34, EXAMPLE_35, EXAMPLE_43, + EXAMPLE_44, EXAMPLE_49, EXAMPLE_51, EXAMPLE_59,