forked from baron/baron-sso
역할 전환 E2E 및 권한 안내 검증 테스트 추가
This commit is contained in:
@@ -70,35 +70,39 @@ export function makeClient(
|
||||
};
|
||||
}
|
||||
|
||||
export async function seedAuth(page: Page) {
|
||||
export async function seedAuth(page: Page, role?: string) {
|
||||
const nowInSeconds = Math.floor(Date.now() / 1000);
|
||||
|
||||
await page.addInitScript((issuedAt) => {
|
||||
const mockOidcUser = {
|
||||
id_token: "playwright-id-token",
|
||||
session_state: "playwright-session",
|
||||
access_token: "playwright-access-token",
|
||||
refresh_token: "playwright-refresh-token",
|
||||
token_type: "Bearer",
|
||||
scope: "openid profile email",
|
||||
profile: {
|
||||
sub: "playwright-user",
|
||||
email: "playwright@example.com",
|
||||
name: "Playwright User",
|
||||
},
|
||||
expires_at: issuedAt + 3600,
|
||||
};
|
||||
await page.addInitScript(
|
||||
({ issuedAt, injectedRole }) => {
|
||||
const mockOidcUser = {
|
||||
id_token: "playwright-id-token",
|
||||
session_state: "playwright-session",
|
||||
access_token: "playwright-access-token",
|
||||
refresh_token: "playwright-refresh-token",
|
||||
token_type: "Bearer",
|
||||
scope: "openid profile email",
|
||||
profile: {
|
||||
sub: "playwright-user",
|
||||
email: "playwright@example.com",
|
||||
name: "Playwright User",
|
||||
...(injectedRole ? { role: injectedRole } : {}),
|
||||
},
|
||||
expires_at: issuedAt + 3600,
|
||||
};
|
||||
|
||||
window.localStorage.setItem(
|
||||
"oidc.user:http://localhost:5000/oidc:devfront",
|
||||
JSON.stringify(mockOidcUser),
|
||||
);
|
||||
window.localStorage.setItem(
|
||||
"oidc.user:http://localhost:5000/oidc/:devfront",
|
||||
JSON.stringify(mockOidcUser),
|
||||
);
|
||||
window.localStorage.setItem("dev_tenant_id", "tenant-a");
|
||||
}, nowInSeconds);
|
||||
window.localStorage.setItem(
|
||||
"oidc.user:http://localhost:5000/oidc:devfront",
|
||||
JSON.stringify(mockOidcUser),
|
||||
);
|
||||
window.localStorage.setItem(
|
||||
"oidc.user:http://localhost:5000/oidc/:devfront",
|
||||
JSON.stringify(mockOidcUser),
|
||||
);
|
||||
window.localStorage.setItem("dev_tenant_id", "tenant-a");
|
||||
},
|
||||
{ issuedAt: nowInSeconds, injectedRole: role ?? "" },
|
||||
);
|
||||
}
|
||||
|
||||
function json(route: Route, payload: unknown, status = 200) {
|
||||
|
||||
24
devfront/tests/helpers/evidence.ts
Normal file
24
devfront/tests/helpers/evidence.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import type { Page, TestInfo } from "@playwright/test";
|
||||
|
||||
function safeName(name: string): string {
|
||||
return name
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9-_]+/g, "-")
|
||||
.replace(/-+/g, "-")
|
||||
.replace(/^-|-$/g, "");
|
||||
}
|
||||
|
||||
export async function captureEvidence(
|
||||
page: Page,
|
||||
testInfo: TestInfo,
|
||||
name: string,
|
||||
) {
|
||||
const filename = `${safeName(name)}.png`;
|
||||
const fullPath = testInfo.outputPath(filename);
|
||||
await page.screenshot({ path: fullPath, fullPage: true });
|
||||
await testInfo.attach(name, {
|
||||
path: fullPath,
|
||||
contentType: "image/png",
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user