fix: 收口依赖兼容与会话撤销
为 miniprogram-ci 和 Jimp 依赖增加兼容 patch 与 smoke test;修复平台模板管理员路由漏配;收紧模板契约校验;为 admin/customer 增加 token 撤销和集中会话存储;同步品牌切换角色、doctor source hash、多屏宽截图证据和 CI 构建门禁。
This commit is contained in:
1 parent
4f0b50c7f1
commit
3017e3eb49
65 files changed
+1623
-975
No files matched your search
@@ -247,6 +247,30 @@ test("模板失败指标仅平台模板管理员可查,按窗口聚合且不
|
||||
await prisma.adminUser.delete({ where: { id: ordinaryUser.id } });
|
||||
}
|
||||
|
||||
const templateAdminWithoutMembership = await prisma.adminUser.create({
|
||||
data: {
|
||||
username: `metrics-platform-${randomUUID()}`,
|
||||
passwordHash: "unused",
|
||||
displayName: "平台模板管理员",
|
||||
platformTemplateRole: "template_admin",
|
||||
mustChangePassword: false,
|
||||
},
|
||||
});
|
||||
try {
|
||||
const response = await request("/admin/template-operations/failures", {
|
||||
headers: {
|
||||
authorization: `Bearer ${signIdentity({
|
||||
subject: templateAdminWithoutMembership.id,
|
||||
brandId: "00000000-0000-0000-0000-000000000000",
|
||||
role: "admin",
|
||||
})}`,
|
||||
},
|
||||
});
|
||||
assert.equal(response.statusCode, 200, response.body);
|
||||
} finally {
|
||||
await prisma.adminUser.delete({ where: { id: templateAdminWithoutMembership.id } });
|
||||
}
|
||||
|
||||
const login = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||
@@ -516,7 +540,10 @@ test("平台模板管理员可以按行业预览版本,且预览不写入品
|
||||
/所属行业|must match its key/,
|
||||
],
|
||||
[{ ...stored.manifestSnapshot, requiredCapabilities: ["unknown"] }, /未注册的 capability/],
|
||||
[{ ...stored.manifestSnapshot, visualTemplateKey: "unknown" }, /元数据/],
|
||||
[
|
||||
{ ...stored.manifestSnapshot, visualTemplateKey: "unknown" },
|
||||
/visualTemplateKey must match packageKey|元数据/,
|
||||
],
|
||||
[{ ...stored.manifestSnapshot, runtimeContract: "9.0" }, /契约/],
|
||||
[{ ...stored.manifestSnapshot, dataSlots: [null] }, /契约/],
|
||||
[{ ...stored.manifestSnapshot, navigation: [null] }, /契约/],
|
||||
@@ -3868,6 +3895,54 @@ test("admin login validates credentials", async () => {
|
||||
assert.equal(response.statusCode, 401);
|
||||
});
|
||||
|
||||
test("admin logout revokes the current token", async () => {
|
||||
const username = `logout-admin-${randomUUID()}`;
|
||||
const password = "logout-password-123";
|
||||
const user = await prisma.adminUser.create({
|
||||
data: {
|
||||
username,
|
||||
passwordHash: await bcrypt.hash(password, 12),
|
||||
displayName: "登出测试管理员",
|
||||
mustChangePassword: false,
|
||||
},
|
||||
});
|
||||
await prisma.brandMembership.create({
|
||||
data: { brandId, adminUserId: user.id, role: "owner", isEnabled: true },
|
||||
});
|
||||
try {
|
||||
const login = await request("/admin/session/login", {
|
||||
method: "POST",
|
||||
payload: { username, password },
|
||||
});
|
||||
assert.equal(login.statusCode, 201, login.body);
|
||||
const token = JSON.parse(login.body).token;
|
||||
const headers = { authorization: `Bearer ${token}` };
|
||||
const before = await request("/admin/bookings/unread-count", { headers });
|
||||
assert.equal(before.statusCode, 200);
|
||||
|
||||
const logout = await request("/admin/session/logout", { method: "POST", headers });
|
||||
assert.equal(logout.statusCode, 201);
|
||||
const after = await request("/admin/bookings/unread-count", { headers });
|
||||
assert.equal(after.statusCode, 401);
|
||||
} finally {
|
||||
await prisma.adminUser.delete({ where: { id: user.id } });
|
||||
}
|
||||
});
|
||||
|
||||
test("customer logout revokes the current token", async () => {
|
||||
const openid = `logout-${randomUUID()}`;
|
||||
await prisma.customerUser.create({ data: { brandId, openid } });
|
||||
const token = signIdentity({ subject: openid, brandId, role: "customer" });
|
||||
const headers = { authorization: `Bearer ${token}` };
|
||||
const before = await request("/customer/inquiry-submissions", { headers });
|
||||
assert.equal(before.statusCode, 200);
|
||||
|
||||
const logout = await request("/customer/session/logout", { method: "POST", headers });
|
||||
assert.equal(logout.statusCode, 201);
|
||||
const after = await request("/customer/inquiry-submissions", { headers });
|
||||
assert.equal(after.statusCode, 401);
|
||||
});
|
||||
|
||||
test("admin login does not auto-grant ownership to users without memberships", async () => {
|
||||
const username = `no-membership-${Date.now()}`;
|
||||
const user = await prisma.adminUser.create({
|
||||
@@ -4287,7 +4362,7 @@ test("admin can manage trust content", async () => {
|
||||
|
||||
test("customer booking endpoints require a valid customer session", async () => {
|
||||
const missing = await request("/customer/bookings");
|
||||
assert.equal(missing.statusCode, 400);
|
||||
assert.equal(missing.statusCode, 401);
|
||||
|
||||
const list = await request("/customer/bookings", {
|
||||
headers: { authorization: `Bearer ${customerToken}` },
|
||||
@@ -4774,6 +4849,9 @@ test("atelier template imports selected package and preserves draft publication
|
||||
(await json("/public/workspace?brandSlug=" + slug)).brand.visualPresentation.home.title,
|
||||
"仅草稿可见的新标题",
|
||||
);
|
||||
const atelierCustomer = await prisma.customerUser.create({
|
||||
data: { brandId: brand.id, openid: "atelier-test-customer" },
|
||||
});
|
||||
const customerHeaders = {
|
||||
authorization: `Bearer ${signIdentity({ subject: "atelier-test-customer", brandId: brand.id, role: "customer" })}`,
|
||||
};
|
||||
@@ -4819,6 +4897,7 @@ test("atelier template imports selected package and preserves draft publication
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
await prisma.customerUser.deleteMany({ where: { brandId: brand.id } });
|
||||
await prisma.brandProfile.delete({ where: { id: brand.id } });
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user