forked from baron/baron-sso
refresh-token e2e 테스트와 설정 임시제거
This commit is contained in:
@@ -12,8 +12,7 @@
|
||||
"lint": "biome check .",
|
||||
"preview": "vite preview",
|
||||
"test": "playwright test",
|
||||
"test:ci": "pnpm test && pnpm run test:refresh-token",
|
||||
"test:refresh-token": "playwright test --config playwright.refresh-token.config.ts",
|
||||
"test:ci": "pnpm test",
|
||||
"test:coverage": "vitest run --coverage --bail 1",
|
||||
"test:unit": "vitest run --bail 1",
|
||||
"test:roles": "playwright test tests/devfront-role-switch-report.spec.ts",
|
||||
|
||||
@@ -28,7 +28,6 @@ const baseURL = process.env.PLAYWRIGHT_BASE_URL || "http://127.0.0.1:4174";
|
||||
*/
|
||||
export default defineConfig({
|
||||
testDir: "./tests",
|
||||
testIgnore: ["**/devfront-refresh-token.spec.ts"],
|
||||
/* Run tests in files in parallel */
|
||||
fullyParallel: true,
|
||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
import { createRequire } from "node:module";
|
||||
import { defineConfig, devices } from "@playwright/test";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const { shouldIncludeWebKit } =
|
||||
require("../scripts/playwrightHostDeps.cjs") as {
|
||||
shouldIncludeWebKit: () => boolean;
|
||||
};
|
||||
|
||||
const configuredWorkers = process.env.PLAYWRIGHT_WORKERS
|
||||
? Number.parseInt(process.env.PLAYWRIGHT_WORKERS, 10)
|
||||
: 1;
|
||||
const baseURL = process.env.PLAYWRIGHT_BASE_URL || "http://127.0.0.1:4175";
|
||||
const skipWebServer =
|
||||
process.env.PLAYWRIGHT_SKIP_WEBSERVER === "1" ||
|
||||
process.env.PLAYWRIGHT_SKIP_WEBSERVER === "true";
|
||||
|
||||
export default defineConfig({
|
||||
testDir: "./tests",
|
||||
testMatch: ["**/devfront-refresh-token.spec.ts"],
|
||||
fullyParallel: false,
|
||||
forbidOnly: !!process.env.CI,
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
workers: configuredWorkers,
|
||||
reporter: [["html", { open: "never" }], ["list"]],
|
||||
use: {
|
||||
baseURL,
|
||||
trace: "on-first-retry",
|
||||
},
|
||||
projects: [
|
||||
{
|
||||
name: "chromium",
|
||||
use: { ...devices["Desktop Chrome"] },
|
||||
},
|
||||
...(shouldIncludeWebKit()
|
||||
? [
|
||||
{
|
||||
name: "webkit",
|
||||
use: { ...devices["Desktop Safari"] },
|
||||
},
|
||||
]
|
||||
: []),
|
||||
],
|
||||
webServer: skipWebServer
|
||||
? undefined
|
||||
: {
|
||||
command:
|
||||
"VITE_OIDC_AUTHORITY=http://localhost:5000/oidc ./node_modules/.bin/vite build && ./node_modules/.bin/vite preview --host 127.0.0.1 --strictPort --port 4175",
|
||||
url: baseURL,
|
||||
reuseExistingServer: false,
|
||||
},
|
||||
});
|
||||
@@ -1,99 +0,0 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
import {
|
||||
getPersistedOidcUser,
|
||||
installDevApiMock,
|
||||
seedAuth,
|
||||
} from "./helpers/devfront-fixtures";
|
||||
import { captureEvidence } from "./helpers/evidence";
|
||||
|
||||
test.describe("DevFront refresh token renewal", () => {
|
||||
test.afterEach(async ({ page }, testInfo) => {
|
||||
if (testInfo.status === "passed") {
|
||||
await captureEvidence(page, testInfo, testInfo.title);
|
||||
}
|
||||
});
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await seedAuth(page, {
|
||||
expiresInSeconds: 60,
|
||||
refreshToken: "playwright-refresh-token",
|
||||
state: { returnTo: "/clients" },
|
||||
});
|
||||
|
||||
await installDevApiMock(page, {
|
||||
clients: [],
|
||||
consents: [],
|
||||
auditLogs: [],
|
||||
users: [],
|
||||
tenants: [],
|
||||
});
|
||||
});
|
||||
|
||||
test("exchanges the refresh token for a new access token on silent renewal", async ({
|
||||
page,
|
||||
}) => {
|
||||
let tokenRequestBody = "";
|
||||
let authorizeRequested = false;
|
||||
|
||||
await page.route("**/oidc/token", async (route) => {
|
||||
const request = route.request();
|
||||
tokenRequestBody = request.postData() ?? "";
|
||||
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
headers: { "Access-Control-Allow-Origin": "*" },
|
||||
body: JSON.stringify({
|
||||
access_token: "rotated-access-token",
|
||||
expires_in: 3600,
|
||||
refresh_token: "rotated-refresh-token",
|
||||
scope: "openid offline_access profile email",
|
||||
session_state: "rotated-session-state",
|
||||
token_type: "Bearer",
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
await page.route("**/oidc/auth**", async (route) => {
|
||||
authorizeRequested = true;
|
||||
await route.fulfill({
|
||||
status: 500,
|
||||
body: "unexpected authorize request",
|
||||
});
|
||||
});
|
||||
|
||||
await page.goto("/clients");
|
||||
|
||||
await expect(page.locator('a[href="/clients"]')).toBeVisible();
|
||||
|
||||
const tokenRequestPromise = page.waitForRequest(
|
||||
(request) =>
|
||||
request.url().endsWith("/oidc/token") && request.method() === "POST",
|
||||
);
|
||||
|
||||
await page.getByRole("button", { name: "Open account menu" }).click();
|
||||
await page.getByRole("menuitem", { name: "My Profile" }).click();
|
||||
|
||||
const tokenRequest = await tokenRequestPromise;
|
||||
const tokenParams = new URLSearchParams(tokenRequestBody);
|
||||
|
||||
expect(tokenParams.get("grant_type")).toBe("refresh_token");
|
||||
expect(tokenParams.get("refresh_token")).toBe("playwright-refresh-token");
|
||||
|
||||
await expect(page.getByRole("heading", { name: "내 정보" })).toBeVisible();
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const storedUser = await getPersistedOidcUser(page);
|
||||
return storedUser?.access_token;
|
||||
})
|
||||
.toBe("rotated-access-token");
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const storedUser = await getPersistedOidcUser(page);
|
||||
return storedUser?.refresh_token;
|
||||
})
|
||||
.toBe("rotated-refresh-token");
|
||||
expect(tokenRequest.url()).toContain("/oidc/token");
|
||||
expect(authorizeRequested).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user