test(phase23): KEEP-VERIFY — remove 44 pass shells + fake INV tests, add shell guard
Phase 23 "可信系统测试重建 (REFACTOR)" re-audit. STATUS claimed "10 E2E
files / ~80+ cases" and "INV-011~020 ✅"; measurement showed the opposite.
D-23-A (Critical): V11InvariantsTest's 14 cases asserted only Constants
strings. INV-016 "Banner target types" actually asserted ARTICLE_STATUS_*;
INV-017 "home 8 entries" declared local arrays then asserted
firstRow.length == 4 (tautology, never called the home service);
INV-018/019/020 used appointment/article/account status constants as
stand-ins for permission and data-scope checks. Rewritten to 12 cases:
4 real service-behavior guards (INV-013 via real CounselingService.getDetail
— Matchmaker sees null userRequestSummary, with an assigned-Counselor
counter-proof so global sanitization cannot fake a pass; INV-016 reads the
production ALLOWED_TARGET_TYPES whitelist and asserts no external/http/url/
web entry; INV-017 calls real getHome and pins all 8 codes + order;
INV-019 asserts content_editor reads null), plus assertBehaviorTestExists
turning "行为验证见 XxxTest" pointers into executable Class.forName contracts.
D-23-B (High): 44 `pass` shells across 6 files in tests/e2e (4 files were
100% shells). Gate forbids skip/pass shells. Rewritten in place as honest
placeholders with the full scenario lists preserved.
D-23-C (High, residual): the pytest E2E suite is not executable at all —
no conftest.py anywhere, ~15 fixtures (api_client/verified_user/
banner_factory/...) do not exist. Only run_v11_tests.py really runs
(16 cases, needs a live stack + E2E_PASSWORD).
D-23-D (High, residual, NOT fixed): CI does not chain E2E as the plan
requires. Needs an infrastructure decision on how CI provisions a live
stack; not implemented rather than written unverified.
D-23-E (Medium): the CI migration job claimed to "验证 migration SQL 语法"
but only checked file non-emptiness, while the real syntax/baseline checks
live in MigrationValidationTest (already run by the backend job). Replaced
with a real sequence check (naming / non-empty / unique versions / no
gaps); verified by extracting the exact inline script and running it.
New gate: scripts/check-no-empty-tests.py (AST scan, blocks pass-only and
unconditionally skipped tests) + a CI test-shell-guard job. Verified both
ways: 0 findings on the real tree, 2 precise findings on injected shells.
Negative validation: 3 injected production defects (external_url in the
banner whitelist, swapped home entry order, isMatchmaker returning the full
record) turned exactly inv016/inv017/inv013 red, 9 others green, zero
unrelated failures; md5sum -c confirmed byte-identical restore.
Full regression: 655 tests / 652 passed / 0 failures / 0 errors / 3 skipped
(baseline 657; -2 because 14 vacuous cases were merged into 12). The 3
skips carry explicit reasons (2x @EnabledIfEnvironmentVariable(CI=true),
1x @Disabled "需要完整数据库连接") — none is a shell.
Phase 23 is PARTIALLY closed: fake coverage is gone, but the UAT gate
requires the end-to-end chain to actually execute, so "失败为零可进入 UAT"
is NOT claimed.
This commit is contained in:
@@ -1,72 +1,39 @@
|
||||
"""
|
||||
V1.1 本地资格 E2E 测试骨架
|
||||
测试项目: 本地资格声明 → 佐证上传 → 审核流程
|
||||
V1.1 本地资格 E2E —— 空壳已移除(Phase 23 KEEP-VERIFY,2026-09-18)
|
||||
|
||||
历史问题
|
||||
--------
|
||||
原文件 11 个测试函数**全部**为 `pass` 空壳(注释均为「TODO: P04/P05/P06 实现后完善」),
|
||||
且依赖 `api_client` / `verified_user` / `local_eligibility_factory` 等
|
||||
**在本仓库中根本不存在**的 pytest fixture(全局无 `conftest.py`)。
|
||||
这些用例从未执行过,却在 `docs/STATUS.md` 中被计为 P23-T05「本地资格 E2E ✅」。
|
||||
|
||||
计划 Phase 23 Gate:「**不允许 skip/pass 空壳**」。
|
||||
|
||||
当前状态
|
||||
--------
|
||||
本文件现**不含任何测试函数**,pytest 将收集到 0 个用例 ——
|
||||
以「没有假覆盖」取代「假装有覆盖」。
|
||||
|
||||
仍待真实实现的场景(需求不因移除空壳而丢失)
|
||||
------------------------------------------
|
||||
1. 用户可声明丹阳工作 / 户籍 / 居住
|
||||
2. 声明本地资格不默认要求上传佐证
|
||||
3. 佐证文件上传需要鉴权
|
||||
4. 审核员可访问本地资格佐证(INV-011)
|
||||
5. 红娘不可访问本地资格佐证(INV-011)
|
||||
6. `/me/status` 返回 localEligibilityStatus
|
||||
7. 本地资格未核验影响匹配资格
|
||||
8. 本地资格审核进入 `review_type=local_eligibility` 队列
|
||||
9. 审核通过更新 local_eligibility 状态
|
||||
10. 需补充佐证时触发用户上传
|
||||
11. 查看佐证文件须记录审计日志
|
||||
|
||||
现状补充(Phase 23 实测)
|
||||
------------------------
|
||||
`LocalEligibilityService` 全部方法均以 `userId` 自限定、**无任何 role 分支**,
|
||||
佐证无独立的服务端读取入口(仅经受权限控制的审核队列 `ReviewController` 访问),
|
||||
故 INV-011 在结构上成立;但缺少显式守卫测试,列为遗留待补。
|
||||
|
||||
真实可执行的 V1.1 E2E 见:`tests/e2e/run_v11_tests.py`
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
class TestLocalEligibilityE2E:
|
||||
"""本地资格 E2E 全流程测试"""
|
||||
|
||||
def test_declare_local_eligibility(self, api_client, verified_user):
|
||||
"""用户可声明丹阳工作/户籍/居住"""
|
||||
# POST /api/v1/local-eligibility/declaration
|
||||
# TODO: P04 实现后完善
|
||||
pass
|
||||
|
||||
def test_declare_does_not_require_evidence_by_default(self, api_client, verified_user):
|
||||
"""声明本地资格不默认要求上传佐证"""
|
||||
# TODO: P04 实现后完善
|
||||
pass
|
||||
|
||||
def test_evidence_upload_requires_permission(self, api_client, verified_user):
|
||||
"""佐证文件上传需要鉴权"""
|
||||
# TODO: P04 实现后完善
|
||||
pass
|
||||
|
||||
def test_reviewer_can_access_evidence(self, operator_client, local_eligibility_factory):
|
||||
"""审核员可访问本地资格佐证"""
|
||||
# TODO: P05 实现后完善
|
||||
pass
|
||||
|
||||
def test_matchmaker_cannot_access_evidence(self, matchmaker_client, local_eligibility_factory):
|
||||
"""红娘不可访问本地资格佐证(INV-011)"""
|
||||
# TODO: P13 + P05 实现后完善
|
||||
pass
|
||||
|
||||
def test_local_eligibility_status_in_me_status(self, api_client, verified_user):
|
||||
"""/me/status 返回 localEligibilityStatus"""
|
||||
# TODO: P04 实现后完善
|
||||
pass
|
||||
|
||||
def test_local_eligibility_affects_match_eligibility(self, api_client, user_factory):
|
||||
"""本地资格未核验影响匹配资格"""
|
||||
# TODO: P06 实现后完善
|
||||
pass
|
||||
|
||||
|
||||
@pytest.mark.e2e
|
||||
class TestLocalEligibilityReview:
|
||||
"""本地资格审核流程测试"""
|
||||
|
||||
def test_review_queue_local_eligibility_type(self, operator_client):
|
||||
"""本地资格审核进入 review_type=local_eligibility 队列"""
|
||||
# TODO: P05 实现后完善
|
||||
pass
|
||||
|
||||
def test_approve_updates_eligibility_status(self, operator_client, local_eligibility_factory):
|
||||
"""审核通过更新 local_eligibility 状态"""
|
||||
# TODO: P05 实现后完善
|
||||
pass
|
||||
|
||||
def test_need_evidence_triggers_upload(self, operator_client, local_eligibility_factory):
|
||||
"""需补充佐证触发用户上传"""
|
||||
# TODO: P05 实现后完善
|
||||
pass
|
||||
|
||||
def test_evidence_access_logged(self, operator_client, local_eligibility_factory):
|
||||
"""查看佐证文件记录审计日志"""
|
||||
# TODO: P05 实现后完善
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user