Files
qing 2817dbbab2 docs: 收尾同步——waf/smtp README、项目画像、测试套件与遗留模块标注
- waf/smtp README: 链路改 ca:8443 → gateway:8445,启动描述改 services.yaml
- profile/evaluation: 拓扑/请求链路/端口表/模块表同步,口径漂移项标记已解决
- tests/blackbox: README 与 config.py 标注测试条目→生产服务映射(保留历史条目名)
- static/dnfs/db/captcha/confs README 顶部加"已废弃"标注
2026-08-10 12:35:45 +00:00

93 lines
2.7 KiB
Python

"""
micro_servers 黑盒测试 — 服务地址与端口配置。
每个服务定义: name, port, description, host。
test_runner.py 通过 --url 参数自动识别目标服务。
"""
SERVICES = {
"gateway": {
"name": "gateway",
"host": "127.0.0.1",
"port": 8443,
"description": "中央认证 ca :8443 (认证+前置转发,原 gateway 认证职责;gateway 纯转发在 8445)",
"test_file": "test_gateway.py",
},
"static": {
"name": "static",
"host": "127.0.0.1",
"port": 9200,
"description": "前端托管 fsys :9200 (文件托管+视频流,static 的 C++ 重写)",
"test_file": "test_static.py",
},
"dnfs": {
"name": "dnfs",
"host": "127.0.0.1",
"port": 8006,
"description": "树状笔记 dnfs2 :8006 (CRUD+内容审核,dnfs 的 C++ 重写)",
"test_file": "test_dnfs.py",
},
"db": {
"name": "db",
"host": "127.0.0.1",
"port": 8005,
"protocol": "pymsg",
"description": "通用数据库 db2 :8005 (CRUD+集中日志,db 的 C++ 重写)",
"test_file": "test_db.py",
},
"ai_review": {
"name": "ai_review",
"host": "127.0.0.1",
"port": 8007,
"description": "AI 内容审核服务 (DeepSeek+ChromaDB RAG)",
"test_file": "test_ai_review.py",
},
"captcha": {
"name": "captcha",
"host": "127.0.0.1",
"port": 8009,
"description": "验证码 captcha2 :8009 (图片生成+校验,captcha 的 C++ 重写)",
"test_file": "test_captcha.py",
},
"smtp": {
"name": "smtp",
"host": "127.0.0.1",
"port": 8008,
"description": "邮件验证服务 (发送+校验)",
"test_file": "test_smtp.py",
},
"waf": {
"name": "waf",
"host": "127.0.0.1",
"port": 443,
"description": "WAF 安全网关 (TLS+Coraza规则引擎)",
"test_file": "test_waf.py",
},
}
# 端口到服务的反向映射
PORT_MAP = {v["port"]: v["name"] for v in SERVICES.values()}
def detect_service(url: str):
"""从 URL 中识别目标服务。返回服务名或 None。"""
from urllib.parse import urlparse
parsed = urlparse(url)
port = parsed.port
if port is None:
# 默认端口猜测
if parsed.scheme == "https":
port = 443
else:
port = 80
return PORT_MAP.get(port)
def get_url(name: str) -> str:
"""获取服务的完整 HTTP URL。"""
svc = SERVICES.get(name)
if not svc:
raise ValueError(f"未知服务: {name}")
return f"http://{svc['host']}:{svc['port']}"