修复部署后旧证书误通过及校验失败仍显示成功

This commit is contained in:
xuans committed 2026-09-30 21:21:56 +08:00
1 parent 1b2b45d059
commit fc57b8e1da
11 files changed
+416 -13

No files matched your search

@@ -10,11 +10,17 @@ export function serverAuthLabel(server) {
export function deploymentSummary(report) {
if (!report || !Array.isArray(report.results)) return "未收到有效部署结果";
if (report.verification_status === "failed") {
return "证书已推送,但站点 HTTPS 校验失败,尚未确认新证书生效;未自动回滚";
}
if (report.total === 0 && report.results.length === 0) return "未配置部署目标,未执行推送";
if (report.status === "success" && report.total > 0 &&
report.success === report.total && report.failed === 0 &&
report.results.length === report.total &&
report.results.every((item) => item.status === "success")) {
if (report.verification_status === "success") {
return `证书部署完成:${report.success} 台推送成功,站点 HTTPS 校验通过`;
}
return `证书部署完成:${report.success} 台成功`;
}
return "证书部署未全部成功,请检查各服务器结果";
@@ -30,6 +30,18 @@ test("部署汇总不把空目标、缺失结果或部分失败称为成功", ()
assert.match(deploymentSummary({ ...report, status: "partial", failed: 1 }), /未全部成功/);
});
test("站点生效校验与单台推送分开展示,不把旧证书或校验失败宣称为部署成功", () => {
const failed = { ...report, status: "failed", verification_status: "failed" };
assert.match(deploymentSummary(failed), /HTTPS 校验失败/);
assert.match(deploymentSummary(failed), /未自动回滚/);
assert.doesNotMatch(deploymentSummary(failed), /部署完成/);
assert.match(deploymentSummary({ ...report, verification_status: "failed" }), /尚未确认/);
assert.equal(
deploymentSummary({ ...report, verification_status: "success" }),
"证书部署完成:1 台推送成功,站点 HTTPS 校验通过",
);
});
test("手动部署展示真实返回结果并阻止执行期间重复提交", async (t) => {
const pending = deferred();
let requests = 0;
@@ -72,6 +84,22 @@ test("部署失败仍保留各服务器结果,网络失败不会残留执行
assert.equal(state.deploymentResult.value.error, "network-test-failure");
});
test("HTTPS 校验失败响应保留推送明细,但不弹出成功通知", async (t) => {
const failed = { ...report, status: "failed", verification_status: "failed" };
const { state } = await mountComposable(t, useDashboard, async (path) => {
if (path.endsWith("/deploy")) {
return Response.json({ error: "证书部署失败", deployment: failed }, { status: 502 });
}
return Response.json({ items: [] });
});
await state.deployDomain({ id: "domain-1", name: "example.test" });
assert.equal(state.deploymentResult.value.running, false);
assert.equal(state.deploymentResult.value.error, "证书部署失败");
assert.deepEqual(state.deploymentResult.value.report, failed);
assert.match(deploymentSummary(state.deploymentResult.value.report), /尚未确认新证书生效/);
assert.equal(state.notice.value, "");
});
test("部署结果组件可编译且认证提示绑定真实配置", async () => {
const source = await readFile(new URL("./DeploymentResult.vue", import.meta.url), "utf8");
const { descriptor, errors } = parse(source);
@@ -49,7 +49,7 @@ defineEmits(["close"]);
</span>
</article>
</div>
<p class="muted">此处显示本次推送结果;远程站点是否使用新证书,仍需访问站点验证。</p>
<p class="muted">各服务器结果记录文件推送、配置校验与重载;站点 HTTPS 校验单独汇总,不代表逐台服务器均已验证。</p>
</template>
<div class="modal-actions">
<button class="secondary-button" type="button" :disabled="result.running" @click="$emit('close')">