refactor: 收口 Admin 会话与授权边界
This commit is contained in:
1 parent
0788480ce3
commit
4ef4be2071
67 files changed
+1890
-392
No files matched your search
@@ -57,9 +57,19 @@ test("模板管理可重试预览,并切换我的、详情和禁止提交的
|
||||
),
|
||||
);
|
||||
await page.setViewportSize({ width: 1440, height: 1000 });
|
||||
await page.addInitScript(() => {
|
||||
localStorage.setItem("adminToken", "fixture-token");
|
||||
localStorage.setItem("adminPlatformTemplateRole", "template_admin");
|
||||
await page.route("**/api/**", (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
if (url.pathname.endsWith("/admin/session/current"))
|
||||
return route.fulfill({
|
||||
json: {
|
||||
authenticated: true,
|
||||
displayName: "模板管理员",
|
||||
role: "owner",
|
||||
mustChangePassword: false,
|
||||
platformTemplateRole: "template_admin",
|
||||
},
|
||||
});
|
||||
return route.fulfill({ json: {} });
|
||||
});
|
||||
let attempts = 0;
|
||||
const writes: string[] = [];
|
||||
@@ -71,6 +81,16 @@ test("模板管理可重试预览,并切换我的、详情和禁止提交的
|
||||
};
|
||||
await page.route("**/api/**", async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
if (url.pathname.endsWith("/admin/session/current"))
|
||||
return route.fulfill({
|
||||
json: {
|
||||
authenticated: true,
|
||||
displayName: "模板管理员",
|
||||
role: "owner",
|
||||
mustChangePassword: false,
|
||||
platformTemplateRole: "template_admin",
|
||||
},
|
||||
});
|
||||
if (route.request().method() !== "GET") writes.push(url.pathname);
|
||||
if (url.pathname.endsWith("/preview")) {
|
||||
attempts++;
|
||||
|
||||
Reference in new issue
Block a user