From 23a3a084b83b1fc21baf7518bc81f4e0eb9819a1 Mon Sep 17 00:00:00 2001 From: kyy Date: Mon, 15 Jun 2026 09:36:29 +0900 Subject: [PATCH] =?UTF-8?q?refresh-token=20e2e=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EC=99=80=20=EC=84=A4=EC=A0=95=20=EC=9E=84=EC=8B=9C?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- devfront/package.json | 3 +- devfront/playwright.config.ts | 1 - devfront/playwright.refresh-token.config.ts | 52 ---------- devfront/tests/devfront-refresh-token.spec.ts | 99 ------------------- 4 files changed, 1 insertion(+), 154 deletions(-) delete mode 100644 devfront/playwright.refresh-token.config.ts delete mode 100644 devfront/tests/devfront-refresh-token.spec.ts diff --git a/devfront/package.json b/devfront/package.json index 90c89038..c849f931 100644 --- a/devfront/package.json +++ b/devfront/package.json @@ -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", diff --git a/devfront/playwright.config.ts b/devfront/playwright.config.ts index e6b4dff8..cfb1eb55 100644 --- a/devfront/playwright.config.ts +++ b/devfront/playwright.config.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. */ diff --git a/devfront/playwright.refresh-token.config.ts b/devfront/playwright.refresh-token.config.ts deleted file mode 100644 index 518a5fdd..00000000 --- a/devfront/playwright.refresh-token.config.ts +++ /dev/null @@ -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, - }, -}); diff --git a/devfront/tests/devfront-refresh-token.spec.ts b/devfront/tests/devfront-refresh-token.spec.ts deleted file mode 100644 index d11fde29..00000000 --- a/devfront/tests/devfront-refresh-token.spec.ts +++ /dev/null @@ -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); - }); -});