1 parent
82f7b630e4
commit
b1ab163a75
3 files changed
+7
-5
No files matched your search
@@ -116,20 +116,23 @@ test('单字段更新完整保留内部数据,锁定字段和污染路径无
|
||||
assert.equal({}.polluted, undefined)
|
||||
})
|
||||
|
||||
test('基础配置隐藏代理网段和数据库只读信息,不留下空分组且保留内部值', () => {
|
||||
test('基础配置隐藏额外访问主机、代理网段和数据库只读信息,保留内部值且无空分组', () => {
|
||||
for (const type of ['sqlite', 'mysql', 'postgresql']) {
|
||||
for (const tlsMode of ['direct', 'proxy']) {
|
||||
const config = {
|
||||
database: { type, localRef: 'preserved.db', name: 'smail', host: 'db.example.com', port: type === 'postgresql' ? 5432 : 3306, username: 'smail', password: null },
|
||||
domains: { primary: 'example.com', web: 'mail.example.com', accepted: ['example.com'], accessHosts: ['alternate.example.com', '192.0.2.10'] },
|
||||
http: { tlsMode, port: 8080, trustedProxyCidrs: ['127.0.0.1/32', '192.0.2.10/32'] },
|
||||
security: { externalEmailEnabled: false, webAuthnEnabled: false }
|
||||
}
|
||||
const text = JSON.stringify(config)
|
||||
const groups = getFieldGroups('base', config)
|
||||
const keys = groups.flatMap(item => item.fields.map(input => input.path.join('.')))
|
||||
const hidden = ['database.type', 'database.localRef', 'http.trustedProxyCidrs']
|
||||
const hidden = ['database.type', 'database.localRef', 'http.trustedProxyCidrs', 'domains.accessHosts']
|
||||
assert.ok(groups.every(item => item.fields.length > 0))
|
||||
assert.ok(hidden.every(key => !keys.includes(key)))
|
||||
assert.doesNotMatch(JSON.stringify(groups), /额外允许的访问主机|按需填写域名或 IP 地址/)
|
||||
assert.ok(keys.includes('domains.accepted'))
|
||||
assert.equal(groups.some(item => item.id === 'database'), type !== 'sqlite')
|
||||
for (const key of hidden) {
|
||||
assert.equal(updateFormConfig(text, 'base', key.split('.'), 'changed'), text)
|
||||
|
||||
@@ -627,10 +627,10 @@ test('SQLite 不显示或发送密码,网络数据库和中继密码留空保
|
||||
assert.equal(request.secretChanges['relay.password'].value.plaintext, ' smtp-test-only ')
|
||||
})
|
||||
|
||||
test('基础配置保存完整保留隐藏的数据库和代理信任配置', async () => {
|
||||
test('基础配置保存完整保留隐藏的额外访问主机、数据库和代理信任配置', async () => {
|
||||
const config = {
|
||||
database: { type: 'sqlite', localRef: 'preserved.db' },
|
||||
domains: { primary: 'example.com', web: 'mail.example.com', accepted: ['example.com'] },
|
||||
domains: { primary: 'example.com', web: 'mail.example.com', accepted: ['example.com'], accessHosts: ['alternate.example.com', '192.0.2.10'] },
|
||||
http: { tlsMode: 'proxy', port: 8080, httpsEnabled: false, trustedProxyCidrs: ['127.0.0.1/32', '192.0.2.10/32'] },
|
||||
security: { externalEmailEnabled: false, webAuthnEnabled: false }
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user