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
@@ -88,14 +88,24 @@ test('API recognizes admin mapping and sample actions before generic rules route
|
||||
for(const action of ['list','capture']){assert.equal(await orderExecutionApi({...args,execution,body:{connectionId:'c',idempotencyKey:'k',...(action==='capture'?{listId:'l',rowId:'r'}:{})},route:'/api/order-rules/field-samples/'+action}),true);assert.equal(reply.status,200);}
|
||||
assert.equal(body.connectionId,'c');await assert.rejects(orderExecutionApi({...args,execution,body:{connectionId:'c',idempotencyKey:'k',detailUrl:'http://forged'},route:'/api/order-rules/field-samples/list'}),e=>e.status===400);
|
||||
});
|
||||
test('operator directory hides cross-connection and disabled-connection mapping check evidence',async t=>{
|
||||
test('field APIs authorize directory and advanced evidence while paused owned sources remain readable',async t=>{
|
||||
const f=fixture(t),hiddenId='hidden-sample',ownId='own-sample';f.connection.owner='operator';
|
||||
f.execution.workspace.getConnection=id=>id==='c1'?f.connection:{id:'c2',owner:'other',status:'connected'};
|
||||
const sample=(id,connectionId)=>({id,processName:f.row.processName,processVersion:'1.4',sample:{connectionId},fields:[]});
|
||||
const foreign={id:'c2',owner:'other',status:'connected'};
|
||||
f.execution.workspace.getConnection=id=>id==='c1'?f.connection:foreign;
|
||||
const sample=(id,connectionId)=>({id,processName:f.row.processName,processVersion:'1.4',sample:{connectionId,fields:{value:id==='own-sample'?'OWN FIELD':'SECRET OTHER CONNECTION'}},fields:[{value:id==='own-sample'?'OWN FIELD':'SECRET OTHER CONNECTION'}]});
|
||||
const hidden={id:'hidden-mapping',sampleId:hiddenId,check:{sampleId:hiddenId,result:{fieldTrace:[{value:'SECRET OTHER CONNECTION'}]}}};
|
||||
f.store.fields=()=>({samples:[sample(hiddenId,'c2'),sample(ownId,'c1')],adapters:[{id:'demo',reference:true},{id:'secret-active',sampleId:hiddenId,reference:false}],processes:[{processName:f.row.processName,versions:[{processVersion:'1.4',sampleIds:[hiddenId,ownId],sampleCount:2,draft:hidden,active:{...hidden},reference:{id:'demo'}}]}]});
|
||||
const operator={user:{username:'operator',role:'operator'},sessionId:'operator-session'},visible=f.execution.snapshot(operator).fields;
|
||||
assert.equal(JSON.stringify(visible).includes('SECRET OTHER CONNECTION'),false);assert.equal(visible.processes[0].versions[0].sampleCount,1);assert.deepEqual(visible.processes[0].versions[0].sampleIds,[ownId]);assert.equal(visible.adapters.length,1);
|
||||
f.connection.status='disabled';assert.equal(f.execution.snapshot(operator).fields.samples.length,0);
|
||||
assert.equal(JSON.stringify(f.execution.snapshot(principal).fields).includes('SECRET OTHER CONNECTION'),true);
|
||||
const operator={user:{username:'operator',role:'operator'},sessionId:'operator-session'};
|
||||
async function read(path,who=operator){let value;assert.equal(await orderExecutionApi({execution:f.execution,orderRules:f.store,workspace:f.execution.workspace,...who,url:new URL(path,'http://fixture'),route:path.split('?')[0],method:'GET',reply:(status,result)=>{assert.equal(status,200);value=result;}}),true);return value;}
|
||||
const execution=await read('/api/order-execution');
|
||||
assert.equal(execution.fields.processes,undefined);assert.doesNotMatch(JSON.stringify(execution),/OWN FIELD|SECRET OTHER CONNECTION/);
|
||||
const visible=await read('/api/order-rules/fields?view=directory');
|
||||
assert.doesNotMatch(JSON.stringify(visible),/OWN FIELD|SECRET OTHER CONNECTION/);
|
||||
assert.equal(visible.processes[0].versions[0].sampleCount,1);assert.deepEqual(visible.processes[0].versions[0].sampleIds,[ownId]);assert.equal(visible.processes[0].versions[0].draft,null);assert.equal(visible.processes[0].versions[0].active,null);assert.deepEqual(visible.adapters.map(a=>a.id),['demo']);
|
||||
const advanced=await read('/api/order-rules/fields');assert.match(JSON.stringify(advanced),/OWN FIELD/);assert.doesNotMatch(JSON.stringify(advanced),/SECRET OTHER CONNECTION/);
|
||||
f.connection.status='disabled';foreign.status='disabled';
|
||||
const paused=await read('/api/order-rules/fields');assert.deepEqual(paused.samples.map(s=>s.id),[ownId]);assert.doesNotMatch(JSON.stringify(paused),/SECRET OTHER CONNECTION/);
|
||||
await assert.rejects(f.execution.listFieldSamples({connectionId:'c1',scope:'configuration',idempotencyKey:'paused'},principal),e=>e.status===409);
|
||||
assert.match(JSON.stringify(await read('/api/order-rules/fields',principal)),/SECRET OTHER CONNECTION/);
|
||||
f.connection.owner='new-owner';const transferred=await read('/api/order-rules/fields?view=directory');assert.equal(transferred.samples.length,0);assert.equal(transferred.processes[0].versions[0].sampleCount,0);assert.doesNotMatch(JSON.stringify(transferred),/OWN FIELD|SECRET OTHER CONNECTION/);
|
||||
});
|
||||
Reference in new issue
Block a user