Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #507: relax source URL validation #547

Merged
merged 1 commit into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ctms/schemas/newsletter.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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/",
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/test_schema_contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)