// Tests for the gate, in process: no network. import { test } from 'node:test'; import assert from 'node:assert/strict'; import { makeGate } from './gate.js'; test('the right key opens the gate; a wrong one is refused', () => { const cap = { it: 'the capability' }; const gate = makeGate('k3y', cap); assert.equal(gate.open('k3y'), cap); assert.throws(() => gate.open('guess'), /no such key/); assert.throws(() => gate.open(''), /no such key/); assert.throws(() => gate.open(undefined), /no such key/); });