test(e2e): 补 L2 平台门控端到端用例(T04)

T04 把 audit-l2.ts 的平台门控从裸 throw 改成统一 assertWindows 后,
需要端到端证据:非 Windows 被控端上 system.audit.l2 必须明确失败
(result.status=failed + E_UNSUPPORTED_PLATFORM),不得静默走别的
分支、也不得报成误导性错误;Windows 上 status 可用(双平台各验一边)。

第一版按 assert.rejects 写,实测不会红 —— 能力执行失败走
result.status=failed(resolve),只有协议层错误才 reject。
已按 client 真实行为改为断言 failed + error.name(按 name 不按 code)。

e2e 34/34 全绿
This commit is contained in:
jkooe committed 2026-10-26 00:38:01 +08:00
1 parent fbd42e1c3b
commit 6152a68b4a
1 file changed
+20
+20
View File
@@ -1811,6 +1811,26 @@ async function main() {
// ---------- 契约形状(agent 实现 ↔ 协议契约)----------
await test('契约形状:只读能力返回字段与 manifest returns_schema 一致', testContractShapes);
// ---------- v2.1.0 L2 平台门控(T04)----------
// 当前 e2e 跑在 macOS/Linux:system.audit.l2 必须明确报不支持,
// 而不是静默走到别的分支、或报成误导性错误(T04 起门控走统一 assertWindows)。
await test('v2.1.0 L2 平台门控:非 Windows 明确报不支持 / Windows 上 status 可用', async () => {
const c = await connect();
try {
if (process.platform === 'win32') {
const r = await c.invoke('system.audit.l2', { action: 'status' });
assert.equal(r.status, 'ok', 'Windows 上 L2 status 应可用');
} else {
// 能力执行失败走 result.status=failed(协议层才 reject);按 name 断言
const r = await c.invoke('system.audit.l2', { action: 'status' });
assert.equal(r.status, 'failed', '非 Windows 上必须明确失败,不得静默走别的分支');
assert.equal(r.error?.name, 'E_UNSUPPORTED_PLATFORM', `错误名应为平台不支持,实际 ${r.error?.name}`);
}
} finally {
c.close();
}
});
// ---------- v2.0.3 硬化回归(2026-10-13 实测缺陷)----------
await test('v2.0.3 畸形报文不得打死被控端(B-01/B-02 + 崩溃链 + U-01 审计)', () =>
testMalformedFrames(agent),