Files
MikrotikManager/backend/scripts/acceptance/chr-recursive-direct-links.test.mjs
T

18 lines
1.2 KiB
JavaScript

import assert from 'node:assert/strict';
import { test } from 'node:test';
import { inspectDirectLinks } from './chr-recursive-direct-links.mjs';
test('direct evidence requires exact opaque reference and corroborated ifindex namespace', () => {
const route = { 'routing-table': 'main', 'nexthop-id': '*A', 'immediate-gw': '192.0.2.1%ether1' };
const nexthop = { '.id': '*A', 'immediate-gw.interface-idx': '4' };
const iface = { id: '9', ifindex: '4', name: 'ether1' };
const table = { '.id': '*0', name: 'main' };
assert.deepEqual(inspectDirectLinks([route], [nexthop], [iface], [table]), {
opaqueReferences: 1, namedInterfaceCorroborations: 1, interfaceIdSubstitutionRefusals: 1, tableNames: 1, recursiveLinkRows: 0,
});
assert.throws(() => inspectDirectLinks([{ ...route, 'nexthop-id': '*a' }], [nexthop], [iface], [table]), /exact opaque/);
assert.throws(() => inspectDirectLinks([{ ...route, 'routing-table': '0' }], [nexthop], [iface], [table]), /named routing table/);
assert.throws(() => inspectDirectLinks([route], [nexthop], [{ ...iface, id: '4', ifindex: '9' }], [table]), /corroboration/);
assert.throws(() => inspectDirectLinks([route], [nexthop], [iface, { ...iface, id: '3' }], [table]), /ambiguous ifindex/);
});