Initial import of verae-access-zapier from zapier monorepo

This commit is contained in:
George Lambert 2026-09-11 19:10:15 -04:00
commit bb61b99579
5 changed files with 117 additions and 0 deletions

39
test/health.test.js Normal file
View file

@ -0,0 +1,39 @@
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');
test('zapier plane has no portal and cannot read statements', async () => {
const authzPort = 18028;
const zPort = 18029;
const authz = spawn(process.execPath, ['src/server.js'], {
cwd: authzRoot,
env: { ...process.env, PORT: String(authzPort) },
stdio: ['ignore', 'pipe', 'pipe'],
});
const z = spawn(process.execPath, ['src/server.js'], {
cwd: root,
env: { ...process.env, PORT: String(zPort), AUTHZ_URL: `http://127.0.0.1:${authzPort}` },
stdio: ['ignore', 'pipe', 'pipe'],
});
await new Promise((r) => setTimeout(r, 500));
try {
const h = await (await fetch(`http://127.0.0.1:${zPort}/health`)).json();
assert.equal(h.plane, 'zapier');
const portal = await fetch(`http://127.0.0.1:${zPort}/portal`);
assert.equal(portal.status, 404);
const deny = await fetch(`http://127.0.0.1:${authzPort}/check`, {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ plane: 'zapier', subject: 'verae.billing.statement.get' }),
});
assert.equal(deny.status, 403);
} finally {
z.kill('SIGTERM');
authz.kill('SIGTERM');
}
});