44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
import pytest
|
|
from pydantic import SecretStr, ValidationError
|
|
|
|
from ai_platform.infrastructure.config.settings import Settings
|
|
|
|
_TEST_DATABASE_URL = "postgresql+asyncpg://test:test@localhost/ai_platform_test"
|
|
|
|
|
|
def test_aihub_base_url_accepts_local_http():
|
|
settings = Settings(
|
|
database_url=_TEST_DATABASE_URL,
|
|
environment="development",
|
|
aihub_base_url="http://localhost:8080",
|
|
)
|
|
assert settings.aihub_base_url == "http://localhost:8080"
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"base_url",
|
|
[
|
|
"ftp://localhost:8080",
|
|
"http://user:password@localhost:8080",
|
|
"http://localhost:8080?token=secret",
|
|
"http://aihub:8080",
|
|
],
|
|
)
|
|
def test_aihub_base_url_rejects_invalid_or_nonlocal_http(base_url: str):
|
|
with pytest.raises(ValidationError):
|
|
Settings(
|
|
database_url=_TEST_DATABASE_URL,
|
|
environment="development",
|
|
aihub_base_url=base_url,
|
|
)
|
|
|
|
|
|
def test_aihub_base_url_requires_https_outside_development():
|
|
with pytest.raises(ValidationError):
|
|
Settings(
|
|
database_url=_TEST_DATABASE_URL,
|
|
environment="production",
|
|
tenant_provisioning_secret=SecretStr("a-provisioner-secret"),
|
|
aihub_base_url="http://localhost:8080",
|
|
)
|