fix(ipsec): удаление сервера убирает свои profile и proposal
mm_ipsec_server_remove_plan и REST-удаление оставляли profile и proposal ipsec-vpn (стенд IPsec 2026-11-21). Теперь они удаляются после policy и peer, если это строки продукта (метка или ipsec-vpn без комментария), не встроенные, и на них ссылаются только удаляемые строки; общие с чужой конфигурацией остаются без отказа. Версия операции 3. Тесты: модель (освобождение, общий профиль, встроенные, профиль init), приёмка со сценарием освобождения и паритетом MCP/REST. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
8d4169bb50
commit
d02a019b3b
7 files changed
+65
-18
No files matched your search
@@ -100,6 +100,16 @@ export async function acceptIpsecServerDelete(actor: AuthUser) {
|
||||
const successfulCommands = commands.slice(before); reset(scenario.crl); const restBefore: number = commands.length, historyBefore = historyCalls
|
||||
const response = await rest.inject({ method: "DELETE", url: `/api/ipsec/server/${serverId}?removeCertificates=${scenario.remove}` }); assert.equal(response.statusCode, 200, response.body); assert.deepEqual(response.json(), { ok: true }); assert.deepEqual(commands.slice(restBefore), successfulCommands); assert.deepEqual(catalogs, desired(original, scenario.remove)); assert.equal(historyCalls, historyBefore + 1)
|
||||
}
|
||||
// Without foreign users the product proposal/profile are released: MCP and REST remove them after policy/peer, identically.
|
||||
const released = () => { reset(); for (const [path, id] of [["/ip/ipsec/peer", "*p2"], ["/ip/ipsec/policy", "*s2"], ["/ip/ipsec/identity", "*i2"]]) catalogs[path] = catalogs[path].filter(row => row[".id"] !== id) }
|
||||
{
|
||||
released(); const before = commands.length, result = await apply(false)
|
||||
assert.equal(result.state, "applied", JSON.stringify(result)); assert.equal(catalogs["/ip/ipsec/profile"].length, 0); assert.equal(catalogs["/ip/ipsec/proposal"].length, 0)
|
||||
const mcpCommands = commands.slice(before); assert.deepEqual(mcpCommands.slice(7), ["/ip/ipsec/proposal/*r1", "/ip/ipsec/profile/*f1"])
|
||||
released(); const restBefore = commands.length
|
||||
const response = await rest.inject({ method: "DELETE", url: `/api/ipsec/server/${serverId}?removeCertificates=false` }); assert.equal(response.statusCode, 200, response.body)
|
||||
assert.deepEqual(commands.slice(restBefore), mcpCommands); assert.equal(catalogs["/ip/ipsec/profile"].length, 0); assert.equal(catalogs["/ip/ipsec/proposal"].length, 0)
|
||||
}
|
||||
reset(); ticking = true
|
||||
catalogs["/ip/ipsec/policy"].push({ ".id": "*runtime", dynamic: "true", peer: "vanished-runtime-peer", group: "vanished-runtime-group", comment: marker })
|
||||
const withCountdown = await apply(false)
|
||||
@@ -132,7 +142,7 @@ export async function acceptIpsecServerDelete(actor: AuthUser) {
|
||||
for (const table of ["mcp_audit", "mcp_plans", "mcp_operation_steps"]) {
|
||||
const rows = table === "mcp_operation_steps" ? await originalQuery("SELECT s.* FROM mcp_operation_steps s JOIN mcp_operations o ON o.id=s.operation_id WHERE o.connection_id=$1", [connectionId]) : await originalQuery(`SELECT * FROM ${table} WHERE connection_id=$1`, [connectionId]); assert.ok(!JSON.stringify(rows.rows).includes("NEVER_"), `${table} leaked private fixture data`)
|
||||
}
|
||||
console.log("✓ IPsec server removal SQL/loopback: full managed manifest, REST parity/defaults/noop history, raw foreign/profile/proposal preservation, closed CRL CA cascade, foreign/protected dependencies and ambiguity denied, per-step drift/fault stop without replay; native cascade/forwarding gate remains open")
|
||||
console.log("✓ IPsec server removal SQL/loopback: full managed manifest, REST parity/defaults/noop history, raw foreign/shared profile/proposal preservation, released profile/proposal removal with REST parity, closed CRL CA cascade, foreign/protected dependencies and ambiguity denied, per-step drift/fault stop without replay; native cascade/forwarding gate remains open")
|
||||
} finally {
|
||||
closeFixtureAgent()
|
||||
pool.query = originalQuery as typeof pool.query
|
||||
|
||||
@@ -18,7 +18,7 @@ const operation = "network.ipsec.server.delete", hash = z.string().regex(/^[a-f0
|
||||
export const ipsecServerDeleteActionSchema = z.object({ serverId: z.number().int().positive().safe(), removeCertificates: z.boolean().default(true) }).strict()
|
||||
const objectRef = z.object({ kind: z.string().min(1).max(100), id: z.string().min(1).max(200) }).strict()
|
||||
const nativeId = z.string().regex(/^\*[a-z0-9]+$/i).max(100)
|
||||
const command = z.object({ path: z.enum(["/ip/ipsec/identity", "/ip/ipsec/peer", "/ip/ipsec/policy", "/ip/ipsec/mode-config", "/ip/pool", "/ip/firewall/nat", "/ip/ipsec/policy/group", "/certificate"]), id: nativeId, cascadeIds: z.array(nativeId).max(2000).optional() }).strict()
|
||||
const command = z.object({ path: z.enum(["/ip/ipsec/identity", "/ip/ipsec/peer", "/ip/ipsec/policy", "/ip/ipsec/mode-config", "/ip/pool", "/ip/firewall/nat", "/ip/ipsec/policy/group", "/ip/ipsec/proposal", "/ip/ipsec/profile", "/certificate"]), id: nativeId, cascadeIds: z.array(nativeId).max(2000).optional() }).strict()
|
||||
const bindingSchema = ipsecServerDeleteActionSchema.extend({
|
||||
operation: z.literal(operation), principal: z.object({ connectionId: z.string().uuid(), credentialId: z.string().uuid(), credentialExpiresAt: z.string().datetime() }).strict(),
|
||||
ownerId: z.string().min(1), ownerProof: hash, policyProof: hash, generation: z.string().min(1), sourceProof: hash, expectedProof: hash,
|
||||
@@ -121,5 +121,5 @@ export function createIpsecServerDeleteAdapter(overrides: Partial<typeof product
|
||||
export function registerIpsecServerDeleteActions(register: typeof add) {
|
||||
const adapter = createIpsecServerDeleteAdapter()
|
||||
registerMcpService(operation, adapter.service)
|
||||
register(operation, "mm_ipsec_server_remove_plan", "Удалить управляемый сервер IPsec по полному манифесту", "network", "mm:network:write", "write", "servers", ipsecServerDeleteActionSchema, { version: 2, prepare: adapter.prepare })
|
||||
register(operation, "mm_ipsec_server_remove_plan", "Удалить управляемый сервер IPsec по полному манифесту", "network", "mm:network:write", "write", "servers", ipsecServerDeleteActionSchema, { version: 3, prepare: adapter.prepare })
|
||||
}
|
||||
@@ -14,7 +14,7 @@ assert.equal(findAction("mm_ipsec_user_create_plan").operation.version, 3)
|
||||
assert.equal(findAction("mm_ipsec_server_init_plan").operation.version, 5)
|
||||
// RouterOS 7.24 certificate bodies (no comment, sign/export by .id): earlier prepared plans need a new approval.
|
||||
assert.equal(findAction("mm_ipsec_existing_certificate_export_plan").operation.version, 2)
|
||||
assert.equal(findAction("mm_ipsec_server_remove_plan").operation.version, 2)
|
||||
assert.equal(findAction("mm_ipsec_server_remove_plan").operation.version, 3)
|
||||
assert.equal(findAction("mm_ipsec_revision_restore_plan").operation.version, 1)
|
||||
assert.equal(findAction("mm_wireguard_revision_restore_plan").operation.id, "config.wireguard.revisions.restore")
|
||||
assert.equal(findAction("mm_vrf_update_plan").schema.safeParse({ serverId: 1, id: "*1", fields: { comment: "reviewed" }, productionAdmission: true }).success, true)
|
||||
@@ -71,4 +71,4 @@ assert.equal(findAction("mm_ipsec_user_edit_plan").operation.id, "network.ipsec.
|
||||
assert.deepEqual(findAction("mm_ipsec_user_edit_plan").operation.requiredPermissions, ["mm:network:write"])
|
||||
|
||||
for (const tool of ["mm_ipsec_peer_remove_plan", "mm_ipsec_certificate_remove_plan", "mm_ipsec_user_remove_plan", "mm_ipsec_peer_edit_plan"]) assert.equal(findAction(tool).operation.version, 2)
|
||||
assert.equal(findAction("mm_ipsec_server_remove_plan").operation.version, 2)
|
||||
assert.equal(findAction("mm_ipsec_server_remove_plan").operation.version, 3)
|
||||
Reference in new issue
Block a user