Close Campaign interface audit gaps
This commit is contained in:
@@ -7,6 +7,7 @@ import pytest
|
||||
from fastapi import HTTPException
|
||||
|
||||
from govoplan_campaign.backend import route_support
|
||||
from govoplan_campaign.backend.routes import attachments as attachment_routes
|
||||
from govoplan_campaign.backend.routes import versions as router
|
||||
from govoplan_campaign.backend.campaign.loader import CampaignSchemaError, validate_against_schema
|
||||
from govoplan_campaign.backend.campaign.mail_profile_boundary import (
|
||||
@@ -94,6 +95,42 @@ def test_loader_rejects_inline_transport_before_optional_mail_summary() -> None:
|
||||
)
|
||||
|
||||
|
||||
def test_attachment_preview_reports_legacy_mail_boundary_as_validation_error() -> None:
|
||||
campaign = SimpleNamespace(id="campaign-1")
|
||||
version = SimpleNamespace(
|
||||
id="version-1",
|
||||
campaign_id=campaign.id,
|
||||
raw_json=_campaign_json({"smtp": {"host": "legacy.example.test"}}),
|
||||
)
|
||||
principal = SimpleNamespace(
|
||||
tenant_id="tenant-1",
|
||||
user=SimpleNamespace(id="user-1"),
|
||||
)
|
||||
|
||||
with (
|
||||
patch.object(attachment_routes, "_get_campaign_for_principal"),
|
||||
patch.object(attachment_routes, "_require_permission"),
|
||||
patch.object(attachment_routes, "_get_campaign_for_tenant", return_value=campaign),
|
||||
patch.object(attachment_routes, "_get_version_for_tenant", return_value=version),
|
||||
patch.object(attachment_routes, "_require_mail_profile_use_if_needed"),
|
||||
patch.object(
|
||||
attachment_routes,
|
||||
"_attachment_preview_for_version",
|
||||
side_effect=CampaignMailProfileBoundaryError("Select an authorized Mail profile."),
|
||||
),
|
||||
pytest.raises(HTTPException) as captured,
|
||||
):
|
||||
attachment_routes.preview_campaign_attachments(
|
||||
campaign.id,
|
||||
version.id,
|
||||
session=object(), # type: ignore[arg-type]
|
||||
principal=principal, # type: ignore[arg-type]
|
||||
)
|
||||
|
||||
assert captured.value.status_code == 422
|
||||
assert captured.value.detail == "Select an authorized Mail profile."
|
||||
|
||||
|
||||
def test_loader_uses_only_non_secret_mail_profile_capabilities() -> None:
|
||||
raw = _campaign_json({"mail_profile_id": "profile-1"})
|
||||
|
||||
|
||||
@@ -62,3 +62,12 @@ def test_aggregate_reports_are_an_integrated_campaign_view() -> None:
|
||||
]
|
||||
assert len(report_surfaces) == 1
|
||||
assert report_surfaces[0].description == "/campaigns/reports"
|
||||
|
||||
|
||||
def test_reusable_template_library_is_not_owned_by_campaign() -> None:
|
||||
manifest = get_manifest()
|
||||
assert manifest.frontend is not None
|
||||
|
||||
assert "/templates" not in {item.path for item in manifest.nav_items}
|
||||
assert "/templates" not in {item.path for item in manifest.frontend.nav_items}
|
||||
assert "/templates" not in {route.path for route in manifest.frontend.routes}
|
||||
|
||||
Reference in New Issue
Block a user