forked from baron/baron-sso
adminfront/devfront code-check 수정
This commit is contained in:
@@ -107,6 +107,22 @@ test.describe("DevFront role report", () => {
|
||||
const state = {
|
||||
clients: [makeClient("gitea-client", { name: "Gitea" })],
|
||||
consents: [] as Consent[],
|
||||
developerRequests: [
|
||||
{
|
||||
id: "req-audit-approved",
|
||||
userId: "playwright-user",
|
||||
userName: "Playwright User",
|
||||
name: "Playwright User",
|
||||
userEmail: "playwright@example.com",
|
||||
organization: "Tenant A",
|
||||
reason: "Need access",
|
||||
status: "approved",
|
||||
accessPages: ["audit"],
|
||||
createdAt: "2026-05-29T00:00:00.000Z",
|
||||
updatedAt: "2026-05-29T00:10:00.000Z",
|
||||
approvedAt: "2026-05-29T00:10:00.000Z",
|
||||
},
|
||||
],
|
||||
auditLogs: [
|
||||
{
|
||||
event_id: "evt-rp-1",
|
||||
|
||||
@@ -65,6 +65,22 @@ test.describe("DevFront security and isolation", () => {
|
||||
clients: [] as ReturnType<typeof makeClient>[],
|
||||
consents: [] as Consent[],
|
||||
auditLogsByCursor: undefined,
|
||||
developerRequests: [
|
||||
{
|
||||
id: "req-audit-approved",
|
||||
userId: "playwright-user",
|
||||
userName: "Playwright User",
|
||||
name: "Playwright User",
|
||||
userEmail: "playwright@example.com",
|
||||
organization: "Tenant A",
|
||||
reason: "Need access",
|
||||
status: "approved",
|
||||
accessPages: ["audit"],
|
||||
createdAt: "2026-05-29T00:00:00.000Z",
|
||||
updatedAt: "2026-05-29T00:10:00.000Z",
|
||||
approvedAt: "2026-05-29T00:10:00.000Z",
|
||||
},
|
||||
],
|
||||
};
|
||||
await installDevApiMock(page, state);
|
||||
|
||||
|
||||
@@ -242,6 +242,30 @@ export async function installDevApiMock(page: Page, state: DevApiMockState) {
|
||||
const readMockRole = () =>
|
||||
(state.mockRole ?? seededRoles.get(page) ?? "super_admin").trim();
|
||||
|
||||
const buildDeveloperAccessStatus = () => {
|
||||
const requests = state.developerRequests ?? [];
|
||||
const myRequests = requests.filter((request) => request.userId === "playwright-user");
|
||||
const approvedPages = myRequests
|
||||
.filter((request) => request.status === "approved")
|
||||
.flatMap((request) => request.accessPages ?? ["all"]);
|
||||
const pendingPages = myRequests
|
||||
.filter((request) => request.status === "pending")
|
||||
.flatMap((request) => request.accessPages ?? ["all"]);
|
||||
|
||||
const latestRequest = myRequests[myRequests.length - 1];
|
||||
if (!latestRequest) {
|
||||
return {
|
||||
status: "none" as const,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
status: latestRequest.status,
|
||||
approvedPages,
|
||||
pendingPages,
|
||||
};
|
||||
};
|
||||
|
||||
const buildSelfConfigEditorRelation = (): ClientRelation => ({
|
||||
relation: "config_editor",
|
||||
subject: "User:playwright-user",
|
||||
@@ -358,10 +382,7 @@ export async function installDevApiMock(page: Page, state: DevApiMockState) {
|
||||
pathname === "/api/v1/dev/developer-request/status") &&
|
||||
method === "GET"
|
||||
) {
|
||||
const myRequest = (state.developerRequests ?? []).find(
|
||||
(r) => r.userId === "playwright-user",
|
||||
);
|
||||
return json(route, myRequest || null);
|
||||
return json(route, buildDeveloperAccessStatus());
|
||||
}
|
||||
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user