Files
wecom_it_smart_desk/docs/06-测试质量/RBAC-BugFix-测试报告-20260707.md
Simon e4e2de47bb docs: test reports + knowledge iteration design + PRDs
提交 OTP/RBAC/Tier0/Tier1/P0+P2 测试报告、方案A E2E 验证、知识库迭代设计(PRD/mermaid/html 原型)、项目状态看板更新; 根配置 docker-compose.yml/mkdocs.yml。
2026-07-09 11:50:19 +08:00

46 lines
2.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# RBAC BugFix 测试报告 — admin_users 装饰器修复
> **版本**: v1.0 | **日期**: 2026-07-07~08 | **QA**: 严过关(software-qa-engineer | **状态**: ✅ 全部通过
## 测试概览
| 指标 | 值 |
|------|-----|
| 测试文件 | 1 |
| 测试用例 | 5 |
| 通过 | 5 |
| 失败 | 0 |
| 轮次 | 2 |
| 源码 Bug | 0 |
## Bug 背景
`admin_users.py``require_role("admin")` 是装饰器工厂,正确用法为 `@require_role("admin")` 装饰路由函数。代码误写为 `Depends(require_role("admin"))`FastAPI 将内层 func 当作必填 query parameter → 全部 admin_users 接口 422 鉴权失效(P0 安全漏洞)。
**修复**6 处 `Depends(require_role(...))``@require_role(...)` 装饰器。同时修复了 `conftest.py` starlette `_read_file` patch 签名兼容问题(加 `encoding=None` 参数)。
## 测试明细
| 用例 | 类型 | 结果 | 说明 |
|------|------|------|------|
| `test_rbac_role_permissions_model_is_real` | 单元 | ✅ | ROLE_PERMISSIONS 模型正确 |
| `test_check_permission_returns_true_for_granted` | 单元 | ✅ | 授权 check_permission 返回 True |
| `test_check_permission_returns_false_for_denied` | 单元 | ✅ | 拒绝 check_permission 返回 False |
| `test_admin_user_list_allows_admin` | 集成 | ✅ | admin 角色 200(之前 422 已修复) |
| `test_admin_user_list_denies_non_admin` | 集成 | ✅ | 非 admin 角色 403(之前 422 已修复) |
## 轮次详情
### Round 1: 5 ERROR(环境故障)
- 根因:`starlette==1.2.1``_read_file` 新增 `encoding` 参数,但 `pytest-asyncio==1.4.0` monkey-patch 只接受 2 个参数
- 5 个测试在 setup 阶段崩溃,未进入测试体
### Round 2: 5/5 ✅
- 修复 `conftest.py``_patched_read_file(self, env_file, encoding=None)`
- 全部通过,智能路由判定:**NoOne**
## 关联文档
- 增量 PRD`../02-需求分析/增量PRD-知识库迭代与痛点缓解-20260707.md`
- 项目状态看板:`../10-项目管理/05-项目状态看板/01-项目状态看板.md`