feat: complete workflow recovery and safe administration
This commit is contained in:
1 parent
1148aa6f14
commit
69583e8c33
46 files changed
+756
-120
No files matched your search
@@ -23,7 +23,7 @@ test('scan API enforces owner, role and origin; scan results and overview reflec
|
||||
test('ledger browser keeps filtering, details and addressable PDF navigation independent from scanner failures',async t=>{
|
||||
const {base,scanner,scanStore}=await setup(t);await scanner.scan('fixture',{user:{username:'admin',role:'admin'},sessionId:'fixture'});
|
||||
const browser=await loadPlaywright().chromium.launch(browserOptions());t.after(()=>browser.close());const page=await browser.newPage();await page.goto(base+'/#records');await page.locator('#username').fill('admin');await page.locator('#password').fill('Test-password-123');await page.locator('#login-form button').click();
|
||||
await page.locator('[data-arrival-row]').first().waitFor();assert.equal(await page.locator('[data-arrival-row]').count(),2);assert.equal(await page.getByRole('navigation',{name:'记录导航'}).getByRole('link',{name:'流程到达记录',exact:true}).getAttribute('aria-current'),'page');
|
||||
await page.locator('[data-arrival-row]').first().waitFor();assert.equal(await page.locator('[data-arrival-row]').count(),2);assert.equal(await page.getByRole('navigation',{name:'工具导航'}).getByRole('link',{name:'流程到达记录',exact:true}).getAttribute('aria-current'),'page');
|
||||
await page.getByRole('button',{name:'查看详情',exact:true}).first().click();await page.getByRole('dialog',{name:'流程到达详情'}).waitFor();await page.getByRole('dialog').getByText('订单号:123',{exact:true}).waitFor();await page.getByRole('button',{name:'关闭详情',exact:true}).click();
|
||||
const background=normalizeArrival({taskId:'background',serialNum:'BG-1',processName:'海外运营订单评审',startTime:'2026-10-16T12:00:00',processInstanceSubject:'后台扫描新增'},'portal-v8');scanStore.complete(scanStore.begin('fixture','系统扫描'),'fixture',[background]);
|
||||
await page.getByText('记录有更新。',{exact:true}).waitFor({timeout:20000});await page.locator('.card-header').getByRole('button',{name:'刷新记录',exact:true}).click();await page.getByText('后台扫描新增',{exact:true}).filter({visible:true}).waitFor();await page.getByLabel('搜索流程记录',{exact:true}).fill('昨天');await page.getByRole('button',{name:'查询',exact:true}).click();await page.waitForFunction(()=>document.querySelectorAll('[data-arrival-row]').length===1);await page.getByText('昨天的流程',{exact:true}).filter({visible:true}).waitFor();
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
const test=require('node:test'),assert=require('node:assert/strict'),fs=require('node:fs'),os=require('node:os'),path=require('node:path'),cp=require('node:child_process');
|
||||
function fixture(t,protection){const dir=fs.mkdtempSync(path.join(os.tmpdir(),'vault-retry-')),previous=process.env.LOCALAPPDATA;process.env.LOCALAPPDATA=dir;const logs=[];t.mock.method(console,'error',(...args)=>logs.push(args.join(' ')));t.mock.method(cp,'execFileSync',(_,args,options)=>{const script=args.at(-1);if(script.includes('::Protect('))return protection(options);if(script.includes('::Unprotect('))return options.input;return '';});delete require.cache[require.resolve('../../src/platform/security/vault.cjs')];const {BpmVault}=require('../../src/platform/security/vault.cjs');let vault;t.after(()=>{vault?.destroy();if(previous===undefined)delete process.env.LOCALAPPDATA;else process.env.LOCALAPPDATA=previous;fs.rmSync(dir,{recursive:true,force:true});});return {dir,logs,create:()=>vault=new BpmVault({stateDir:path.join(dir,'state')}),keys:()=>fs.readdirSync(path.join(dir,'OrderNotificationAutomation','bpm-keys'))};}
|
||||
test('one timed-out protection attempt retries the same key and commits one readable encrypted identity',{skip:process.platform!=='win32'},t=>{
|
||||
const inputs=[];const f=fixture(t,options=>{inputs.push(options.input);if(inputs.length===1)throw Object.assign(Error('synthetic-secret timeout'),{code:'ETIMEDOUT'});return options.input;});const vault=f.create(),value={fixture:'private synthetic data'},bytes=vault.encode('sample',value);assert.deepEqual(vault.decode('sample',bytes),value);assert.equal(inputs.length,2);assert.equal(inputs[0],inputs[1]);assert.equal(f.keys().length,1);assert.equal(f.logs.length,1);assert.doesNotMatch(f.logs.join(''),/synthetic-secret|private|ProtectedData|base64/i);assert.equal(bytes.includes(Buffer.from(value.fixture)),false);
|
||||
});
|
||||
for(const code of ['ETIMEDOUT','EACCES'])test('protection '+code+' stays bounded and never publishes a partial key',{skip:process.platform!=='win32'},t=>{let calls=0;const f=fixture(t,()=>{calls++;throw Object.assign(Error('synthetic-secret '+code),{code});}),vault=f.create();assert.throws(()=>vault.encode('sample',{fixture:'private'}),e=>e.status===503&&e.stage==='key_protect'&&e.cause.code===code);assert.equal(calls,code==='ETIMEDOUT'?2:1);assert.equal(f.keys().length,0);assert.equal(f.logs.length,code==='ETIMEDOUT'?1:0);assert.doesNotMatch(f.logs.join(''),/synthetic-secret|private/);});
|
||||
Reference in new issue
Block a user