Treasury & Bank Transfer Management System — سامانه مدیریت خزانهداری و حوالههای بانکی
Add independent production access edge/security regression suite: qa/scripts/production-http-edge-cases.mjs
davoodmehraban89 committed
Oct 21, 2026 at 08:48 UTC
44cc5442d2edd637a857eb36dfc5902f24eedb1c
1 file changed
+33
qa/scripts/production-http-edge-cases.mjs
new
+33
@@ -0,0 +1,33 @@
1
+import assert from 'node:assert/strict';
2
+import {spawn} from 'node:child_process';
3
+const port=3133,base='http://127.0.0.1:'+port;
4
+const env={...process.env,DATABASE_URL:'evidence-ref',IDENTITY_PROVIDER:'oidc-ref',
5
+ AUTH_PROXY_HMAC_SECRET:'synthetic-smoke-secret',KMS_KEY_ID:'kms-ref',
6
+ SIEM_ENDPOINT:'siem-ref',WAF_POLICY_ID:'waf-ref',ALERT_CHANNEL:'ops-ref',
7
+ BANK_ADAPTER_MODE:'disabled',TREASURYFLOW_DESKTOP_LOCAL:'0'};
8
+const child=spawn(process.execPath,['node_modules/next/dist/bin/next','start','-p',String(port)],{env,stdio:'ignore'});
9
+const pause=ms=>new Promise(resolve=>setTimeout(resolve,ms));
10
+try{
11
+ let ready=false;
12
+ for(let i=0;i<50;i++){
13
+ try{if((await fetch(base+'/api/ready',{signal:AbortSignal.timeout(1500)})).status===200){ready=true;break}}catch{}
14
+ await pause(250);
15
+ }
16
+ assert(ready,'PRODUCTION_APP_NOT_READY');
17
+ const allowed=await fetch(base+'/login',{redirect:'manual'});
18
+ assert.equal(allowed.status,200,'LOGIN_MUST_REMAIN_ACCESSIBLE');
19
+ for(const path of ['/payments?role=admin','/api/ready/anything','/login/dashboard',
20
+ '/reports/export?format=xlsx','/pay%6dents','/%70ayments','/payments/%2e%2e/accounts',
21
+ '/api/financial/write','/favicon.ico/evil']){
22
+ const r=await fetch(base+path,{redirect:'manual'});
23
+ assert.equal(r.status,403,'EDGE_PATH_BYPASS_'+path);
24
+ }
25
+ const readyResponse=await fetch(base+'/api/ready?path=/payments');
26
+ assert.equal(readyResponse.status,200);
27
+ const readyData=await readyResponse.json();
28
+ assert.equal(readyData.bankAdapter,'disabled');
29
+ assert.equal(readyData.status,'ready');
30
+ assert(!JSON.stringify(readyData).includes('synthetic-smoke-secret'));
31
+ console.log('GATE_PASS_PRODUCTION_HTTP_10_EDGE_PATHS_AND_READINESS');
32
+}catch(e){console.error('PRODUCTION_HTTP_EDGE_FAIL_'+String(e.message).replace(/[^A-Za-z0-9_]/g,''));process.exitCode=1}
33
+finally{child.kill();await pause(300)}