From b1ab163a75ddda2281e886b516a76c1f00f880b6 Mon Sep 17 00:00:00 2001 From: smail Date: Sun, 6 Sep 2026 15:59:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=9F=BA=E7=A1=80=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E9=A2=9D=E5=A4=96=E8=AE=BF=E9=97=AE=E4=B8=BB=E6=9C=BA?= =?UTF-8?q?=E8=A1=A8=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ConfigSettings/ConfigForm/ConfigForm.js | 1 - test/frontend/config-form.test.mjs | 7 +++++-- test/frontend/config-settings.test.mjs | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/src/views/components/ConfigSettings/ConfigForm/ConfigForm.js b/frontend/src/views/components/ConfigSettings/ConfigForm/ConfigForm.js index cba42da..220b4e9 100644 --- a/frontend/src/views/components/ConfigSettings/ConfigForm/ConfigForm.js +++ b/frontend/src/views/components/ConfigSettings/ConfigForm/ConfigForm.js @@ -80,7 +80,6 @@ const baseGroups = [ field('domains.primary', '主邮件域名', 'text', { required: true, placeholder: 'example.com' }), field('domains.web', '网页访问域名', 'text', { required: true, placeholder: 'mail.example.com' }), field('domains.accepted', '接收邮件的域名', 'list', { required: true, hint: '需包含主邮件域名,每个域名单独填写。', placeholder: 'example.com' }), - field('domains.accessHosts', '额外允许的访问主机', 'list', { hint: '按需填写域名或 IP 地址,不填写则保持默认访问范围。', placeholder: 'mail.example.com' }), field('logLevel', '日志级别', 'select', { options: options([['', '默认级别'], ['debug', '调试'], ['info', '信息'], ['warn', '警告'], ['error', '错误']]) }) ]), group('database', '数据库连接', '修改数据库类型、名称或文件请使用右侧“数据库迁移”,支持 SQLite、MySQL、PostgreSQL,避免切换到空数据库。', [ diff --git a/test/frontend/config-form.test.mjs b/test/frontend/config-form.test.mjs index 4ec7a35..548f2b3 100644 --- a/test/frontend/config-form.test.mjs +++ b/test/frontend/config-form.test.mjs @@ -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) diff --git a/test/frontend/config-settings.test.mjs b/test/frontend/config-settings.test.mjs index 86c885c..26b518d 100644 --- a/test/frontend/config-settings.test.mjs +++ b/test/frontend/config-settings.test.mjs @@ -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 } }