diff --git a/.werks/16721.md b/.werks/16721.md new file mode 100644 index 00000000000..fa3d949df9b --- /dev/null +++ b/.werks/16721.md @@ -0,0 +1,15 @@ +[//]: # (werk v2) +# site management: Fix url validation + +key | value +---------- | --- +date | 2024-12-24T11:49:39+00:00 +version | 2.3.0p25 +class | fix +edition | cre +component | rest-api +level | 1 +compatible | yes + +This fix allows hostnames without TLD on URLs when creating a site using the site management endpoints + diff --git a/cmk/gui/fields/custom_fields.py b/cmk/gui/fields/custom_fields.py index e3d39fa5729..54faa0b2d92 100644 --- a/cmk/gui/fields/custom_fields.py +++ b/cmk/gui/fields/custom_fields.py @@ -73,6 +73,7 @@ def __init__( validator = validate.URL( schemes=set(self.must_startwith_one), error=self.error_messages["invalid"], + require_tld=False, ) self.validators.insert(0, validator) diff --git a/tests/unit/cmk/gui/openapi/test_site_management.py b/tests/unit/cmk/gui/openapi/test_site_management.py index f9016b3525d..52a912f4ff9 100644 --- a/tests/unit/cmk/gui/openapi/test_site_management.py +++ b/tests/unit/cmk/gui/openapi/test_site_management.py @@ -187,6 +187,16 @@ def test_create_then_get_site_connection(clients: ClientRegistry) -> None: assert resp.json["extensions"] == config +def test_create_site_connection_url_without_tld(clients: ClientRegistry) -> None: + config, site_id = _default_config_with_site_id() + url = "http://myhost:7323/myhost/check_mk/" + + config["configuration_connection"]["url_of_remote_site"] = url + clients.SiteManagement.create(site_config=config) + resp = clients.SiteManagement.get(site_id=site_id) + assert resp.json["extensions"] == config + + def test_update_site_connection(clients: ClientRegistry) -> None: config, site_id = _default_config_with_site_id() clients.SiteManagement.create(site_config=config)