3 lines
1.5 KiB
JavaScript
3 lines
1.5 KiB
JavaScript
import test from 'node:test';import assert from 'node:assert/strict';import {companyFixture} from './company-deed-fixture.mjs';import {ensurePoliticalOfficeCharters,politicalOfficeId} from '../node/political-office-charters.mjs';import {PUBLIC_OFFICES} from '../node/public-government.mjs';import {STAFF_OFFICE_ACCOUNT_ID} from '../node/organisation-keys.mjs';
|
|
test('protected offices receive one automatically applied staff Royal charter, including vacant offices',async()=>{const f=await companyFixture();try{const first=await ensurePoliticalOfficeCharters(f.db,f.keys);assert.equal(first.applied,PUBLIC_OFFICES.length);assert.equal((await ensurePoliticalOfficeCharters(f.db,f.keys)).applied,0);const keys=await f.keys.list(STAFF_OFFICE_ACCOUNT_ID);assert.equal(keys.length,PUBLIC_OFFICES.length);assert(keys.every(k=>k.keyType==='staff-office-royal'&&k.status==='used'&&k.code===null));for(const o of PUBLIC_OFFICES){const deed=await f.db.first('SELECT * FROM political_office_charters WHERE office_key=?',[o.key]);assert.equal(deed.charter_kind,'royal');assert.equal(deed.organisation_id,politicalOfficeId(o.key));assert(keys.some(k=>k.id===deed.staff_key_id&&k.targetId===deed.organisation_id));}assert.equal((await f.keys.list(f.people.Owner.id)).length,0);assert.equal((await f.db.first('SELECT COUNT(*) n FROM political_office_terms')).n,0);await assert.rejects(f.keys.issue({accountId:f.people.Owner.id,keyType:'staff-office-royal',scopeId:'office:emperor',authorize:async()=>{}}),/system issuer/);
|
|
}finally{f.db.close();}});
|

Staff