优化
This commit is contained in:
@@ -5,15 +5,17 @@ import { AcceptanceRun, configureReadOnlyEvidence, parseArguments, validateExecu
|
||||
const args = ['--environment', 'gray', '--modules', 'phase5-root-fulfillment',
|
||||
'--gateway', 'https://gray.example.invalid', '--username', 'contract', '--password', 'contract',
|
||||
'--pda-username', 'contract-pda', '--pda-password', 'contract-pda',
|
||||
'--fixed-customer-id', 'TEN2100000000000000001', '--merchant-username', 'existing-gray', '--merchant-password', 'offline-gray-password',
|
||||
'--f40-tax-mode', 'TAX_REFUND', '--output', 'reports/gray-contract.json']
|
||||
|
||||
test('gray is explicit, keeps real environment identity and creates its own customer', () => {
|
||||
test('gray is explicit, keeps real environment identity and uses the designated existing customer', () => {
|
||||
const options = validateExecutionOptions(parseArguments(args))
|
||||
assert.equal(options.environment, 'gray')
|
||||
assert.deepEqual(options.modules, ['merchant-qualification-fixture', 'phase5-root-fulfillment'])
|
||||
const run = new AcceptanceRun(options)
|
||||
assert.match(run.marker, /^GRAY-API-/)
|
||||
assert.equal(run.context.f40TaxMode, 'TAX_REFUND')
|
||||
assert.equal(run.options.fixedCustomerId, 'TEN2100000000000000001')
|
||||
})
|
||||
|
||||
test('gray cannot run unbounded full suite, extra modules, bulk data or TEST faults', () => {
|
||||
@@ -40,7 +42,8 @@ test('gray has no fallback to TEST account, gateway, customer or PDA environment
|
||||
const keys = ['ADMIN_TEST_GATEWAY', 'ADMIN_TEST_USERNAME', 'ADMIN_TEST_PASSWORD', 'ADMIN_PDA_USERNAME',
|
||||
'ADMIN_PDA_PASSWORD', 'MERCHANT_TEST_USERNAME', 'MERCHANT_TEST_PASSWORD', 'ADMIN_TEST_CUSTOMER_NAME',
|
||||
'ADMIN_GRAY_GATEWAY', 'ADMIN_GRAY_USERNAME', 'ADMIN_GRAY_PASSWORD', 'ADMIN_GRAY_PDA_USERNAME',
|
||||
'ADMIN_GRAY_PDA_PASSWORD', 'MERCHANT_GRAY_USERNAME', 'MERCHANT_GRAY_PASSWORD', 'ADMIN_GRAY_CUSTOMER_NAME']
|
||||
'ADMIN_GRAY_PDA_PASSWORD', 'MERCHANT_GRAY_USERNAME', 'MERCHANT_GRAY_PASSWORD', 'ADMIN_GRAY_CUSTOMER_NAME',
|
||||
'ADMIN_GRAY_FIXED_CUSTOMER_ID', 'ADMIN_TEST_FIXED_CUSTOMER_ID']
|
||||
const saved = new Map(keys.map(key => [key, process.env[key]]))
|
||||
try {
|
||||
for (const key of keys) {
|
||||
@@ -49,7 +52,7 @@ test('gray has no fallback to TEST account, gateway, customer or PDA environment
|
||||
}
|
||||
const options = parseArguments(['--environment', 'gray', '--modules', 'phase5-root-fulfillment'])
|
||||
for (const key of ['gateway', 'username', 'password', 'pdaUsername', 'pdaPassword',
|
||||
'merchantUsername', 'merchantPassword', 'customerName']) assert.equal(options[key], '')
|
||||
'merchantUsername', 'merchantPassword', 'customerName', 'fixedCustomerId']) assert.equal(options[key], '')
|
||||
process.env.ADMIN_GRAY_GATEWAY = 'https://gray.example.invalid'
|
||||
assert.equal(parseArguments(['--environment', 'gray', '--modules', 'phase5-root-fulfillment']).gateway,
|
||||
'https://gray.example.invalid')
|
||||
@@ -61,6 +64,22 @@ test('gray has no fallback to TEST account, gateway, customer or PDA environment
|
||||
}
|
||||
})
|
||||
|
||||
test('gray missing fixed identity or customer credentials fails without network; both transports forbid customer creation', async () => {
|
||||
const original = globalThis.fetch
|
||||
globalThis.fetch = () => assert.fail('missing configuration and customer writes must stop before HTTP')
|
||||
try {
|
||||
for (const field of ['fixedCustomerId', 'merchantUsername', 'merchantPassword']) {
|
||||
const options = parseArguments(args); options[field] = ''
|
||||
assert.throws(() => validateExecutionOptions(options), /禁止自动创建客户/)
|
||||
}
|
||||
const runner = new AcceptanceRun(validateExecutionOptions(parseArguments(args)))
|
||||
for (const entry of ['request', 'requestWithBody']) {
|
||||
for (const path of ['/api/platform/v1/iam/tenants', '/api/auth/register', '/api/platform/v1/iam/tenants/123/submit-review'])
|
||||
await assert.rejects(runner[entry]('POST', path, {}), /GRAY.*禁止创建/)
|
||||
}
|
||||
} finally { globalThis.fetch = original }
|
||||
})
|
||||
|
||||
test('gray evidence preflight attaches only read-only readers, never constructs fault executors', async () => {
|
||||
const run = new AcceptanceRun(validateExecutionOptions(parseArguments(args)))
|
||||
const readReceiving = () => {}, readCompletion = () => {}
|
||||
|
||||
Reference in New Issue
Block a user