feat: 增加能力插件启停与审计
This commit is contained in:
1 parent
0fb96bdea3
commit
8a02d09e2d
6 files changed
+147
-1
No files matched your search
@@ -89,6 +89,34 @@ test("public workspace uses brand-scoped capability installations and preserves
|
||||
}
|
||||
});
|
||||
|
||||
test("admin can update declared capability status with authorization and audit", async () => {
|
||||
const unauthorized = await request("/admin/workspace/capabilities/inquiry", {
|
||||
method: "PATCH",
|
||||
payload: { capabilityVersion: "1.0.0", status: "disabled" },
|
||||
});
|
||||
assert.equal(unauthorized.statusCode, 401);
|
||||
const login = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
});
|
||||
const token = JSON.parse(login.body).token;
|
||||
const updated = await request("/admin/workspace/capabilities/inquiry", {
|
||||
method: "PATCH",
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: { capabilityVersion: "1.0.0", status: "disabled", config: { mode: "manual" } },
|
||||
});
|
||||
assert.equal(updated.statusCode, 200);
|
||||
assert.equal(JSON.parse(updated.body).status, "disabled");
|
||||
const audit = await prisma.capabilityAuditLog.findFirst({
|
||||
where: { brandId, capabilityKey: "inquiry" },
|
||||
orderBy: { createdAt: "desc" },
|
||||
});
|
||||
assert.ok(audit);
|
||||
assert.equal(audit.toStatus, "disabled");
|
||||
await prisma.capabilityInstallation.deleteMany({ where: { brandId } });
|
||||
await prisma.capabilityAuditLog.deleteMany({ where: { brandId } });
|
||||
});
|
||||
|
||||
test("admin can install a template and public workspace exposes enabled configuration", async () => {
|
||||
await prisma.inquirySubmission.deleteMany({ where: { brandId } });
|
||||
await prisma.inquiryForm.deleteMany({ where: { brandId } });
|
||||
|
||||
Reference in new issue
Block a user