整改基线:封存公网端口分离与远程后端回归候选
This commit is contained in:
1 parent
89e5d6c0c8
commit
6683f1cf9f
23 files changed
+338
-43
No files matched your search
@@ -13,6 +13,26 @@ const { readFormConfig, getFieldGroups, updateFormConfig, validateFormConfig } =
|
||||
'\nreturn { readFormConfig, getFieldGroups, updateFormConfig, validateFormConfig }'
|
||||
)()
|
||||
|
||||
test('公网 HTTPS 端口独立编辑且保留内部监听与模式切换', () => {
|
||||
const config = {
|
||||
domains: { primary: 'example.com', web: 'mail.example.com', accepted: ['example.com'] },
|
||||
http: { port: 8001, httpsPort: 8002, httpsEnabled: true, tlsMode: 'direct' }
|
||||
}
|
||||
const updated = readFormConfig(updateFormConfig(JSON.stringify(config), 'base', ['http', 'publicHttpsPort'], 443))
|
||||
assert.equal(updated.http.publicHttpsPort, 443)
|
||||
assert.equal(updated.http.httpsPort, 8002)
|
||||
assert.equal(updated.http.port, 8001)
|
||||
assert.deepEqual(validateFormConfig('base', updated), {})
|
||||
const proxy = readFormConfig(updateFormConfig(JSON.stringify(updated), 'base', ['http', 'tlsMode'], 'proxy'))
|
||||
assert.equal(proxy.http.publicHttpsPort, 443)
|
||||
for (const value of [-1, 65536, 1.5, '443']) {
|
||||
updated.http.publicHttpsPort = value
|
||||
assert.ok(validateFormConfig('base', updated)['http.publicHttpsPort'])
|
||||
}
|
||||
updated.http.publicHttpsPort = 0
|
||||
assert.deepEqual(validateFormConfig('base', updated), {})
|
||||
})
|
||||
|
||||
test('基础配置不再展示冗余安全选项与开关,通行密钥由系统默认解析,用户权限仍由账号设置管理', () => {
|
||||
const config = { domains: { web: 'mail.old.com' }, security: { webAuthnEnabled: false, externalEmailEnabled: false, webAuthnRpId: 'mail.old.com' } }
|
||||
const groups = getFieldGroups('base', config)
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { compileFunction } from 'node:vm'
|
||||
|
||||
const source = readFileSync(new URL('../../frontend/src/views/Setup/SetupNavigation.js', import.meta.url), 'utf8')
|
||||
const { buildFinalURL } = compileFunction(
|
||||
source.replaceAll('export const ', 'const ') + '\nreturn { buildFinalURL }'
|
||||
)()
|
||||
|
||||
test('初始化完成跳转优先使用公网端口,保持路径和页面状态', () => {
|
||||
const location = new URL('https://mail.example.com/setup?step=ssl#/finish')
|
||||
for (const tlsMode of ['direct', 'proxy']) {
|
||||
assert.equal(buildFinalURL({ tlsMode, httpsPort: 8002, publicHttpsPort: 443 }, 'mail.example.com', location),
|
||||
'https://mail.example.com/setup?step=ssl#/finish')
|
||||
assert.equal(buildFinalURL({ tlsMode, httpsPort: 8002, publicHttpsPort: 9443 }, 'mail.example.com', location),
|
||||
'https://mail.example.com:9443/setup?step=ssl#/finish')
|
||||
}
|
||||
})
|
||||
|
||||
test('没有公网配置时保留直连和旧反代跳转行为', () => {
|
||||
const location = new URL('https://mail.example.com/')
|
||||
assert.equal(buildFinalURL({ tlsMode: 'direct', httpsPort: 8443 }, 'mail.example.com', location),
|
||||
'https://mail.example.com:8443/')
|
||||
assert.equal(buildFinalURL({ tlsMode: 'proxy', httpsPort: 8002 }, 'mail.example.com', location),
|
||||
'https://mail.example.com/')
|
||||
})
|
||||
Reference in new issue
Block a user