forked from baron/baron-sso
merge: integrate origin dev into dev
Includes Worksmobile SSOT sync comparison updates, UUID import conflict resolution, and Playwright route mock stabilization.
This commit is contained in:
@@ -55,6 +55,7 @@ test.describe("DevFront relationships", () => {
|
||||
] satisfies ClientRelation[],
|
||||
},
|
||||
auditLogsByCursor: undefined,
|
||||
mockRole: "super_admin",
|
||||
};
|
||||
await installDevApiMock(page, state);
|
||||
|
||||
|
||||
@@ -115,8 +115,11 @@ export type DevApiMockState = {
|
||||
onRotateSecret?: (newSecret: string) => void;
|
||||
onRefreshHeadlessJwks?: (clientId: string) => void;
|
||||
onRevokeHeadlessJwksCache?: (clientId: string) => void;
|
||||
mockRole?: string;
|
||||
};
|
||||
|
||||
const seededRoles = new WeakMap<Page, string>();
|
||||
|
||||
export function makeClient(
|
||||
id: string,
|
||||
overrides: Partial<Client> = {},
|
||||
@@ -137,6 +140,7 @@ export function makeClient(
|
||||
|
||||
export async function seedAuth(page: Page, role?: string) {
|
||||
const nowInSeconds = Math.floor(Date.now() / 1000);
|
||||
seededRoles.set(page, role || "rp_admin");
|
||||
|
||||
await page.addInitScript(
|
||||
({ issuedAt, injectedRole }) => {
|
||||
@@ -225,11 +229,8 @@ function parseClientId(pathname: string): string {
|
||||
}
|
||||
|
||||
export async function installDevApiMock(page: Page, state: DevApiMockState) {
|
||||
const readMockRole = async () =>
|
||||
(
|
||||
(await page.evaluate(() => window.localStorage.getItem("dev_role"))) ??
|
||||
"rp_admin"
|
||||
).trim();
|
||||
const readMockRole = () =>
|
||||
(state.mockRole ?? seededRoles.get(page) ?? "rp_admin").trim();
|
||||
|
||||
const buildSelfConfigEditorRelation = (): ClientRelation => ({
|
||||
relation: "config_editor",
|
||||
@@ -250,7 +251,7 @@ export async function installDevApiMock(page: Page, state: DevApiMockState) {
|
||||
return explicitRelations;
|
||||
}
|
||||
|
||||
const role = await readMockRole();
|
||||
const role = readMockRole();
|
||||
if (!shouldGrantDefaultEditRelation(role)) {
|
||||
return [];
|
||||
}
|
||||
@@ -282,9 +283,7 @@ export async function installDevApiMock(page: Page, state: DevApiMockState) {
|
||||
};
|
||||
|
||||
await page.route("**/api/v1/user/me", async (route) => {
|
||||
const storedRole =
|
||||
(await page.evaluate(() => window.localStorage.getItem("dev_role"))) ??
|
||||
"rp_admin";
|
||||
const storedRole = readMockRole();
|
||||
return json(route, {
|
||||
id: "playwright-user",
|
||||
loginId: "playwright@example.com",
|
||||
|
||||
Reference in New Issue
Block a user