fix(mcp): тест закрепляет выключенные по умолчанию MCP и контроллер
На свежей базе после миграций: mcp_settings.enabled=false, ни одного включённого профиля контроллера, значение столбца по умолчанию false, autoRecovery по умолчанию false; выключенный MCP отказывает токену MCP_DISABLED/503, повторное включение возвращает тот же доступ. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
6b0ebce4ea
commit
b7fcf82858
1 file changed
+11
@@ -647,6 +647,11 @@ try {
|
||||
// downloads disabled in this owned fixture before any telemetry refresh.
|
||||
await pool.query("INSERT INTO geoip_settings(id,enabled) VALUES(1,false) ON CONFLICT(id) DO UPDATE SET enabled=false")
|
||||
await pool.query("INSERT INTO servers(id,name,host,port,use_ssl) VALUES(1,'test-router','127.0.0.1',$1,false),(2,'outside-scope','127.0.0.1',$1,false)", [port])
|
||||
// A fresh installation keeps MCP and the route controller off until an administrator enables them (completion plan, stage 5).
|
||||
assert.equal((await pool.query("SELECT enabled FROM mcp_settings WHERE id=1")).rows[0].enabled, false)
|
||||
assert.equal((await pool.query("SELECT count(*)::int AS n FROM mcp_routing_profiles WHERE enabled")).rows[0].n, 0)
|
||||
assert.equal((await pool.query("SELECT column_default FROM information_schema.columns WHERE table_schema='public' AND table_name='mcp_routing_profiles' AND column_name='enabled'")).rows[0].column_default, "false")
|
||||
assert.equal((await import("@mmapp/contracts/mcp-routing")).routeAiProfileSchema.shape.autoRecovery.parse(undefined), false)
|
||||
await updateMcpSettings({ enabled: true }, actor)
|
||||
const { registerManagementChannel, verifyManagementChannel } = await import("./management.js")
|
||||
let alternateIdentity = "fixture-primary"
|
||||
@@ -666,6 +671,12 @@ try {
|
||||
const input = mcpConnectionCreateSchema.parse({ name: "Integration", mode: "approval", expiresAt: new Date(fixtureAuthExpiresAt).toISOString(), permissions: ["mm:network:write", "mm:servers:read"], scope: { serverIds: [1], operationIds: ["ros.ip_settings.list", "ros.ip_settings.update", "servers.list", "operations.recover", "operations.reconcile"], allowGlobal: false } })
|
||||
const issued = await createMcpConnection(input, actor)
|
||||
const principal = await authenticateMcpToken(issued.token)
|
||||
// Switching MCP off refuses every token at once; switching it back on restores the same credential.
|
||||
await updateMcpSettings({ enabled: false }, actor)
|
||||
await assert.rejects(authenticateMcpToken(issued.token), (error: unknown) => (error as { code?: string }).code === "MCP_DISABLED" && (error as { statusCode?: number }).statusCode === 503)
|
||||
await updateMcpSettings({ enabled: true }, actor)
|
||||
assert.equal((await authenticateMcpToken(issued.token)).connectionId, principal.connectionId)
|
||||
console.log("✓ Fresh install: MCP off, no enabled controller profile, autoRecovery off; disabled MCP refuses tokens")
|
||||
const credentials = await pool.query("SELECT digest FROM mcp_credentials WHERE connection_id=$1", [issued.connection.id])
|
||||
assert.equal(credentials.rows[0].digest, tokenDigest(issued.token)); assert.notEqual(credentials.rows[0].digest, issued.token)
|
||||
const read = await invokeMcpTool(principal, "mm_ip_settings_list", { serverId: 1 }) as { items: unknown[] }
|
||||
|
||||
Reference in new issue
Block a user