diff --git a/ctms/schemas/newsletter.py b/ctms/schemas/newsletter.py index 5051b693..1feed151 100644 --- a/ctms/schemas/newsletter.py +++ b/ctms/schemas/newsletter.py @@ -1,7 +1,7 @@ from datetime import datetime, timezone from typing import Literal, Optional -from pydantic import Field, HttpUrl +from pydantic import AnyUrl, Field from .base import ComparableBase @@ -25,7 +25,7 @@ class NewsletterBase(ComparableBase): max_length=5, description="Newsletter language code, usually 2 lowercase letters", ) - source: Optional[HttpUrl] = Field( + source: Optional[AnyUrl] = Field( default=None, description="Source URL of subscription", example="https://www.mozilla.org/en-US/", diff --git a/tests/unit/test_schema_contact.py b/tests/unit/test_schema_contact.py index bffe554f..7f041344 100644 --- a/tests/unit/test_schema_contact.py +++ b/tests/unit/test_schema_contact.py @@ -37,3 +37,9 @@ def test_unsubscribe_not_idempotent_equal(): data["newsletters"][0]["subscribed"] = True modified = ContactInSchema(**data) assert not original.idempotent_equal(modified) + + +def test_source_url_supports_localhost(): + data = SAMPLE_MAXIMAL.dict() + data["newsletters"][0]["source"] = "http://localhost:8888/v1" + ContactInSchema(**data)