保存内置DNS续期与证书同步接续修复前基线

This commit is contained in:
xuans committed 2026-09-20 04:39:25 +08:00
1 parent 7fec05650f
commit d6ea80a040
23 files changed
+704 -13

No files matched your search

+15
View File
@@ -13,6 +13,21 @@ const { readFormConfig, getFieldGroups, updateFormConfig, validateFormConfig } =
'\nreturn { readFormConfig, getFieldGroups, updateFormConfig, validateFormConfig }'
)()
test('项目 DNS 自动续期需要凭据,已设置的凭据可留空且外部托管隐藏 DNS 字段', () => {
const config = { tls: { management: 'project', challenge: 'dns', mode: 'managed_default', defaultDirectory: 'ssl', dnsProvider: 'alidns' } }
assert.ok(validateFormConfig('ssl', config)['tls.dnsAccessKeyInput'])
assert.ok(validateFormConfig('ssl', config)['tls.dnsSecretKeyInput'])
config.dnsAccessKeyStatus = { configured: true }
config.tls.dnsSecretKeyInput = 'test-secret'
assert.deepEqual(validateFormConfig('ssl', config), {})
config.tls.dnsZone = 'https://example.com'
assert.ok(validateFormConfig('ssl', config)['tls.dnsZone'])
for (const management of ['custom', 'web_server']) {
config.tls.management = management
assert.ok(getFieldGroups('ssl', config).flatMap(group => group.fields).every(field => !field.path.join('.').includes('dns')))
}
})
test('公网 HTTPS 端口独立编辑且保留内部监听与模式切换', () => {
const config = {
database: { type: 'sqlite' },
+23
View File
@@ -66,6 +66,29 @@ function deferred() {
return { promise, resolve, reject }
}
test('DNS 凭据只通过专用密钥变更提交,留空保持原值', async () => {
const sent = []
const current = {
tls: { management: 'project', mode: 'managed_default', defaultDirectory: 'ssl', challenge: 'dns', dnsProvider: 'alidns', dnsAccessKey: {}, dnsSecretKey: {} },
dnsAccessKeyStatus: { configured: true }, dnsSecretKeyStatus: { configured: true }
}
const { page } = fixture(async path => ({ errorNo: 0, data: path.endsWith('/status') ? { available: true, activeGeneration: 1 } : current }), 'ssl', {
http: { post: async (path, body) => { sent.push(body); return { errorNo: 0, data: { valid: true } } } }
})
await page.loadAll()
page.updateField(['tls', 'dnsSecretKeyInput'], 'new-test-secret')
await page.validateConfig()
assert.equal(sent.length, 1)
assert.deepEqual(sent[0].secretChanges, { 'tls.dnsSecretKey': { operation: 'replace', value: { plaintext: 'new-test-secret' } } })
assert.equal(sent[0].payload.dnsAccessKeyStatus, undefined)
assert.equal(sent[0].payload.dnsSecretKeyStatus, undefined)
assert.equal(sent[0].payload.tls.dnsSecretKeyInput, undefined)
assert.equal(sent[0].payload.tls.dnsSecretKey, undefined)
page.updateField(['tls', 'dnsSecretKeyInput'], '')
await page.validateConfig()
assert.deepEqual(sent[1].secretChanges, {})
})
for (const cancelled of [false, true]) {
test(`共享身份确认保留单次重试,移除审计不影响其他操作:取消=${cancelled}`, async () => {
const requests = []