collabSupport/tests/igmpFixPayload.test.js
jmcqueen d112e45eb6 Detect and inline-remediate Meraki IGMP snooping in /phonestatus
DECT basestations rely on multicast for handset discovery/registration.
When Meraki switches have IGMP snooping enabled without a querier —
or per-switch overrides that deviate from a DECT-safe policy — those
frames are pruned and DECT handsets silently fail to register.

- integrations/meraki/switches.js: getSwitchMulticastSettings,
  setSwitchMulticastSettings, and pure summarizeMulticast verdict fn.
- services/phoneService.js: fires the multicast fetch as soon as the
  network id is known, overlapping DECT enrichment; attaches
  data.multicast summary to the collector output. Non-fatal on error.
- services/renderers/phoneStatusRenderer.js: emits a single warning
  line inside the DECT Basestations section only when needsFix is
  true, itemizing which parts deviate (default snoop, default flood,
  N overrides).
- commands/igmpFix.js: frozen DECT_SAFE_MULTICAST_PAYLOAD constant
  ({snoop:false, flood:true, overrides:[]}), adaptive-card builder,
  and confirm/cancel handlers.
- commands/phoneStatus.js: appends the adaptive card when needsFix
  and the trigger came from chat (skipped on HTTP path).
- index.js: IGMP_FIX_ACTIONS set + dispatch branch mirroring the
  HOST_ASSIGN pattern (one-shot pending lookup, censorActionCard,
  domain call).
- utils/pendingIgmpFixes.js: 15-min TTL pending-card store.
- tests: 11 summarizer cases (all deviation permutations + malformed
  input), 4 renderer cases (each warning-line shape + silence when
  needsFix false or no DECT), and a frozen-constant regression guard
  on the PUT payload. Full suite: 47/47 passing.
2026-07-02 14:10:33 -04:00

27 lines
1 KiB
JavaScript

// Regression guard for the DECT-safe multicast payload constant.
//
// The whole IGMP-fix design is predicated on a single hardcoded PUT
// body — no read-then-mutate, no per-store branching. If someone
// accidentally flips one of these booleans (or adds an override to
// the array), every remediation click starts silently corrupting
// production Meraki config. This one test makes that impossible to
// merge without also updating the test, which forces a review.
import test from 'node:test';
import assert from 'node:assert/strict';
import { DECT_SAFE_MULTICAST_PAYLOAD } from '../commands/igmpFix.js';
test('DECT_SAFE_MULTICAST_PAYLOAD has the exact expected shape', () => {
assert.deepEqual(DECT_SAFE_MULTICAST_PAYLOAD, {
defaultSettings: {
igmpSnoopingEnabled: false,
floodUnknownMulticastTrafficEnabled: true,
},
overrides: [],
});
});
test('DECT_SAFE_MULTICAST_PAYLOAD is frozen so nothing can mutate it at runtime', () => {
assert.equal(Object.isFrozen(DECT_SAFE_MULTICAST_PAYLOAD), true);
});