29 lines
2.0 KiB
JavaScript
29 lines
2.0 KiB
JavaScript
import test from 'node:test'
|
|||
|
|
import assert from 'node:assert/strict'
|
||
|
|
import { resolve } from 'node:path'
|
||
|
|
import { customerProfilePath, compareCustomerTemplates, execute } from './client-import-template-test-env.mjs'
|
||
|
|
|
||
|
|
const directory = 'C:/Users/BY-OY/.codex/env/chongchong-global'
|
||
|
|
test('template plan performs no login and requires no runtime', async () => {
|
||
|
|
assert.equal((await execute(['--plan'], [], {})).plan, true)
|
||
|
|
})
|
||
|
|
test('cross-customer read evidence rejects same identity, leaked options and incomplete cleanup', () => {
|
||
|
|
const report = (id, privateCount) => ({ success: true, sessionClosed: true, customerIdentitySha256: id,
|
||
|
|
template: { checks: { '私人目的仓地址': { actualCount: privateCount, passed: true }, '取货地址': { actualSha256: id, passed: true } } } })
|
||
|
|
const primary = report('customer-A', 1), control = report('customer-B', 0)
|
||
|
|
assert.equal(compareCustomerTemplates(primary, control).success, true)
|
||
|
|
assert.equal(compareCustomerTemplates(primary, primary).success, false)
|
||
|
|
assert.equal(compareCustomerTemplates(primary, report('customer-B', 1)).success, false)
|
||
|
|
assert.equal(compareCustomerTemplates(primary, { ...control, sessionClosed: false }).success, false)
|
||
|
|
const failed = report('customer-B', 0); failed.template.checks['私人目的仓地址'].passed = false
|
||
|
|
assert.equal(compareCustomerTemplates(primary, failed).success, false)
|
||
|
|
})
|
||
|
|
test('explicit existing TEST UI customer profile cannot select production or escape the authorized directory', () => {
|
||
|
|
const argument = `--customer-profile=${directory}/test-ui-fixture.env`
|
||
|
|
assert.equal(customerProfilePath(argument, directory + '/test-acceptance.env'), resolve(directory, 'test-ui-fixture.env'))
|
||
|
|
for (const value of ['prod-acceptance.env', '../test-ui-fixture.env', 'test-database.env', 'test-ui-fixture.env/another.env']) {
|
||
|
|
assert.throws(() => customerProfilePath(`--customer-profile=${directory}/${value}`, directory + '/test-acceptance.env'))
|
||
|
|
}
|
||
|
|
assert.throws(() => customerProfilePath('--unknown=file', directory + '/test-acceptance.env'))
|
||
|
|
})
|