feat(mcp): подготовить сервер и доступ к приёмке
This commit is contained in:
commit
bf3d50e1ff
3835 files changed
+537122
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import assert from "node:assert/strict"
|
||||
import { test } from "node:test"
|
||||
import { parseEvoBgpCatalog } from "./evobgp-catalog"
|
||||
const empty = { fetchedAt: "2026-10-01T00:00:00Z", modules: [], domains: [], ipRanges: [], asns: [], communities: [] }
|
||||
const domain = { id: "domain-1", domain: "example.test", resolvedIp: "—", asn: "—", purpose: "", filter: "", updated: "—", enabled: false }
|
||||
test("known empty and false stay explicit without invented rows", () => {
|
||||
assert.deepEqual(parseEvoBgpCatalog(empty), empty)
|
||||
assert.equal(parseEvoBgpCatalog({ ...empty, domains: [domain] }).domains[0].enabled, false)
|
||||
})
|
||||
test("malformed or partial catalogue never reaches consumers as a snapshot", () => {
|
||||
for (const raw of [{}, null, { ...empty, domains: undefined }, { ...empty, asns: {} }, { ...empty, fetchedAt: "bad" }, { ...empty, domains: [null] }, { ...empty, domains: [{ ...domain, enabled: undefined }] }, { ...empty, domains: [domain, domain] }]) assert.throws(() => parseEvoBgpCatalog(raw), /Каталог Evolution не подтверждён/)
|
||||
})
|
||||
test("ASN and community zero counts are preserved, invalid counts rejected", () => {
|
||||
const asn = { id: "asn-1", asn: "AS1", org: "", country: "", prefixes: 0, filter: "", updated: "—", enabled: false }
|
||||
assert.equal(parseEvoBgpCatalog({ ...empty, asns: [asn] }).asns[0].prefixes, 0)
|
||||
assert.throws(() => parseEvoBgpCatalog({ ...empty, asns: [{ ...asn, prefixes: -1 }] }))
|
||||
})
|
||||
|
||||
|
||||
test("unknown counts stay nullable and differ from confirmed zero", () => {
|
||||
const asn = { id: "asn-unknown", asn: "AS64512", org: "", country: "", prefixes: null, filter: "", updated: "—", enabled: true }
|
||||
const community = { id: "c", value: "64512:1", name: "c", description: "", type: "custom", filterIds: [], serverCount: 0, prefixCount: null, action: "permit", enabled: true }
|
||||
const result = parseEvoBgpCatalog({...empty, asns:[asn], communities:[community]})
|
||||
assert.equal(result.asns[0].prefixes,null)
|
||||
assert.equal(result.communities[0].prefixCount,null)
|
||||
assert.equal(result.communities[0].serverCount,0)
|
||||
for(const value of [undefined,-1,1.5,Number.MAX_SAFE_INTEGER+1]) {
|
||||
assert.throws(()=>parseEvoBgpCatalog({...empty,asns:[{...asn,prefixes:value}]}))
|
||||
assert.throws(()=>parseEvoBgpCatalog({...empty,communities:[{...community,prefixCount:value}]}))
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user