717ae1031e
Zanzibar-style authorization graph engine (direct/chain/TTU/defeasible/ binary modes, condensed snapshots, value relations) with 39 rigor test campaigns. Includes fixes for snapshot binary writer/reader format mismatch (snapshot-of-snapshot corruption), possibility write-boundary validation, empty-graph snapshot serialization, relation lookup cache direction collision, config-redefinition cache invalidation, binary threshold semantics, defeasible compiled routing, and comparator reason whitelisting.
42 lines
1.7 KiB
JavaScript
42 lines
1.7 KiB
JavaScript
import { describe, test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { Arbiter } from '../../src/core/Arbiter.js';
|
|
import { UnifiedKeyManager } from '../../src/core/UnifiedKeyManager.js';
|
|
|
|
describe('Key manager consistency across subsystems', () => {
|
|
test('relation ids align between arbiter and indices', () => {
|
|
const arbiter = new Arbiter();
|
|
const arbiterRelId = arbiter.keyManager._getRelationId('can_read');
|
|
const indicesRelId = arbiter.indices._getRelationId('can_read');
|
|
assert.strictEqual(arbiterRelId, indicesRelId);
|
|
});
|
|
|
|
test('relation cache keys use the same relation id source', () => {
|
|
const arbiter = new Arbiter();
|
|
arbiter.addNode('user', 'user');
|
|
arbiter.addNode('doc', 'document');
|
|
const srcId = arbiter.nodeManager.getNodeId('user');
|
|
const dstId = arbiter.nodeManager.getNodeId('doc');
|
|
|
|
const directKeyFromIds = arbiter.relationManager._makeDirectCacheKey(srcId, 'can_read', dstId);
|
|
const directKeyFromStrings = arbiter.relationManager._makeDirectCacheKeyFromStrings('user', 'can_read', 'doc');
|
|
|
|
assert.strictEqual(directKeyFromIds, directKeyFromStrings);
|
|
});
|
|
|
|
test('value manager and arbiter key managers agree on composite keys', () => {
|
|
const arbiter = new Arbiter();
|
|
arbiter.addNode('user', 'user');
|
|
arbiter.addNode('doc', 'document');
|
|
|
|
const srcId = arbiter.keyManager.getStringId('user');
|
|
const dstId = arbiter.keyManager.getStringId('doc');
|
|
const arbiterKey = arbiter.keyManager.createCompositeKey(srcId, 'can_read', dstId);
|
|
|
|
const valueManagerKeyManager = new UnifiedKeyManager();
|
|
const valueKey = valueManagerKeyManager.createCompositeKey(srcId, 'can_read', dstId);
|
|
|
|
assert.strictEqual(arbiterKey, valueKey);
|
|
});
|
|
});
|