2026-08-13 18:34:44 +08:00
|
|
|
import assert from 'node:assert/strict'
|
|
|
|
|
import { readFile } from 'node:fs/promises'
|
|
|
|
|
import test from 'node:test'
|
|
|
|
|
|
|
|
|
|
const read = async (path) => (await readFile(new URL(`../${path}`, import.meta.url), 'utf8'))
|
|
|
|
|
.replaceAll('\r\n', '\n')
|
|
|
|
|
|
|
|
|
|
test('基础 Compose 显式配置审计服务地址,避免静默退化为日志输出', async () => {
|
|
|
|
|
const compose = await read('deploy/docker-compose.yml')
|
|
|
|
|
|
|
|
|
|
assert.match(compose,
|
2026-09-29 18:47:37 +08:00
|
|
|
/BAIYUE_AUDIT_ENDPOINT: http:\/\/audit-service:9700\/internal\/audit\/events/)
|
2026-08-13 18:34:44 +08:00
|
|
|
assert.doesNotMatch(compose, /^\s+AUDIT_SERVICE_URL:/m)
|
|
|
|
|
assert.match(compose, /^ audit-service:\s*$/m)
|
2026-10-07 11:02:47 +08:00
|
|
|
assert.match(compose, /container_name: firstleg-\$\{DEPLOY_ENV:-test\}-audit/)
|
2026-08-13 18:34:44 +08:00
|
|
|
assert.match(compose, /networks: \[firstleg-network, infra-network\]/)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('可靠审计仍由独立 Compose 显式启用,不强制基础环境依赖 RocketMQ', async () => {
|
|
|
|
|
const baseCompose = await read('deploy/docker-compose.yml')
|
|
|
|
|
const reliableCompose = await read('deploy/docker-compose.audit.yml')
|
|
|
|
|
|
|
|
|
|
assert.match(baseCompose, /AUDIT_OUTBOX_ENABLED: \$\{AUDIT_OUTBOX_ENABLED:-false\}/)
|
|
|
|
|
assert.match(reliableCompose, /AUDIT_OUTBOX_ENABLED: "true"/)
|
|
|
|
|
assert.match(reliableCompose, /AUDIT_MQ_CONSUMER_ENABLED: "true"/)
|
|
|
|
|
})
|