test(fleet): isolate recovery actor phone generation
This commit is contained in:
@@ -116,7 +116,7 @@ test('changed source report SHA blocks recovery before creating context or loggi
|
||||
rmSync(temporary, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
import { parseFleetArguments, fleetExecutionPlan, runFleetAcceptance, reviewedFullCheckpoint, verifyFleetTerminalState, runFleetHandoverStage, fleetCostShares, prepareFleetCostActors, guardFleetWrites, redactFleetWrite, verifyDepartedRecovery, continueReviewedDeparture, completeDepartedFleetScenario } from './fleet-test-env-acceptance.mjs'
|
||||
import { parseFleetArguments, fleetExecutionPlan, runFleetAcceptance, reviewedFullCheckpoint, verifyFleetTerminalState, runFleetHandoverStage, fleetCostShares, prepareFleetCostActors, findFleetActorPhone, guardFleetWrites, redactFleetWrite, verifyDepartedRecovery, continueReviewedDeparture, completeDepartedFleetScenario } from './fleet-test-env-acceptance.mjs'
|
||||
|
||||
for (const response of [
|
||||
{ http: 0 }, { http: 503, body: { code: 'A0500' }, requestId: 'r', traceId: 't' },
|
||||
@@ -357,6 +357,8 @@ for (const failLogin of [false, true]) test(`cost actors create exact isolated r
|
||||
const context = { marker: 'RUN', token: 'admin-secret', createdResources: {}, async findAvailablePhone() { return '19900000000' },
|
||||
async checkpoint() { saved.push(structuredClone(context.createdResources)) },
|
||||
async request(method, path, body, token) {
|
||||
if (method === 'GET' && (path.startsWith('/api/platform/v1/iam/users?') || path.includes('/administrator-phone-availability?')))
|
||||
return { http: 200, body: { code: '200', data: path.includes('/administrator-phone-availability?') ? true : { records: [], total: 0 } }, requestId: 'r', traceId: 't' }
|
||||
const pending = saved.at(-1).fleetCostActors.requests.at(-1)
|
||||
assert.equal(pending.status, 'SENDING'); assert.equal(pending.path, path)
|
||||
calls.push({ method, path, body, token })
|
||||
@@ -388,6 +390,30 @@ for (const failLogin of [false, true]) test(`cost actors create exact isolated r
|
||||
assert.ok(!calls.some(row => row.method === 'DELETE'))
|
||||
})
|
||||
|
||||
test('fresh cost actor phones avoid existing platform users and use an independent namespace under the same original marker', async () => {
|
||||
const phones = [], ctx = { marker: 'ORIGINAL-RUN', async request(method, path) {
|
||||
assert.equal(method, 'GET')
|
||||
let data
|
||||
if (path.includes('/users?')) {
|
||||
const phone = new URL('https://test.invalid' + path).searchParams.get('keyword'); phones.push(phone)
|
||||
data = { records: phones.length === 1 ? [{ phone }] : [], total: phones.length === 1 ? 1 : 0 }
|
||||
} else data = true
|
||||
return { http: 200, body: { code: '200', data }, requestId: 'r', traceId: 't' }
|
||||
} }
|
||||
const first = await findFleetActorPhone(ctx, 'a'.repeat(16))
|
||||
assert.notEqual(first, phones[0]); assert.match(first, /^18\d{9}$/)
|
||||
const second = await findFleetActorPhone(ctx, 'b'.repeat(16))
|
||||
assert.notEqual(first, second)
|
||||
})
|
||||
|
||||
test('phone lookup failure stops without any user creation or guessing', async () => {
|
||||
let calls = 0
|
||||
await assert.rejects(findFleetActorPhone({ marker: 'RUN', async request(method) {
|
||||
assert.equal(method, 'GET'); calls++; return { http: 0 }
|
||||
} }, 'a'.repeat(16)), /Cannot verify/)
|
||||
assert.equal(calls, 1)
|
||||
})
|
||||
|
||||
test('main chain performs handover after actual DEPART and before receipts, and cleanup follows current-resource closure', async () => {
|
||||
const source = readFileSync(new URL('./fleet-test-env-acceptance.mjs', import.meta.url), 'utf8')
|
||||
const savedDeparture = source.indexOf('proof.departure = departed'), handover = source.indexOf("stage('IN_TRANSIT_HANDOVER')")
|
||||
|
||||
Reference in New Issue
Block a user