Update the browser, editor, settings, and installer
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { AgentController } from '../src/agent.mjs';
|
||||
test('agent grants bind profile, tab, document and expiry', () => {
|
||||
let now = 100;
|
||||
const tabs = new Map([['a', { profileId: 'agent', epoch: 1 }], ['p', { profileId: 'personal', epoch: 1 }]]);
|
||||
const agent = new AgentController(id => tabs.get(id), () => now);
|
||||
assert.throws(() => agent.grant('p', 'agent'));
|
||||
const token = agent.grant('a', 'agent');
|
||||
assert.throws(() => agent.authorized(token, 'p'));
|
||||
assert.equal(agent.authorized(token, 'a'), tabs.get('a'));
|
||||
tabs.get('a').epoch++;
|
||||
assert.throws(() => agent.authorized(token, 'a'));
|
||||
const next = agent.grant('a', 'agent'); now += 300_001;
|
||||
assert.throws(() => agent.authorized(next, 'a'));
|
||||
const last = agent.grant('a', 'agent'); agent.revokeAll();
|
||||
assert.throws(() => agent.authorized(last, 'a'));
|
||||
});
|
||||
Reference in New Issue
Block a user