From dc9332809b709b0745e25274b2b4ffdb3345a868 Mon Sep 17 00:00:00 2001 From: kyy Date: Wed, 4 Mar 2026 09:44:12 +0900 Subject: [PATCH] =?UTF-8?q?Biome=20=EB=B0=8F=20Go=20=ED=8F=AC=EB=A7=B7=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../internal/handler/auth_handler_async_test.go | 1 + backend/internal/handler/dev_handler_test.go | 11 +++++++++-- devfront/tests/devfront-audit.spec.ts | 12 ++++++++---- .../tests/devfront-clients-lifecycle.spec.ts | 10 +++++----- devfront/tests/helpers/devfront-fixtures.ts | 17 +++++++++++++---- 5 files changed, 36 insertions(+), 15 deletions(-) diff --git a/backend/internal/handler/auth_handler_async_test.go b/backend/internal/handler/auth_handler_async_test.go index 00212e60..d206f48c 100644 --- a/backend/internal/handler/auth_handler_async_test.go +++ b/backend/internal/handler/auth_handler_async_test.go @@ -171,6 +171,7 @@ func (m *AsyncMockTenantService) ListTenants(ctx context.Context, limit, offset func (m *AsyncMockTenantService) ListManageableTenants(ctx context.Context, userID string) ([]domain.Tenant, error) { return nil, nil } + func (m *AsyncMockTenantService) IsDomainAllowed(ctx context.Context, domainName string) (bool, error) { return false, nil } diff --git a/backend/internal/handler/dev_handler_test.go b/backend/internal/handler/dev_handler_test.go index 35a52d44..19ede568 100644 --- a/backend/internal/handler/dev_handler_test.go +++ b/backend/internal/handler/dev_handler_test.go @@ -27,16 +27,20 @@ func (m *devMockKetoService) CheckPermission(ctx context.Context, subject, names args := m.Called(ctx, subject, namespace, object, relation) return args.Bool(0), args.Error(1) } + func (m *devMockKetoService) CreateRelation(ctx context.Context, ns, obj, rel, sub string) error { return m.Called(ctx, ns, obj, rel, sub).Error(0) } + func (m *devMockKetoService) DeleteRelation(ctx context.Context, ns, obj, rel, sub string) error { return m.Called(ctx, ns, obj, rel, sub).Error(0) } + func (m *devMockKetoService) ListRelations(ctx context.Context, ns, obj, rel, sub string) ([]service.RelationTuple, error) { args := m.Called(ctx, ns, obj, rel, sub) return args.Get(0).([]service.RelationTuple), args.Error(1) } + func (m *devMockKetoService) ListObjects(ctx context.Context, ns, rel, sub string) ([]string, error) { args := m.Called(ctx, ns, rel, sub) return args.Get(0).([]string), args.Error(1) @@ -53,6 +57,7 @@ func (m *devMockRedisRepo) Set(key, value string, exp time.Duration) error { m.data[key] = value return nil } + func (m *devMockRedisRepo) Get(key string) (string, error) { v, ok := m.data[key] if !ok { @@ -60,13 +65,14 @@ func (m *devMockRedisRepo) Get(key string) (string, error) { } return v, nil } + func (m *devMockRedisRepo) Delete(key string) error { delete(m.data, key) return nil } -func (m *devMockRedisRepo) StoreVerificationCode(p, c string) error { return nil } +func (m *devMockRedisRepo) StoreVerificationCode(p, c string) error { return nil } func (m *devMockRedisRepo) GetVerificationCode(p string) (string, error) { return "", nil } -func (m *devMockRedisRepo) DeleteVerificationCode(p string) error { return nil } +func (m *devMockRedisRepo) DeleteVerificationCode(p string) error { return nil } type devEnhancedMockAuditRepo struct { mockAuditRepo @@ -77,6 +83,7 @@ type devEnhancedMockAuditRepo struct { func (m *devEnhancedMockAuditRepo) CountFailuresSince(ctx context.Context, s time.Time, t string) (int64, error) { return m.countFailures, nil } + func (m *devEnhancedMockAuditRepo) CountActiveSessionsSince(ctx context.Context, s time.Time, t string) (int64, error) { return m.countSessions, nil } diff --git a/devfront/tests/devfront-audit.spec.ts b/devfront/tests/devfront-audit.spec.ts index 7f1cc18e..0d8774c9 100644 --- a/devfront/tests/devfront-audit.spec.ts +++ b/devfront/tests/devfront-audit.spec.ts @@ -1,10 +1,10 @@ import { expect, test } from "@playwright/test"; import { + type AuditLog, + type Consent, installDevApiMock, makeClient, seedAuth, - type AuditLog, - type Consent, } from "./helpers/devfront-fixtures"; test.describe("DevFront audit logs", () => { @@ -85,7 +85,9 @@ test.describe("DevFront audit logs", () => { await installDevApiMock(page, state); await page.goto("/clients/new"); - await page.getByPlaceholder("My Awesome Application").fill("Realtime New App"); + await page + .getByPlaceholder("My Awesome Application") + .fill("Realtime New App"); await page .getByPlaceholder(/https:\/\/app\.example\.com\/callback/i) .fill("https://realtime.example.com/callback"); @@ -93,7 +95,9 @@ test.describe("DevFront audit logs", () => { await expect.poll(() => state.auditLogs.length).toBeGreaterThanOrEqual(1); await page.goto("/clients/client-realtime/settings"); - await page.getByPlaceholder("My Awesome Application").fill("Realtime Updated"); + await page + .getByPlaceholder("My Awesome Application") + .fill("Realtime Updated"); await page.getByRole("button", { name: /^저장$|^Save$/i }).click(); await expect.poll(() => state.auditLogs.length).toBeGreaterThanOrEqual(2); diff --git a/devfront/tests/devfront-clients-lifecycle.spec.ts b/devfront/tests/devfront-clients-lifecycle.spec.ts index d4a840be..7a662395 100644 --- a/devfront/tests/devfront-clients-lifecycle.spec.ts +++ b/devfront/tests/devfront-clients-lifecycle.spec.ts @@ -1,10 +1,10 @@ import { expect, test } from "@playwright/test"; import { + type ClientStatus, + type Consent, installDevApiMock, makeClient, seedAuth, - type ClientStatus, - type Consent, } from "./helpers/devfront-fixtures"; test.describe("DevFront clients lifecycle", () => { @@ -109,9 +109,9 @@ test.describe("DevFront clients lifecycle", () => { .getByRole("button", { name: /Redirect URIs 저장|Save/i }) .click(); - await expect.poll(() => state.clients[0]?.redirectUris[0]).toBe( - "https://after.example.com/callback", - ); + await expect + .poll(() => state.clients[0]?.redirectUris[0]) + .toBe("https://after.example.com/callback"); await page.reload(); await expect( diff --git a/devfront/tests/helpers/devfront-fixtures.ts b/devfront/tests/helpers/devfront-fixtures.ts index 92b01ade..e2f092cc 100644 --- a/devfront/tests/helpers/devfront-fixtures.ts +++ b/devfront/tests/helpers/devfront-fixtures.ts @@ -43,13 +43,19 @@ export type AuditLog = { export type DevApiMockState = { clients: Client[]; consents: Consent[]; - auditLogsByCursor?: Record; + auditLogsByCursor?: Record< + string, + { items: AuditLog[]; next_cursor?: string } + >; auditLogs?: AuditLog[]; onUpdateStatus?: (status: ClientStatus) => void; onRotateSecret?: (newSecret: string) => void; }; -export function makeClient(id: string, overrides: Partial = {}): Client { +export function makeClient( + id: string, + overrides: Partial = {}, +): Client { return { id, name: `${id} app`, @@ -301,7 +307,9 @@ export async function installDevApiMock(page: Page, state: DevApiMockState) { const status = searchParams.get("status") || ""; const items = state.consents.filter((row) => { const matchesSubject = - !subject || row.subject.includes(subject) || row.userName.includes(subject); + !subject || + row.subject.includes(subject) || + row.userName.includes(subject); const matchesClientId = !clientId || row.clientId === clientId; const matchesStatus = !status || row.status === status; return matchesSubject && matchesClientId && matchesStatus; @@ -347,7 +355,8 @@ export async function installDevApiMock(page: Page, state: DevApiMockState) { }; } catch {} const matchesAction = !action || parsedDetails.action === action; - const matchesClient = !clientId || parsedDetails.target_id === clientId; + const matchesClient = + !clientId || parsedDetails.target_id === clientId; const matchesStatus = !status || item.status === status; return matchesAction && matchesClient && matchesStatus; });