test(order): verify warehouse faults and await recovery projection

This commit is contained in:
2026-10-04 00:04:36 +08:00
parent 3f6083ff02
commit e8cf5e70ba
8 changed files with 229 additions and 51 deletions
@@ -49,10 +49,14 @@ class Router:
customer = config['customerId']
if not re.fullmatch(r'[1-9][0-9]{0,19}', customer):
raise ValueError('INVALID_CUSTOMER')
warehouse = config.get('receivingWarehouseId', '')
if not re.fullmatch(r'[1-9][0-9]{0,19}', warehouse):
raise ValueError('INVALID_RECEIVING_WAREHOUSE')
if not config.get('requestIds') or any(not re.fullmatch(r'[A-Za-z0-9_.:-]{1,128}', value) for value in config['requestIds']):
raise ValueError('BOUNDED_REQUEST_IDS_REQUIRED')
self.paths = {'IAM': '/internal/iam/tenants/' + customer + '/order-eligibility',
'FINANCE': '/internal/finance/v1/wallet/accounts/' + customer}
'FINANCE': '/internal/finance/v1/wallet/accounts/' + customer,
'WAREHOUSE': '/internal/warehouses/0/' + warehouse + '/active'}
def status(self):
with self.lock:
@@ -67,7 +71,7 @@ class Router:
with self.lock:
# Even an authenticated malformed command disarms first.
self.mode, self.deadline = 'PASS', 0
if mode not in ('PASS', 'IAM', 'FINANCE') or (mode != 'PASS' and
if mode not in ('PASS', 'IAM', 'FINANCE', 'WAREHOUSE') or (mode != 'PASS' and
(type(ttl) is not int or not 1 <= ttl <= 60)):
raise ValueError('INVALID_MODE_OR_TTL')
self.mode = mode
@@ -77,7 +81,7 @@ class Router:
def dispatch(self, method, path, headers, body, peer):
prefix, separator, rest = path.lstrip('/').partition('/')
dependency = {'iam': 'IAM', 'finance': 'FINANCE'}.get(prefix)
dependency = {'iam': 'IAM', 'finance': 'FINANCE', 'warehouse': 'WAREHOUSE'}.get(prefix)
if not dependency or not separator:
return 404, {}, b'Unknown dependency route'
actual_path = '/' + rest