优化
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { readFileSync, mkdtempSync, mkdirSync, rmSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { createFleetPoolGrayOptions, parseArguments } from './admin-test-env-acceptance.mjs'
|
||||
import { parsePoolArguments, poolPlan, runPoolAcceptance, assertPoolRemaining, assertSingleCommercial,
|
||||
shrinkingVehicleRequest, expiryWaitMs, poolLocalDateTime, poolPickScope, pickPoolDispatch, POOL_COVERAGE, POOL_REMAINING,
|
||||
poolInquiryWrite, poolReadIsDenied, assertPoolBoundCapacity, verifyPoolConfirmedCancellation, verifyPoolBindingRevalidation,
|
||||
@@ -315,3 +318,35 @@ test('pool execution explicitly selects capacity verification before handing off
|
||||
} }), /STOP_BEFORE_ENVIRONMENT_ACCESS/)
|
||||
assert.equal(selected, 'CAPACITY_POOL')
|
||||
})
|
||||
|
||||
test('TEST and GRAY pool reuse configured customer credentials without a creation response and reject unrelated fixture customers', async () => {
|
||||
const original = globalThis.fetch
|
||||
globalThis.fetch = async () => assert.fail('credential handoff must not need customer creation or HTTP')
|
||||
const root = mkdtempSync(join(tmpdir(), 'pool-fixed-customer-contract-'))
|
||||
try {
|
||||
for (const environment of ['TEST', 'GRAY']) {
|
||||
const config = { execute: true, environment, runId: 'existing-customers', warehouseId: '10', destinationWarehouseId: '11' }
|
||||
const transport = { gateway: 'https://gray.example.invalid', username: 'admin', password: 'offline-admin',
|
||||
output: 'reports/unused', markerNamespace: 'offline', fixedCustomerId: 'TEN100', merchantUsername: 'existing-a',
|
||||
merchantPassword: 'offline-a', fixedSecondaryCustomer: { customerId: 'TEN101', username: 'existing-b', password: 'offline-b' },
|
||||
fixedActors: Object.fromEntries(['pool.sales.0', 'pool.sales.1', 'pool.dispatch.0', 'pool.dispatch.1', 'pool.fulfillment.0'].map((slot, index) =>
|
||||
[slot, { membershipId: String(500 + index), roleId: '600', roleCode: 'FIXED_OFFLINE', username: `fixed-${index}`, password: 'offline-password' }])) }
|
||||
const options = environment === 'GRAY' ? createFleetPoolGrayOptions(transport)
|
||||
: { ...parseArguments(['--modules', 'merchant-qualification-fixture']), ...transport, environment: 'test' }
|
||||
const directory = environment === 'GRAY' ? 'fleet-pool-gray-existing-customers' : 'fleet-cross-existing-customers'
|
||||
mkdirSync(join(root, 'reports', directory), { recursive: true })
|
||||
await assert.rejects(runPoolAcceptance(config, { outputRoot: root, runner: async (_config, dependencies) => {
|
||||
const context = dependencies.contextFactory(options)
|
||||
const fixture = { members: [{ customerId: '100' }, { customerId: '101' }] }
|
||||
assert.equal((await dependencies.verify(context, fixture, { execute: false })).execute, false)
|
||||
for (const invalid of [{ members: [{ customerId: '100' }, { customerId: '999' }] }, { members: [{ customerId: '100' }] },
|
||||
{ members: [{ customerId: '100' }, { customerId: '100' }] }])
|
||||
assert.throws(() => dependencies.verify(context, invalid, { execute: true }), /CURRENT_FIXED_POOL_CUSTOMER_CREDENTIALS_REQUIRED/)
|
||||
throw Error('STOP_AFTER_CREDENTIAL_HANDOFF')
|
||||
} }), /STOP_AFTER_CREDENTIAL_HANDOFF/)
|
||||
}
|
||||
} finally {
|
||||
globalThis.fetch = original
|
||||
rmSync(root, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user