Files
Gnuboard7/tests/Playwright/specs/admin/settings-info-opcache.spec.ts
T
HeuJung 062a88ca04 feat(core): DB 최고권한 계정 차단 + OPcache 상태 안내
설치 단계와 코어 부팅의 정책이 엇갈려 있었다. 인스톨러는 root 를 자유롭게
허용하면서, 설치 후 부팅은 같은 값을 보고 확장 로딩 전체를 조용히 스킵했다.
설치는 성공하지만 이후 깨진 화면만 뜨고 원인은 로그 한 줄에만 남았다.

판정을 프레임워크 의존성 0 인 공용 SSoT 로 모아 인스톨러와 코어가 같은 답을
내게 하고, 설치 단계에서 서버 2경로로 차단하며, 설치 후 변경은 전용 에러
페이지로 드러낸다. 가드를 boot 가 아닌 미들웨어에 두어 artisan 이 죽지 않게
해 복구 수단을 남겼다. admin 은 일반 권한 운영 계정 오차단을 막기 위해 차단
목록에서 제외했다.

OPcache 는 상태 조회 경로 자체가 없어 성능 저하를 인지할 방법이 없었다.
설치 단계 경고(비차단)와 관리자 정보 탭 표시를 같은 판정 SSoT 로 추가했다.
확장 로드 여부만으로는 부족해 opcache.enable 지시자까지 확인하며, ini_get 이
차단된 환경은 "확인 불가"로 폴백해 경고도 차단도 하지 않는다.
2026-07-20 14:17:49 +09:00

113 lines
4.6 KiB
TypeScript

/**
* E2E: 환경설정 > 정보 — OPcache 상태 행 및 성능 저하 경고
*
* @scenario admin_settings_info_opcache
* @effects opcache_row_mounted, opcache_warning_conditional
*
* 배경: OPcache 는 코어 어디에서도 상태를 조회하지 않아, 비활성 환경에서 성능이
* 떨어져도 운영자가 인지할 경로가 없었다. 정보 탭에 상태를 노출하고, 비활성일 때만
* 성능 저하 경고를 띄운다.
*
* 검증:
* 1. 정보 탭에 OPcache 행이 마운트되고 값이 raw 키가 아닌 번역문으로 표시된다
* 2. 경고 블록은 enabled=false 일 때만 뜬다 (활성/확인불가에서는 뜨지 않는다)
* — API 응답을 가로채 세 상태를 모두 주입해 조건부 렌더를 검증한다
*/
import { test, expect, issueToken, authenticatePage } from '../../fixtures/auth';
const OPCACHE_ROW = '#opcache_row';
const OPCACHE_WARNING = '#opcache_warning';
const SYSTEM_INFO_API = '**/api/admin/settings/system-info*';
/** 관리자 환경설정 정보 탭 진입 */
async function gotoInfoTab(page: import('@playwright/test').Page): Promise<void> {
await page.goto('/admin/settings?tab=info');
await page.waitForLoadState('domcontentloaded', { timeout: 30_000 });
await expect(page.locator(OPCACHE_ROW)).toBeAttached({ timeout: 20_000 });
}
/**
* system-info 응답의 opcache 필드만 교체해 라우팅한다.
* 나머지 필드는 실제 서버 응답을 그대로 쓴다 (정보 탭 전체가 깨지지 않도록).
*/
async function stubOpcache(
page: import('@playwright/test').Page,
opcache: { loaded: boolean; enabled: boolean | null },
): Promise<void> {
await page.route(SYSTEM_INFO_API, async (route) => {
const response = await route.fetch();
const body = await response.json();
if (body?.data) {
body.data.opcache = opcache;
}
await route.fulfill({ response, json: body });
});
}
// @scenario tab=info, permitted=yes
// @effects opcache_row_mounted
test('@smoke - 정보 탭에 OPcache 상태 행이 번역문과 함께 마운트된다', async ({ page }) => {
const token = issueToken('core.settings.read', 'core.settings.update');
await authenticatePage(page, token);
await gotoInfoTab(page);
expect(page.url()).not.toMatch(/\/admin\/login/);
const row = page.locator(OPCACHE_ROW);
await expect(row).toBeAttached();
// 다국어 키가 해석되지 않으면 "$t:admin.settings.info.opcache" 원문이 그대로 노출된다
const text = (await row.innerText()).trim();
expect(text).not.toContain('$t:');
expect(text).toContain('OPcache');
// 값이 비어 있으면 상태 표현식이 해석되지 않은 것이다 (바인딩 회귀 가드)
expect(text.replace('OPcache', '').trim().length).toBeGreaterThan(0);
});
// @scenario tab=info, opcache_enabled=false
// @effects opcache_warning_conditional
test('- OPcache 비활성이면 성능 저하 경고 블록이 표시된다', async ({ page }) => {
const token = issueToken('core.settings.read', 'core.settings.update');
await authenticatePage(page, token);
await stubOpcache(page, { loaded: true, enabled: false });
await gotoInfoTab(page);
await expect(page.locator(OPCACHE_WARNING)).toBeVisible({ timeout: 20_000 });
const warningText = (await page.locator(OPCACHE_WARNING).innerText()).trim();
expect(warningText).not.toContain('$t:');
expect(warningText.length).toBeGreaterThan(0);
});
// @scenario tab=info, opcache_enabled=true
// @effects opcache_warning_conditional
test('- OPcache 활성이면 경고 블록이 표시되지 않는다', async ({ page }) => {
const token = issueToken('core.settings.read', 'core.settings.update');
await authenticatePage(page, token);
await stubOpcache(page, { loaded: true, enabled: true });
await gotoInfoTab(page);
// 행이 떠 있음을 먼저 확인해야(긍정 앵커) 아래 부정 단언이 의미를 갖는다
await expect(page.locator(OPCACHE_ROW)).toBeVisible();
await expect(page.locator(OPCACHE_WARNING)).toHaveCount(0);
});
// @scenario tab=info, opcache_enabled=null
// @effects opcache_warning_conditional
test('- OPcache 확인 불가(null)면 경고 블록이 표시되지 않는다', async ({ page }) => {
const token = issueToken('core.settings.read', 'core.settings.update');
await authenticatePage(page, token);
// `!enabled` 로 조건을 쓰면 null 에서도 경고가 잘못 뜬다 — 엄격 비교 회귀 가드
await stubOpcache(page, { loaded: true, enabled: null });
await gotoInfoTab(page);
await expect(page.locator(OPCACHE_ROW)).toBeVisible();
await expect(page.locator(OPCACHE_WARNING)).toHaveCount(0);
});