diff --git a/scripts/admin-test-env-modules/container-detail-route-contract.test.mjs b/scripts/admin-test-env-modules/container-detail-route-contract.test.mjs new file mode 100644 index 000000000..033dba88f --- /dev/null +++ b/scripts/admin-test-env-modules/container-detail-route-contract.test.mjs @@ -0,0 +1,20 @@ +import assert from 'node:assert/strict' +import { readFileSync } from 'node:fs' +import test from 'node:test' + +const read = (name) => readFileSync(new URL(name, import.meta.url), 'utf8') + +test('domestic container fixtures use the current workbench detail route', () => { + const containerLoading = read('./phase3-container-loading.mjs') + assert.ok(containerLoading.includes("context.request('GET', `${CONTAINERS}/domestic/${containerId}`)")) + assert.ok(!containerLoading.includes("context.request('GET', `${CONTAINERS}/${containerId}`)")) + + const loading = read('./phase3-loading.mjs') + assert.ok(loading.includes("context.request('GET', `/api/platform/v1/containers/domestic/${containerBookingId}`)")) + assert.ok(!loading.includes("context.request('GET', `/api/platform/v1/containers/${containerBookingId}`)")) + + const crossRegion = read('./phase4-cross-region-events.mjs') + const fixtureId = 'encodeURIComponent(id(phase3.containerBookingId))' + assert.ok(crossRegion.includes(`/api/platform/v1/containers/domestic/\${${fixtureId}}`)) + assert.ok(!crossRegion.includes(`/api/platform/v1/containers/\${${fixtureId}}`)) +}) diff --git a/scripts/admin-test-env-modules/container-simulation-association-contract.test.mjs b/scripts/admin-test-env-modules/container-simulation-association-contract.test.mjs index aba78fffd..2c6c9cb2d 100644 --- a/scripts/admin-test-env-modules/container-simulation-association-contract.test.mjs +++ b/scripts/admin-test-env-modules/container-simulation-association-contract.test.mjs @@ -36,6 +36,8 @@ test('port link mutates the simulation through the frozen four-field request', ( }) test('HTTP fixture keeps simulation and plan identities and creates allocation at link', () => { + assert.ok(fixture.includes("context.request('GET', `${CONTAINERS}/domestic/${containerId}`)")) + assert.ok(!fixture.includes("context.request('GET', `${CONTAINERS}/${containerId}`)")) assert.match(fixture, /关联前后内部柜次、计划和排货明细身份稳定/) assert.match(fixture, /订舱 allocation 原子创建并指向稳定模拟柜身份/) assert.match(fixture, /已消费订舱需求拒绝再次关联/) diff --git a/scripts/admin-test-env-modules/phase3-container-loading.mjs b/scripts/admin-test-env-modules/phase3-container-loading.mjs index 6c225e2f7..263364c34 100644 --- a/scripts/admin-test-env-modules/phase3-container-loading.mjs +++ b/scripts/admin-test-env-modules/phase3-container-loading.mjs @@ -258,7 +258,7 @@ export async function run(context) { } } - const containerDetailResponse = await context.request('GET', `${CONTAINERS}/${containerId}`) + const containerDetailResponse = await context.request('GET', `${CONTAINERS}/domestic/${containerId}`) const containerDetail = context.apiSuccess(MODULE, '回查货柜详情', containerDetailResponse, '', OPTIONS) context.assert(MODULE, '货柜详情保留候选货物路线约束', containerDetailResponse, (!containerDetail?.destinationWarehouseCode || !candidate.destinationWarehouseCode @@ -398,7 +398,7 @@ export async function run(context) { unlinkedTaskAbsent, responseEvidence(unlinkedTaskResponse), OPTIONS) if (!unlinkedTaskAbsent) return - const simulationBeforeLinkResponse = await context.request('GET', `${CONTAINERS}/${containerId}`) + const simulationBeforeLinkResponse = await context.request('GET', `${CONTAINERS}/domestic/${containerId}`) const simulationBeforeLink = context.apiSuccess(MODULE, '预装确认前读取模拟柜最新版本', simulationBeforeLinkResponse, '', OPTIONS) if (!Number.isInteger(Number(simulationBeforeLink?.version))) return @@ -589,7 +589,7 @@ export async function run(context) { `taskId=${taskId || 'missing'}, itemId=${id(pickItem?.id) || 'missing'}`, OPTIONS) if (!taskId || !pickItem?.id) return - const releasedContainerResponse = await context.request('GET', `${CONTAINERS}/${containerId}`) + const releasedContainerResponse = await context.request('GET', `${CONTAINERS}/domestic/${containerId}`) const releasedContainer = context.apiSuccess(MODULE, '任务生成后回查货柜运输版本', releasedContainerResponse, '', OPTIONS) const stableIdentity = { diff --git a/scripts/admin-test-env-modules/phase3-loading.mjs b/scripts/admin-test-env-modules/phase3-loading.mjs index bf4cce2c6..7a0653e84 100644 --- a/scripts/admin-test-env-modules/phase3-loading.mjs +++ b/scripts/admin-test-env-modules/phase3-loading.mjs @@ -506,7 +506,7 @@ export async function run(context) { && Boolean(requirement?.id) && (!bookingConfirmed?.containers || bookingConfirmed.containers.length === 0), `bookingId=${bookingId || 'missing'}, status=${bookingConfirmed?.oceanBooking?.status || 'missing'}`, OPTIONS) if (!bookingId || !requirement?.id || !frozenTransportMatches) return - const latestContainerResponse = await context.request('GET', `/api/platform/v1/containers/${containerBookingId}`) + const latestContainerResponse = await context.request('GET', `/api/platform/v1/containers/domestic/${containerBookingId}`) const latestContainer = context.apiSuccess(MODULE, '合并前读取模拟柜最新版本', latestContainerResponse, '', OPTIONS) const linkResponse = await request(context, 'POST', `/api/platform/v1/containers/${containerBookingId}/ocean-booking-link`, { oceanBookingId: bookingId, requirementId: id(requirement.id), diff --git a/scripts/admin-test-env-modules/phase4-cross-region-events-contract.test.mjs b/scripts/admin-test-env-modules/phase4-cross-region-events-contract.test.mjs index d4cdf9d53..df7ba0d2e 100644 --- a/scripts/admin-test-env-modules/phase4-cross-region-events-contract.test.mjs +++ b/scripts/admin-test-env-modules/phase4-cross-region-events-contract.test.mjs @@ -8,6 +8,11 @@ import { run } from './phase4-cross-region-events.mjs' const source = readFileSync(new URL('./phase4-cross-region-events.mjs', import.meta.url), 'utf8') const system = readFileSync(new URL('./system.mjs', import.meta.url), 'utf8') +test('cross-region denial probes the current domestic container detail route', () => { + assert.ok(source.includes('/api/platform/v1/containers/domestic/${encodeURIComponent(id(phase3.containerBookingId))}')) + assert.ok(!source.includes('/api/platform/v1/containers/${encodeURIComponent(id(phase3.containerBookingId))}')) +}) + function response(path, data, http = 200, code = '200') { return { method: 'GET', path, http, body: { code, data }, requestId: 'request-1', traceId: 'trace-1' } } diff --git a/scripts/admin-test-env-modules/phase4-cross-region-events.mjs b/scripts/admin-test-env-modules/phase4-cross-region-events.mjs index 96eca9fc9..80301a4a9 100644 --- a/scripts/admin-test-env-modules/phase4-cross-region-events.mjs +++ b/scripts/admin-test-env-modules/phase4-cross-region-events.mjs @@ -51,7 +51,7 @@ export async function run(context) { } const overseasTokenAgainstDomestic = await context.request('GET', - `/api/platform/v1/containers/${encodeURIComponent(id(phase3.containerBookingId))}`, + `/api/platform/v1/containers/domestic/${encodeURIComponent(id(phase3.containerBookingId))}`, undefined, context.overseasToken) context.assert(MODULE, '海外Token不能访问国内Audience', overseasTokenAgainstDomestic, denied(overseasTokenAgainstDomestic) && traced(overseasTokenAgainstDomestic),