完成单机TEST统一入口与可靠投递回归收尾

This commit is contained in:
2026-09-29 19:48:34 +08:00
parent 64a70c9f28
commit 6c0a026cc4
89 changed files with 968 additions and 983 deletions
@@ -45,28 +45,15 @@ test('overseas inbound commands, client services and dispatch follow completed P
}
})
test('entry accepts a separate overseas Gateway without exposing token state', () => {
const options = parseArguments([
'--gateway', 'http://localhost:9000/',
'--overseas-gateway', 'http://localhost:9300/',
'--modules', 'phase4-overseas-warehouse',
])
test('entry uses one TEST gateway and rejects retired regional options', () => {
const options = parseArguments(['--gateway', 'http://localhost:9000/', '--modules', 'phase4-overseas-warehouse'])
assert.equal(options.gateway, 'http://localhost:9000')
assert.equal(options.overseasGateway, 'http://localhost:9300')
assert.match(source, /this\.overseasToken = login\.overseasAccessToken \|\| ''/)
assert.match(source, /this\.refreshToken = login\.refreshToken \|\| ''/)
assert.match(source, /this\.overseasExpiresAt = Number\(login\.overseasExpiresIn\)/)
assert.match(source, /async refreshSession\(reason\)/)
assert.match(source, /refreshToken: this\.refreshToken/)
assert.match(source, /const replacement = \{[\s\S]*token: next\.accessToken[\s\S]*refreshToken: next\.refreshToken[\s\S]*overseasToken: next\.overseasAccessToken/)
assert.match(source, /module === 'system' && laterOverseasModule/)
assert.match(source, /system后新admin海外Token只读探针可用/)
assert.match(source, /module\.startsWith\('phase4-overseas-'\)[\s\S]*Date\.now\(\) \+ 120_000 >= this\.overseasExpiresAt/)
assert.match(source, /海外模块 \$\{module\} 执行前Token临近到期/)
assert.match(source, /async requestOverseas\(/)
assert.match(source, /async requestOverseasBinary\(/)
assert.match(source, /async requestOverseasMultipart\(/)
assert.match(source, /forbiddenValues = \[this\.options\.password, this\.options\.merchantPassword,[\s\S]*this\.token, this\.refreshToken, this\.overseasToken\]/)
assert.equal(options.environment, 'test')
assert.throws(() => parseArguments(['--overseas-gateway', 'http://localhost:9300']), /one TEST gateway/)
assert.throws(() => parseArguments(['--environment', 'cn']), /TEST|test/)
assert.doesNotMatch(source, /async requestOverseas|this\.overseasToken|overseasAccessToken/)
assert.match(source, /this\.refreshToken = login\.refreshToken/)
assert.match(source, /system后新admin统一Token只读探针可用/)
})
test('overseas business keeps its marker-scoped customer fixture with reusable credentials configured', () => {
@@ -96,32 +83,31 @@ test('a fixed origin route does not require randomized order fixtures', () => {
assert.match(source, /this\.context\.allowAnyExistingPallet = true/)
})
test('dual-token refresh replaces the whole session only after a complete response', async () => {
const run = new AcceptanceRun({ gateway: 'http://localhost:9000', overseasGateway: 'http://localhost:9300',
test('unified-session refresh replaces the whole session only after a complete response', async () => {
const run = new AcceptanceRun({ gateway: 'http://localhost:9000',
username: 'contract-user', password: 'contract-password', modules: [], output: '' })
Object.assign(run, { token: 'old-access', refreshToken: 'old-refresh', overseasToken: 'old-overseas', overseasExpiresAt: 1 })
Object.assign(run, { token: 'old-access', refreshToken: 'old-refresh', expiresAt: 1 })
run.request = async (method, path, body, token) => {
assert.equal(method, 'POST'); assert.equal(path, '/api/auth/refresh')
assert.deepEqual(body, { refreshToken: 'old-refresh' }); assert.equal(token, '')
return { method, path, http: 200, body: { code: '200', data: {
accessToken: 'new-access', refreshToken: 'new-refresh', overseasAccessToken: 'new-overseas',
overseasExpiresIn: 900,
accessToken: 'new-access', refreshToken: 'new-refresh',
expiresIn: 900,
} }, requestId: 'refresh-request', traceId: 'refresh-trace' }
}
assert.equal(await run.refreshSession('contract'), true)
assert.equal(run.token, 'new-access')
assert.equal(run.refreshToken, 'new-refresh')
assert.equal(run.overseasToken, 'new-overseas')
assert.ok(run.overseasExpiresAt > Date.now())
assert.ok(run.expiresAt > Date.now())
const frozen = { token: run.token, refreshToken: run.refreshToken,
overseasToken: run.overseasToken, overseasExpiresAt: run.overseasExpiresAt }
expiresAt: run.expiresAt }
run.request = async (method, path) => ({ method, path, http: 200,
body: { code: '200', data: { accessToken: 'partial-only' } },
requestId: 'partial-request', traceId: 'partial-trace' })
assert.equal(await run.refreshSession('incomplete-contract'), false)
assert.deepEqual({ token: run.token, refreshToken: run.refreshToken,
overseasToken: run.overseasToken, overseasExpiresAt: run.overseasExpiresAt }, frozen)
expiresAt: run.expiresAt }, frozen)
})
test('entry has no built-in environment address or password and requires explicit execution options', () => {
@@ -129,7 +115,7 @@ test('entry has no built-in environment address or password and requires explici
assert.throws(() => validateExecutionOptions(parseArguments(['--modules', 'phase4-overseas-pda'])),
/缺少必填执行参数/)
const options = parseArguments([
'--gateway', 'http://localhost:9000', '--overseas-gateway', 'http://localhost:9300',
'--gateway', 'http://localhost:9000',
'--username', 'contract-user', '--password', 'contract-password', '--modules', 'phase4-overseas-pda',
'--pda-username', 'contract-picker', '--pda-password', 'contract-picker-password',
])
@@ -139,7 +125,7 @@ test('entry has no built-in environment address or password and requires explici
test('loading dependency chains require PDA credentials before making any HTTP requests', () => {
for (const module of ['phase3-loading', 'phase3-container-loading', 'phase5-overseas-fulfillment']) {
const options = parseArguments(['--gateway', 'http://localhost:9000',
'--overseas-gateway', 'http://localhost:9300', '--username', 'admin', '--password', 'fixture',
'--username', 'admin', '--password', 'fixture',
'--modules', module])
options.pdaUsername = ''
options.pdaPassword = ''
@@ -152,7 +138,7 @@ test('loading dependency chains require PDA credentials before making any HTTP r
})
test('core coverage gaps fail closed while device and external-provider gaps remain report-only', () => {
const run = new AcceptanceRun({ gateway: 'http://localhost:9000', overseasGateway: 'http://localhost:9300',
const run = new AcceptanceRun({ gateway: 'http://localhost:9000',
username: 'contract-user', password: 'contract-password', modules: [], output: '' })
run.addCoverageGap('phase4', 'core', 'fixture', 'missing fixture', 'fixture')
assert.equal(run.steps.at(-1)?.passed, false)