Separate Zapier, web, API, and leaf access planes with NATS authz
Some checks are pending
offline / test (push) Waiting to run

Zapier is one ingress. Direct web, customer API, and S2S leaf nodes are their own services. Every hop to an internal subject must pass verae.access.authz.check (default deny by plane).
This commit is contained in:
George Lambert 2026-09-11 16:05:05 -04:00
parent ac38676645
commit 1b199ca4d4
117 changed files with 2640 additions and 105 deletions

View file

@ -0,0 +1,52 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { spawn } from 'node:child_process';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const root = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
const authzRoot = path.join(root, '..', 'verae-access-authz');
const booksRoot = path.join(root, '..', 'zappier-account-balance');
test('web plane can read statement after authz, cannot skip authz', async () => {
const authzPort = 18021;
const booksPort = 18022;
const webPort = 18023;
const authz = spawn(process.execPath, ['src/server.js'], {
cwd: authzRoot,
env: { ...process.env, PORT: String(authzPort) },
stdio: ['ignore', 'pipe', 'pipe'],
});
const books = spawn(process.execPath, ['src/server.js'], {
cwd: booksRoot,
env: { ...process.env, PORT: String(booksPort) },
stdio: ['ignore', 'pipe', 'pipe'],
});
const web = spawn(process.execPath, ['src/server.js'], {
cwd: root,
env: {
...process.env,
PORT: String(webPort),
AUTHZ_URL: `http://127.0.0.1:${authzPort}`,
ACCOUNT_BALANCE_URL: `http://127.0.0.1:${booksPort}`,
},
stdio: ['ignore', 'pipe', 'pipe'],
});
await new Promise((r) => setTimeout(r, 600));
try {
await fetch(`http://127.0.0.1:${booksPort}/adjust`, {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ customerId: 'c-web', cents: 400, kind: 'reload' }),
});
const h = await (await fetch(`http://127.0.0.1:${webPort}/health`)).json();
assert.equal(h.plane, 'web');
const st = await (await fetch(`http://127.0.0.1:${webPort}/statement/c-web`)).json();
assert.equal(st.prepaidCents, 400);
assert.equal(st.plane, 'web');
} finally {
web.kill('SIGTERM');
books.kill('SIGTERM');
authz.kill('SIGTERM');
}
});