""" 内容管理 E2E(内容编辑员权限边界 + 文章生命周期)。 迁移说明:原文件在 import 期就读 `os.environ["E2E_PASSWORD"]`, 栈没配该变量时**整个文件收集失败**(从未执行过)。现改为 conftest fixture。 """ import pytest pytestmark = pytest.mark.e2e def test_content_categories_are_listable(api, user_token): data = api.ok("GET", "/content/categories", token=user_token) assert isinstance(data, list) def test_article_lifecycle_draft_publish_offline(api, operator_token): """文章生命周期:草稿 → 发布 → 下架,状态必须真实流转。""" token = operator_token("e2e_content") created = api.ok( "POST", "/content/operator/articles", token=token, json={"title": "E2E 文章", "summary": "E2E 摘要", "content": "E2E 正文", "sortOrder": 0}, ) article_id = created["id"] assert created["status"] == "draft", f"新建文章状态应为 draft:{created}" published = api.ok("POST", f"/content/operator/articles/{article_id}/publish", token=token) assert published["status"] == "published", f"发布后状态错误:{published}" offline = api.ok("POST", f"/content/operator/articles/{article_id}/offline", token=token) assert offline["status"] == "offline", f"下架后状态错误:{offline}" def test_content_editor_cannot_read_user_matching_data(api, operator_token): """INV-019:内容编辑员不得访问用户婚恋数据。""" token = operator_token("e2e_content") resp = api.call("GET", "/operator/users", token=token) assert resp.status_code == 403, ( f"内容编辑员竟能访问用户库:HTTP {resp.status_code} {resp.text[:200]}" )