web/website/tests/staff-bureau-security.test.mjs
Dev 6deb4a2e7d DuneRealms V2 clean baseline
Owner-authorised history reset; current source tree preserved exactly.
2026-11-13 00:05:14 +01:00

5 lines
1.2 KiB
JavaScript

import test from 'node:test';import assert from 'node:assert/strict';import {shadowStaffAccess,canReviewPromotion} from '../node/staff-bureau-policy.mjs';import {assessTransfer} from '../node/staff-bureau-promotions.mjs';
test('player cannot gain staff powers through temporary duty grants',()=>{const a=shadowStaffAccess({level:'player',department:null},[{node:'web.bans.manage',expiresAt:999999}],100);assert.deepEqual(a.nodes,[]);});
test('unregistered duty nodes are denied',()=>{const a=shadowStaffAccess({level:'staff',department:'operations'},[{node:'web.unknown.superuser',expiresAt:999999}],100);assert.ok(!a.nodes.includes('web.unknown.superuser'));});
test('suspended target cannot be promoted even by owner',()=>{const owner={accountId:'a',level:'owner',department:null};const target={accountId:'b',level:'head',department:'operations',status:'suspended'};assert.equal(canReviewPromotion(owner,target,'director'),false);});
test('suspended director cannot transfer staff',()=>{const director={accountId:'a',level:'director',department:null,status:'suspended'};const target={accountId:'b',level:'staff',department:'operations'};assert.equal(assessTransfer({actor:director,target,department:'development'}).allowed,false);});