diff --git a/test/policy.test.js b/test/policy.test.js index 632410e..c15cdc8 100644 --- a/test/policy.test.js +++ b/test/policy.test.js @@ -137,6 +137,20 @@ test('keeps management tool audit and approval rules', () => { assert.match(evaluateToolPolicy('bingbu', 'automation_create', [approvedTask('bingbu')]), /门下省准奏记录/) }) +test('blocks unclassified tools by default instead of treating them as read-only', () => { + // 没在任何名单里的工具:执行部门、任务已准奏也先拦;丞相同样拦 + assert.match(evaluateToolPolicy('gongbu', 'some_future_tool', [approvedTask('gongbu')]), /尚未登记分类/) + assert.match(evaluateToolPolicy('lead', 'some_future_tool', []), /尚未登记分类/) + // 登记在册的只读工具照常放行 + for (const tool of ['read', 'grep', 'glob']) { + assert.equal(evaluateToolPolicy('zhongshu', tool, []), undefined) + assert.equal(evaluateToolPolicy('gongbu', tool, []), undefined) + } + // 签字类工具:没签字拦在签字关;签了字放行,不被未知工具规则误伤 + assert.match(evaluateToolPolicy('bingbu', 'remote_ssh_delete', [approvedTask('bingbu')]), /人工签字/) + assert.equal(evaluateToolPolicy('bingbu', 'remote_ssh_delete', [approvedTask('bingbu')], { humanSigned: true }), undefined) +}) + test('parses the department model command the panel sends', async () => { const { parseDeptModelCommand, describeDeptRoutes, readStoredRoutes, writeStoredRoutes } = await import('../index.js') assert.deepEqual(parseDeptModelCommand('gongbu deepseek deepseek-chat high'), {