test(order): verify warehouse faults and await recovery projection
This commit is contained in:
@@ -10,8 +10,8 @@ spec=importlib.util.spec_from_file_location('proxy',sys.argv[1]);p=importlib.uti
|
||||
class ProxyTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.now=[10.0];self.calls=[];self.logs=[]
|
||||
self.config={'customerId':'7','controlToken':'private-control','internalToken':'private-internal-token',
|
||||
'orderIps':['172.20.0.10'],'requestIds':['fixture-request'],'upstreams':{'IAM':'http://iam.invalid:9201','FINANCE':'http://finance.invalid:9207'}}
|
||||
self.config={'customerId':'7','receivingWarehouseId':'30','controlToken':'private-control','internalToken':'private-internal-token',
|
||||
'orderIps':['172.20.0.10'],'requestIds':['fixture-request'],'upstreams':{'IAM':'http://iam.invalid:9201','FINANCE':'http://finance.invalid:9207','WAREHOUSE':'http://warehouse.invalid:9202'}}
|
||||
def forward(*args): self.calls.append(args);return 201,{'X-Upstream':'kept'},b'original-response'
|
||||
self.router=p.Router(self.config,forward=forward,clock=lambda:self.now[0],record=self.logs.append)
|
||||
self.headers={'X-Internal-Service-Token':'private-internal-token','X-Request-Id':'fixture-request'}
|
||||
@@ -42,6 +42,24 @@ class ProxyTests(unittest.TestCase):
|
||||
self.assertEqual(self.send(path)[0],503)
|
||||
self.now[0]=15.0
|
||||
self.assertEqual(self.send(path)[0],201);self.assertEqual(self.router.status()['mode'],'PASS')
|
||||
def test_public_warehouse_fault_is_bounded_by_exact_warehouse_request_and_order_identity(self):
|
||||
self.router.set_mode('private-control','WAREHOUSE',60)
|
||||
path='/warehouse/internal/warehouses/0/30/active'
|
||||
self.assertEqual(self.send(path)[0],503)
|
||||
for other,method,headers,peer in [
|
||||
(path.replace('/30/','/31/'),'GET',self.headers,'172.20.0.10'),
|
||||
(path.replace('/0/','/7/'),'GET',self.headers,'172.20.0.10'),
|
||||
(path+'?extra=1','GET',self.headers,'172.20.0.10'),
|
||||
(path,'POST',self.headers,'172.20.0.10'),
|
||||
(path,'GET',{**self.headers,'X-Request-Id':'another-customer-request'},'172.20.0.10'),
|
||||
(path,'GET',{**self.headers,'X-Internal-Service-Token':'wrong'},'172.20.0.10'),
|
||||
(path,'GET',self.headers,'172.20.0.11')]:
|
||||
self.assertEqual(self.send(other,method,headers,peer)[0],201)
|
||||
self.now[0]=70.0
|
||||
self.assertEqual(self.send(path)[0],201)
|
||||
def test_invalid_receiving_warehouse_scope_is_rejected(self):
|
||||
for value in ['0','../30','30?all=true','']:
|
||||
with self.assertRaises(ValueError):p.Router({**self.config,'receivingWarehouseId':value})
|
||||
def test_control_auth_and_malformed_authenticated_command(self):
|
||||
self.router.set_mode('private-control','IAM',10)
|
||||
with self.assertRaises(PermissionError):self.router.set_mode('wrong','PASS')
|
||||
@@ -65,5 +83,5 @@ sys.exit(0 if result.wasSuccessful() else 1)
|
||||
fileURLToPath(new URL('./order-submit-dependency-fault-proxy.py', import.meta.url))],
|
||||
{ encoding:'utf8', env:{...process.env,PYTHONDONTWRITEBYTECODE:'1'} })
|
||||
assert.equal(result.status,0,result.stderr || result.error?.message)
|
||||
assert.match(result.stderr,/Ran 6 tests/)
|
||||
assert.match(result.stderr,/Ran 8 tests/)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user