修复开发模式匿名恢复路由
This commit is contained in:
1 parent
fa78ee8a5d
commit
9bf59292b2
4 files changed
+55
-15
No files matched your search
@@ -30,16 +30,24 @@ test('前端构建必须自动同步 Go 嵌入资源', async () => {
|
||||
|
||||
test('前端入口按需加载 Element Plus,并延迟设置页和写信编辑器', async () => {
|
||||
const main = await read('frontend/src/main.js')
|
||||
const mainApp = await read('frontend/src/main-app.js')
|
||||
const vite = await read('frontend/vite.config.js')
|
||||
const header = await read('frontend/src/views/components/HomeHeader/HomeHeader.js')
|
||||
assert.doesNotMatch(main, /app\.use\(ElementPlus\)/)
|
||||
assert.doesNotMatch(main, /element-plus\/dist\/index\.css/)
|
||||
assert.match(main, /element-services\.css/)
|
||||
assert.match(main, /public-recovery\.js/)
|
||||
assert.match(mainApp, /element-services\.css/)
|
||||
assert.match(vite, /manualChunks\(id\)/)
|
||||
assert.match(header, /defineAsyncComponent/)
|
||||
assert.match(header, /import\('\.\.\/ConfigSettings\/ConfigSettings\.vue'\)/)
|
||||
})
|
||||
|
||||
test('开发服务器将匿名恢复入口和接口安全转发到后端', async () => {
|
||||
const vite = await read('frontend/vite.config.js')
|
||||
assert.match(vite, /"\/public-password-recovery": developmentBackendProxy\(backendUrl, backendOrigin\)/)
|
||||
assert.match(vite, /"\/rest\/api\/recovery": developmentBackendProxy\(backendUrl, publicRecoveryOrigin\)/)
|
||||
})
|
||||
|
||||
test('开发启动必须固定运行配置根目录并集中保存日志', async () => {
|
||||
const content = await read('deploy/start-dev.ps1')
|
||||
assert.match(content, /\$env:SMAIL_ROOT = \$runtime\r?\n/)
|
||||
|
||||
@@ -21,6 +21,7 @@ test('开发配置只从模拟部署目录读取且不返回凭据字段', async
|
||||
await writeFile(path.join(root, 'ssl/private.key'), 'key', { mode: 0o600 })
|
||||
const runtime = readDevelopmentRuntime(root)
|
||||
assert.equal(runtime.origin, 'https://mail.example.test')
|
||||
assert.equal(runtime.mailOrigin, 'https://mail.example.test')
|
||||
assert.equal(runtime.generation, 9)
|
||||
assert.equal(runtime.privateKeyPath, path.join(root, 'ssl/private.key'))
|
||||
assert.equal(JSON.stringify(runtime).includes('not-exported'), false)
|
||||
@@ -31,6 +32,26 @@ test('开发配置只从模拟部署目录读取且不返回凭据字段', async
|
||||
assert.throws(() => readDevelopmentRuntime(root), /事务尚未完成/)
|
||||
})
|
||||
|
||||
test('开发运行配置单独保留主邮件域名供匿名恢复接口校验', async () => {
|
||||
const root = await mkdtemp(path.join(os.tmpdir(), 'smail-runtime-recovery-domain-'))
|
||||
await mkdir(path.join(root, 'config'))
|
||||
await mkdir(path.join(root, 'ssl'))
|
||||
await writeFile(path.join(root, 'config/config.json'), JSON.stringify({
|
||||
generation: 5,
|
||||
domains: { web: 'web.example.test', primary: 'mail.example.test' }
|
||||
}))
|
||||
await writeFile(path.join(root, 'config/ssl.json'), JSON.stringify({
|
||||
meta: { generation: 5 },
|
||||
tls: { certificateRef: 'ssl/public.crt', privateKeyRef: 'ssl/private.key' }
|
||||
}))
|
||||
await writeFile(path.join(root, 'ssl/public.crt'), 'certificate')
|
||||
await writeFile(path.join(root, 'ssl/private.key'), 'key', { mode: 0o600 })
|
||||
|
||||
const runtime = readDevelopmentRuntime(root)
|
||||
assert.equal(runtime.origin, 'https://web.example.test')
|
||||
assert.equal(runtime.mailOrigin, 'https://mail.example.test')
|
||||
})
|
||||
|
||||
test('源码指纹检测编辑且忽略编译嵌入目录', async () => {
|
||||
const root = await mkdtemp(path.join(os.tmpdir(), 'smail-build-state-'))
|
||||
for (const name of ['backend', 'frontend', 'plugins/pmail_telegram_push', 'deploy']) {
|
||||
|
||||
Reference in new issue
Block a user