优化
This commit is contained in:
@@ -1,7 +1,37 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
import { pickerFixtureSuffix, createPicker, disablePicker, pickerSessionHandoff } from './phase4-overseas-pda.mjs'
|
||||
import { pickerFixtureSuffix, createPicker, disablePicker, pickerSessionHandoff, restoreFixedPicker } from './phase4-overseas-pda.mjs'
|
||||
import { verifyPdaWarehouseRevocation } from './unified-pda-session-revocation.mjs'
|
||||
import { AcceptanceRun } from '../admin-test-env-acceptance.mjs'
|
||||
|
||||
test('child workflows share PDA leases and recovery reuses the saved membership without enabling or recreating an account', async () => {
|
||||
const actors = ['11', '12'].map(membershipId => ({ membershipId, warehouseId: '91', username: `test-${membershipId}`, password: 'fixture-only' }))
|
||||
const context = new AcceptanceRun({ environment: 'test', fixedCustomerId: '101', fixedPdaActors: actors }), calls = []
|
||||
context.request = async (method, path, body) => {
|
||||
calls.push({ method, path })
|
||||
let data = {}
|
||||
if (path.includes('/iam/users?')) {
|
||||
assert.equal(new URL(path, 'https://fixture.invalid').searchParams.has('keyword'), false)
|
||||
data = { page: 1, size: 100, total: 2, records: actors.map(actor => ({ ...actor, overseasWarehouseId: '91', tenantId: '0', status: 'ACTIVE', roleIds: ['7'] })) }
|
||||
}
|
||||
if (path === '/api/auth/login') data = { accessToken: body.loginId, refreshToken: `refresh-${body.loginId}` }
|
||||
return { http: 200, body: { code: '200', data } }
|
||||
}
|
||||
const full = await createPicker(Object.create(context), 161, '91', { role: { id: '7' } })
|
||||
const partial = await createPicker(Object.create(context), 71, '91', { role: { id: '7' } })
|
||||
assert.notEqual(full.membershipId, partial.membershipId)
|
||||
await disablePicker(context, full, 161)
|
||||
await disablePicker(context, partial, 71)
|
||||
const restored = await restoreFixedPicker(context, { membershipId: '12', username: 'test-12' }, 71, '91', { role: { id: '7' } })
|
||||
assert.equal(restored.membershipId, '12')
|
||||
await disablePicker(context, restored, 71)
|
||||
assert.equal(calls.filter(call => call.path === '/api/auth/logout').length, 3)
|
||||
assert.equal(context.fixedPdaLeases.size, 0)
|
||||
assert.ok(calls.every(call => call.method === 'GET' || ['/api/auth/login', '/api/auth/logout'].includes(call.path)))
|
||||
const before = calls.length
|
||||
await assert.rejects(restoreFixedPicker(context, { membershipId: '999', username: 'foreign' }, 71, '91', { role: { id: '7' } }), /禁止推算临时账号/)
|
||||
assert.equal(calls.length, before)
|
||||
})
|
||||
|
||||
test('fixed PDA actors are leased separately and only logged out, never modified', async () => {
|
||||
const actors = ['11', '12'].map(membershipId => ({ membershipId, warehouseId: '91', username: `test-${membershipId}`, password: 'fixture-only' }))
|
||||
|
||||
Reference in New Issue
Block a user