File size: 800 Bytes
242c945 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | from __future__ import annotations
import pytest
from pydantic import ValidationError
from app.schemas import TenantIn, TenantUpdate
def test_shop_normalized_to_bare_myshopify_domain():
t = TenantIn(slug="xx", shopify_shop="HTTPS://Acme-Store.myshopify.com/")
assert t.shopify_shop == "acme-store.myshopify.com"
def test_non_myshopify_shop_rejected():
# the OAuth secret must never be sendable to a non-Shopify host
with pytest.raises(ValidationError):
TenantIn(slug="xx", shopify_shop="evil.example.com")
with pytest.raises(ValidationError):
TenantUpdate(shopify_shop="attacker.myshopify.com.evil.com")
def test_empty_shop_is_none():
assert TenantIn(slug="xx", shopify_shop="").shopify_shop is None
assert TenantIn(slug="xx").shopify_shop is None
|