mirror of
https://github.com/gadgethd/ukmesh.git
synced 2026-12-06 03:14:09 +00:00
24 lines
1.1 KiB
JavaScript
24 lines
1.1 KiB
JavaScript
const assert = require('node:assert/strict');
|
|
const test = require('node:test');
|
|
const { publicConfig } = require('./verify-core.cjs');
|
|
|
|
test('isolated public origins accept only the configured projection authorities and sources', () => {
|
|
const token = 'x'.repeat(32);
|
|
const beacon = 'y'.repeat(32);
|
|
const config = {
|
|
publicProjection: true,
|
|
dbPath: '/data/analyzer.db',
|
|
publicAuthorityURL: 'http://backend:3000/internal/ingest/public/policy',
|
|
publicAuthorityToken: token,
|
|
postgresSources: [{ dsn: 'postgresql://reader@fixture/database' }],
|
|
};
|
|
assert.equal(publicConfig(config, token, beacon), true);
|
|
assert.equal(publicConfig(config, token, token), false);
|
|
for (const override of [
|
|
{publicProjection: false}, {publicAuthorityToken: beacon},
|
|
{mqttSources: [{broker:'tcp://fixture'}]}, {dbPath:'/existing/analyzer.db'},
|
|
{redisSources: [{url:'redis://fixture'}]}, {publicAuthorityURL:'https://fixture.invalid'},
|
|
{postgresSources: [{dsn:'postgres://fixture',requirePublicVisibility:false}]},
|
|
]) assert.equal(publicConfig({...config, ...override}, token, beacon), false);
|
|
});
|