muse-agent-example/tests/单元/test_证据内容校验.py
zizi d82581daee W08 原文证据、临时租约与归档:原文证据生命周期、临时租约、调用授权与归档恢复。
按 R2 串行阶段整理提交;包内文件为该阶段交付(含后续小增量),状态以工作包清单为准。
2026-09-10 19:25:41 +08:00

29 lines
1012 B
Python
Raw 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.

"""逐例承接旧凭据过滤;字节校验独立于数据库,无原文改写。"""
import pytest
from muse.任务运行.接口 import 原文错误, 校验原文字节
def test_普通token篇幅说明允许原样保留__42d154() -> None:
数据 = "输出不超过 4000 字;token budget 只用于篇幅估算。".encode()
assert 校验原文字节(数据) is None
assert 校验原文字节('{"最大输出token":64}'.encode()) is None
@pytest.mark.parametrize(
"数据",
[
b"api_key=sk-example-secret-value",
b"token: abcdefghijklmnop",
b"Authorization: Bearer abcdefghijklmnop",
b"-----BEGIN PRIVATE KEY-----",
],
ids=["api-key", "token-assignment", "bearer", "private-key"],
)
def test_凭据赋值拒绝且错误不泄露命中值__44009d(数据: bytes) -> None:
with pytest.raises(原文错误) as 捕获:
校验原文字节(数据)
assert 数据.decode() not in str(捕获.value)
assert 捕获.value.上下文 == {}