feat: 관리자 계정 식별자와 카카오 영구 교체 지원

관리자 승인과 사용자 OAuth 증명을 분리하고 기존 Kakao stable ID를 영구 폐기한다. 로그인 ID와 닉네임 변경은 현재 장수에 revision 기반으로 투영하며 과거 기록은 당시 이름으로 보존한다.
This commit is contained in:
2026-08-24 23:25:49 +00:00
parent e8dc7a65aa
commit 10cd1ed6d4
34 changed files with 1496 additions and 143 deletions
@@ -0,0 +1,107 @@
import { expect, test, type Page, type Route } from '@playwright/test';
import { writeFile } from 'node:fs/promises';
const response = (data: unknown) => ({ result: { data } });
const operationNames = (route: Route): string[] => {
const url = new URL(route.request().url());
return decodeURIComponent(url.pathname.slice(url.pathname.lastIndexOf('/trpc/') + 6)).split(',');
};
const installFixture = async (page: Page) => {
const requests: Array<{ operation: string; body: string }> = [];
await page.addInitScript(() => {
window.localStorage.setItem('sammo-session-token', 'kakao-replacement-session');
});
await page.route('**/gateway/api/trpc/**', async (route) => {
const body = route.request().postData() ?? '';
const results = operationNames(route).map((operation) => {
requests.push({ operation, body });
if (operation === 'account.get') {
return response({
id: 'replacement-user',
username: 'replacement-user',
displayName: '교체 사용자',
roles: ['user'],
oauthType: 'KAKAO',
email: 'replacement@example.test',
createdAt: '2026-08-01T00:00:00.000Z',
iconUrl: null,
icons: [],
preferredPicture: 'default.jpg',
maxActiveIcons: 5,
nextUploadAt: null,
nextRetireAt: null,
thirdPartyUse: false,
deleteAfter: null,
kakaoReplacementApprovedUntil: new Date(Date.now() + 86_400_000).toISOString(),
});
}
if (operation === 'account.notifications.get') {
return response({
capability: { enabled: false, publicKey: null },
eventTypes: [],
profiles: [],
preferences: [],
subscriptionCount: 0,
currentDeviceSubscribed: false,
});
}
if (operation === 'auth.kakaoStart') {
return response({
authUrl: `${new URL(route.request().url()).origin}/gateway/account?replacement=started`,
});
}
throw new Error(`Unhandled account replacement fixture operation: ${operation}`);
});
const isBatch = new URL(route.request().url()).searchParams.get('batch') === '1';
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify(isBatch ? results : results[0]),
});
});
return requests;
};
test('starts an approved Kakao replacement with explicit permanent-retirement confirmation', async ({
page,
}, testInfo) => {
const requests = await installFixture(page);
let confirmation = '';
page.on('dialog', async (dialog) => {
confirmation = dialog.message();
await dialog.accept();
});
await page.goto('account');
const button = page.getByRole('button', { name: '새 카카오 계정으로 교체' });
await expect(button).toBeVisible();
await expect(page.getByText(/교체 승인 .*까지/)).toBeVisible();
const initialBackground = await button.evaluate((element) => getComputedStyle(element).backgroundColor);
await button.hover();
await expect
.poll(() => button.evaluate((element) => getComputedStyle(element).backgroundColor))
.not.toBe(initialBackground);
await button.focus();
await expect(button).toBeFocused();
await page.screenshot({ path: testInfo.outputPath('account-kakao-replacement-desktop.png'), fullPage: true });
await button.click();
await expect(page).toHaveURL(/replacement=started/);
expect(confirmation).toContain('기존 카카오 계정은 영구 폐기');
const startRequest = requests.find(({ operation }) => operation === 'auth.kakaoStart');
expect(startRequest?.body).toContain('verify');
expect(startRequest?.body).toContain('kakao-replacement-session');
await page.setViewportSize({ width: 500, height: 844 });
const mobileButton = page.getByRole('button', { name: '새 카카오 계정으로 교체' });
await expect(mobileButton).toBeVisible();
const geometry = await mobileButton.evaluate((element) => {
const rect = element.getBoundingClientRect();
return { left: rect.left, right: rect.right, width: rect.width, viewportWidth: window.innerWidth };
});
expect(geometry.left).toBeGreaterThanOrEqual(0);
expect(geometry.right).toBeLessThanOrEqual(geometry.viewportWidth);
await writeFile(testInfo.outputPath('account-kakao-replacement-mobile-geometry.json'), JSON.stringify(geometry));
await page.screenshot({ path: testInfo.outputPath('account-kakao-replacement-mobile.png'), fullPage: true });
});
@@ -11,6 +11,9 @@ const installFixture = async (page: Page) => {
const requests: Array<{ operation: string; body: unknown }> = [];
let deleteAfter: string | null = null;
let graceUntil: string | null = null;
let username = 'target';
let displayName = '대상 사용자';
let kakaoReplacementApprovedUntil: string | null = null;
let specialGrants: Array<Record<string, unknown>> = [];
const auditHistory = [
{
@@ -74,10 +77,10 @@ const installFixture = async (page: Page) => {
users: [
{
id: 'target-user',
username: 'target',
displayName: '대상 사용자',
username,
displayName,
email: 'target@example.test',
oauthType: 'NONE',
oauthType: 'KAKAO',
roles: ['user'],
hasActiveSanction: false,
deleteAfter,
@@ -111,11 +114,13 @@ const installFixture = async (page: Page) => {
if (operation === 'admin.users.lookup') {
return response({
id: 'target-user',
username: 'target',
displayName: '대상 사용자',
username,
displayName,
roles: ['user'],
sanctions: {},
oauthType: 'NONE',
oauthType: 'KAKAO',
oauthId: 'fixture-kakao-stable-id',
kakaoReplacementApprovedUntil,
kakaoGraceStartedAt: '2026-07-20T00:00:00.000Z',
kakaoGraceUntil: graceUntil,
deleteAfter,
@@ -164,6 +169,27 @@ const installFixture = async (page: Page) => {
});
return response({ kakaoGraceUntil: graceUntil });
}
if (operation === 'admin.users.updateIdentity') {
username = 'target-renamed';
displayName = '변경된 대상';
auditHistory.unshift({
...auditHistory[0],
id: 'audit-identity',
action: 'admin.users.updateIdentity',
reason: '고객 본인 확인 완료',
});
return response({ username, displayName, identityRevision: '2026-08-24T12:00:00.000Z' });
}
if (operation === 'admin.users.setKakaoReplacementApproval') {
kakaoReplacementApprovedUntil = '2026-08-26T00:00:00.000Z';
auditHistory.unshift({
...auditHistory[0],
id: 'audit-kakao-replacement',
action: 'admin.users.setKakaoReplacementApproval',
reason: '기존 단말 분실 교체',
});
return response({ kakaoReplacementApprovedUntil });
}
if (operation === 'admin.users.grantSpecialAccess') {
specialGrants = [
{
@@ -219,6 +245,18 @@ test('operates OAuth grace and scheduled deletion with reasoned audit history',
await expect(page.getByText('Kakao 인증: 미완료')).toBeVisible();
await expect(page.getByRole('navigation', { name: '사용자 관리 기능' })).toBeVisible();
await expect(page.getByRole('heading', { name: '비밀번호 리셋' })).toBeHidden();
await expect(page.getByRole('heading', { name: 'ID · 닉네임 변경' })).toBeVisible();
await page.getByLabel('로그인 ID').fill('target-renamed');
await page.getByLabel('닉네임').fill('변경된 대상');
await page.getByPlaceholder('권한·제재·복구·탈퇴 조치 사유 (필수)').fill('고객 본인 확인 완료');
await page.getByRole('button', { name: 'ID · 닉네임 변경', exact: true }).click();
await expect(page.getByText('ID와 닉네임을 변경했습니다.').first()).toBeVisible();
await page.getByLabel('Kakao 계정 교체 승인 만료 시각').fill('2026-08-26T00:00');
await page.getByPlaceholder('권한·제재·복구·탈퇴 조치 사유 (필수)').fill('기존 단말 분실 교체');
await page.getByRole('button', { name: '교체 승인', exact: true }).click();
await expect(page.getByText('새 카카오 계정 교체를 승인했습니다.').first()).toBeVisible();
expect(requests.some(({ operation }) => operation === 'admin.users.updateIdentity')).toBe(true);
expect(requests.some(({ operation }) => operation === 'admin.users.setKakaoReplacementApproval')).toBe(true);
await page.getByRole('button', { name: /접근 · 권한/ }).click();
await expect(page.getByRole('option', { name: /Profile 전체 운영/ })).toHaveCount(0);
await expect(page.getByRole('option', { name: /Profile 실행 관리/ })).toHaveCount(1);
@@ -11,6 +11,7 @@ export default defineConfig({
'server-operations.spec.ts',
'admin-runtime-actions.spec.ts',
'admin-account-controls.spec.ts',
'account-kakao-replacement.spec.ts',
'lobby-admin-navigation.spec.ts',
'lobby-game-auth.spec.ts',
'logout.spec.ts',