Treasury & Bank Transfer Management System — سامانه مدیریت خزانهداری و حوالههای بانکی
Fail-close production HTTP ingress with explicit gate regression tests: src/platform/identity/production-http-guard.test.ts
davoodmehraban89 committed
Oct 21, 2026 at 08:45 UTC
a40fc64598192bd4f7c46e5f1280c285b5ef3344
1 file changed
+28
src/platform/identity/production-http-guard.test.ts
new
+28
@@ -0,0 +1,28 @@
1
+import {describe,it,expect} from 'vitest';
2
+import {isProductionOperationBlocked as blocked} from './production-http-guard';
3
+const production={NODE_ENV:'production',TREASURYFLOW_DESKTOP_LOCAL:'0'};
4
+describe('production access fails closed at ingress',()=>{
5
+ it('blocks financial and action endpoints before any data access',()=>{
6
+ for(const path of ['/','/dashboard','/accounts','/payments','/payments/new',
7
+ '/queue','/audit','/api/payments','/api/transfer/submit','/reports/export',
8
+ '/integrations','/master-data','/reconciliation','/%2e%2e/payments']){
9
+ expect(blocked(production,path),path).toBe(true);
10
+ }
11
+ });
12
+ it('exposes only login view and readiness (not operations)',()=>{
13
+ expect(blocked(production,'/login')).toBe(false);
14
+ expect(blocked(production,'/api/ready')).toBe(false);
15
+ expect(blocked(production,'/api/ready/secret')).toBe(true);
16
+ expect(blocked(production,'/login/dashboard')).toBe(true);
17
+ });
18
+ it('cannot be bypassed by unrelated environment flags',()=>{
19
+ for(const x of [{}, {BANK_ADAPTER_MODE:'disabled'}, {IDENTITY_PROVIDER:'oidc-ref'},
20
+ {AUTH_PROXY_HMAC_SECRET:'configured'}, {TREASURYFLOW_DESKTOP_LOCAL:'true'}]){
21
+ expect(blocked({...production,...x},'/payments')).toBe(true);
22
+ }
23
+ });
24
+ it('preserves isolated local desktop and developer flow',()=>{
25
+ expect(blocked({NODE_ENV:'development'},'/dashboard')).toBe(false);
26
+ expect(blocked({NODE_ENV:'production',TREASURYFLOW_DESKTOP_LOCAL:'1'},'/payments')).toBe(false);
27
+ });
28
+});