diff --git a/components/ecoindex/models/compute.py b/components/ecoindex/models/compute.py index 1351e42..6c5c987 100644 --- a/components/ecoindex/models/compute.py +++ b/components/ecoindex/models/compute.py @@ -103,6 +103,7 @@ class WebPage(BaseModel): @classmethod def url_as_http_url(cls, v: str) -> str: url_object = AnyHttpUrl(url=v) + assert url_object.scheme in {"http", "https"}, "scheme must be http or https" return url_object.unicode_string() diff --git a/test/components/ecoindex/compute/test_models.py b/test/components/ecoindex/compute/test_models.py index b5bfa43..9705f3e 100644 --- a/test/components/ecoindex/compute/test_models.py +++ b/test/components/ecoindex/compute/test_models.py @@ -28,6 +28,9 @@ def test_model_webpage_invalid_url() -> None: "[type=url_parsing, input_value='toto', input_type=str]\n" ) in str(error.value) + with raises(ValidationError): + WebPage(url="about:config") + def test_model_webpage_wrong_size() -> None: with raises(ValidationError) as error: