feat(core): DB 최고권한 계정 차단 + OPcache 상태 안내

설치 단계와 코어 부팅의 정책이 엇갈려 있었다. 인스톨러는 root 를 자유롭게
허용하면서, 설치 후 부팅은 같은 값을 보고 확장 로딩 전체를 조용히 스킵했다.
설치는 성공하지만 이후 깨진 화면만 뜨고 원인은 로그 한 줄에만 남았다.

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

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

No files matched your search

@@ -14,6 +14,7 @@ use App\Services\SettingsService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Mail;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
/**
@@ -1490,6 +1491,150 @@ class SettingsControllerTest extends TestCase
]);
}
/**
* OPcache 상태가 시스템 정보 페이로드에 포함된다.
*
* 관리자 환경설정 > 정보 탭이 이 값으로 상태 행과 성능 저하 경고 블록을 렌더한다.
* enabled 는 true/false 외에 null("확인 불가" — ini_get 차단 환경)을 가질 수 있다.
*
* @scenario probe_item=opcache,probe_outcome=success,auth_state=authenticated_with_permission
*
* @effects opcache_status_exposed_in_system_info
*/
public function test_system_info_includes_opcache_status(): void
{
$cache = $this->app->make(CacheInterface::class);
$cache->forget('settings.system_info.'.app()->getLocale());
$response = $this->authRequest()->getJson('/api/admin/settings/system-info');
$response->assertStatus(200)
->assertJsonStructure([
'data' => [
'opcache' => ['loaded', 'enabled'],
],
]);
$opcache = $response->json('data.opcache');
$this->assertIsBool($opcache['loaded']);
$this->assertTrue(
$opcache['enabled'] === null || is_bool($opcache['enabled']),
'opcache.enabled 는 true/false/null 중 하나여야 합니다.'
);
}
// 아래 test_system_info_reports_each_opcache_state 의 DataProvider 가 함께 검증하는
// 나머지 3개 조합 (docblock 은 @scenario 를 1건만 인식하므로 라인 주석으로 병기).
// @scenario opcache_state=loaded_but_disabled, surface=system_info_api
// @effects opcache_status_exposed_in_system_info
// @scenario opcache_state=not_loaded, surface=system_info_api
// @effects opcache_status_exposed_in_system_info
// @scenario opcache_state=ini_get_blocked, surface=system_info_api
// @effects opcache_status_exposed_in_system_info
/**
* OPcache 판정 결과가 API 페이로드에 그대로 실려 나온다.
*
* 관리자 정보 탭이 이 값으로 상태 행과 경고 블록을 렌더하므로, 네 가지 상태가
* 각각 구별되어 전달되어야 한다. 특히 loaded_but_disabled(확장은 로드됐으나
* opcache.enable=0)와 ini_get_blocked(null)이 뭉개지면 화면 판단이 무너진다.
*
* @scenario opcache_state=enabled, surface=system_info_api
*
* @effects opcache_status_exposed_in_system_info
*/
#[DataProvider('opcacheStateProvider')]
public function test_system_info_reports_each_opcache_state(array $probe): void
{
$cache = $this->app->make(CacheInterface::class);
$cache->forget('settings.system_info.'.app()->getLocale());
$service = new class($this->app, $probe) extends SettingsService
{
private array $stub;
public function __construct($app, array $stub)
{
parent::__construct(
$app->make(ConfigRepositoryInterface::class),
$app->make(AttachmentRepositoryInterface::class),
$app->make(CacheInterface::class),
);
$this->stub = $stub;
}
protected function getOpcacheStatus(): array
{
return $this->stub;
}
};
$this->app->instance(SettingsService::class, $service);
$response = $this->authRequest()->getJson('/api/admin/settings/system-info');
$response->assertStatus(200);
$this->assertSame($probe, $response->json('data.opcache'));
}
/**
* @return array<string, array{0: array{loaded: bool, enabled: bool|null}}>
*/
public static function opcacheStateProvider(): array
{
return [
'enabled' => [['loaded' => true, 'enabled' => true]],
'loaded_but_disabled' => [['loaded' => true, 'enabled' => false]],
'not_loaded' => [['loaded' => false, 'enabled' => false]],
'ini_get_blocked' => [['loaded' => true, 'enabled' => null]],
];
}
/**
* OPcache probe 가 실패해도 격리되어 전체 200 이 유지된다.
*
* ini_get 이 disable_functions 로 차단된 호스팅에서 probe 하나가 죽어
* system-info API 전체가 500 이 나는 것을 방지한다.
*
* @scenario probe_item=opcache,probe_outcome=throws_error,auth_state=authenticated_with_permission
*
* @effects failing_probe_isolated_and_api_returns_200
* @effects failed_item_filled_with_unknown_fallback
*/
public function test_system_info_isolates_failing_opcache_probe(): void
{
$cache = $this->app->make(CacheInterface::class);
$cache->forget('settings.system_info.'.app()->getLocale());
$service = new class($this->app) extends SettingsService
{
public function __construct($app)
{
parent::__construct(
$app->make(ConfigRepositoryInterface::class),
$app->make(AttachmentRepositoryInterface::class),
$app->make(CacheInterface::class),
);
}
protected function getOpcacheStatus(): array
{
throw new \Error('Call to undefined function ini_get() (disable_functions)');
}
};
$this->app->instance(SettingsService::class, $service);
$response = $this->authRequest()->getJson('/api/admin/settings/system-info');
$response->assertStatus(200)
->assertJson([
'success' => true,
'data' => [
'opcache' => ['loaded' => false, 'enabled' => null],
],
]);
}
/**
* 사용량 조회 실패 시 폴백 배열 구조 검증: unknownUsage 는 total/used/free 를
* 'unknown' 으로, percentage 를 0 으로 채워 memory_usage·disk_usage 형식을 유지한다.
@@ -0,0 +1,305 @@
<?php
namespace Tests\Feature\Middleware;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;
/**
* DatabaseCredentialGuard 미들웨어 회귀 테스트
*
* 배경: 설치 후 `.env` 의 DB 사용자명을 최고권한 계정으로 바꾸거나 비우면
* CoreServiceProvider 가 확장 로딩 전체를 스킵한다. 그 결과 템플릿이 없는 깨진
* 화면만 뜨고 원인은 storage/logs 의 ERROR 한 줄에만 남아, 운영자가 무엇이
* 잘못됐는지 알 방법이 없었다("조용한 실패"). 본 미들웨어가 그 상황을 전용
* 에러 페이지로 드러내는지 보장한다.
*
* 검증 축 (계정종류 × 요청유형 × 설치상태):
* - 계정: 정상 / 최고권한(root·postgres·대문자·공백) / 빈 값
* - 요청: 웹 / API(JSON) — 콘솔은 미들웨어를 타지 않으므로 구조로 보장
* - 설치상태: 완료 / 미완료(설치 전에는 통과해야 함)
* - 정보 유출: 에러 페이지에 실제 계정명이 노출되지 않을 것
*/
class DatabaseCredentialGuardTest extends TestCase
{
/**
* DB 커넥션 설정의 사용자명을 교체합니다.
*
* 미들웨어는 DB 에 접속하지 않고 config 배열만 읽으므로, 실제 커넥션을
* 훼손하지 않고(=RefreshDatabase 트랜잭션 유지) 판정만 바꿀 수 있습니다.
*
* @param string|null $username 주입할 사용자명
*/
private function setDbUsername(?string $username): void
{
$connection = config('database.default');
config([
"database.connections.{$connection}.username" => $username,
"database.connections.{$connection}.read.username" => $username,
"database.connections.{$connection}.write.username" => $username,
]);
}
/**
* 설치 완료 상태에서 정상 계정이면 웹 요청을 통과시켜야 한다.
*
* @scenario account_kind=normal, enforcement_point=runtime_web, install_state=completed
*
* @effects runtime_passes_through_with_normal_account
*/
public function test_passes_through_with_normal_account(): void
{
config(['app.installer_completed' => true]);
$this->setDbUsername('g7user');
$response = $this->get('/');
$this->assertNotEquals(503, $response->getStatusCode());
}
/**
* 정상 계정이면 API 요청도 통과시켜야 한다 (과잉 차단 방지).
*
* @scenario account_kind=normal, enforcement_point=runtime_api, install_state=completed
*
* @effects runtime_passes_through_with_normal_account
*/
public function test_passes_through_with_normal_account_for_api(): void
{
config(['app.installer_completed' => true]);
$this->setDbUsername('g7user');
$response = $this->getJson('/api/test');
$this->assertNotEquals(503, $response->getStatusCode());
}
/**
* 최고권한 계정이면 웹 요청에 503 전용 에러 페이지를 반환해야 한다.
*
* @scenario account_kind=privileged, enforcement_point=runtime_web, install_state=completed
*
* @effects runtime_returns_503_error_page
*/
#[DataProvider('privilegedUsernameProvider')]
public function test_returns_error_page_for_privileged_account(string $username): void
{
config(['app.installer_completed' => true]);
$this->setDbUsername($username);
$response = $this->get('/');
$response->assertStatus(503);
$response->assertViewIs('database-credential-error');
}
/**
* 빈 사용자명(설정 누락)도 동일하게 전용 에러 페이지를 반환해야 한다.
*
* @scenario account_kind=empty, enforcement_point=runtime_web, install_state=completed
*
* @effects runtime_returns_503_error_page
*/
#[DataProvider('emptyUsernameProvider')]
public function test_returns_error_page_for_empty_account(?string $username): void
{
config(['app.installer_completed' => true]);
$this->setDbUsername($username);
$response = $this->get('/');
$response->assertStatus(503);
$response->assertViewIs('database-credential-error');
}
/**
* @return array<string, array{0: string}>
*/
public static function privilegedUsernameProvider(): array
{
return [
'root' => ['root'],
'postgres' => ['postgres'],
'대문자 ROOT (우회 차단)' => ['ROOT'],
'앞뒤 공백 " root " (우회 차단)' => [' root '],
];
}
/**
* @return array<string, array{0: string|null}>
*/
public static function emptyUsernameProvider(): array
{
return [
'빈 문자열 (설정 누락)' => [''],
'null (설정 누락)' => [null],
];
}
/**
* 최고권한 계정일 때 API 요청에는 HTML 이 아니라 JSON 503 을 반환해야 한다.
*
* @scenario account_kind=privileged, enforcement_point=runtime_api, install_state=completed
*
* @effects runtime_returns_503_json_for_api
*/
public function test_returns_json_for_api_requests(): void
{
config(['app.installer_completed' => true]);
$this->setDbUsername('root');
$response = $this->getJson('/api/test');
$response->assertStatus(503);
$response->assertJson(['success' => false]);
}
/**
* 빈 사용자명일 때도 api/* 경로는 Accept 헤더와 무관하게 JSON 이어야 한다.
*
* @scenario account_kind=empty, enforcement_point=runtime_api, install_state=completed
*
* @effects runtime_returns_503_json_for_api
*/
public function test_returns_json_for_api_path_requests(): void
{
config(['app.installer_completed' => true]);
$this->setDbUsername('');
$response = $this->get('/api/settings');
$response->assertStatus(503);
$response->assertHeader('content-type', 'application/json');
}
/**
* 설치 전(installer_completed=false)에는 최고권한 계정이어도 통과해야 한다.
*
* 설치 전에는 DB 설정이 비어 있는 것이 정상이며, public/index.php 가
* 이미 /install 로 유도한다. 여기서 막으면 설치 자체가 불가능해진다.
*
* @scenario account_kind=privileged, enforcement_point=runtime_web, install_state=not_completed
*
* @effects runtime_passes_through_when_not_installed
*/
public function test_passes_through_when_not_installed(): void
{
config(['app.installer_completed' => false]);
$this->setDbUsername('root');
$response = $this->get('/');
$this->assertNotEquals(503, $response->getStatusCode());
}
/**
* 설치 전에는 사용자명이 비어 있어도 통과해야 한다 (설치 전 정상 상태).
*
* @scenario account_kind=empty, enforcement_point=runtime_web, install_state=not_completed
*
* @effects runtime_passes_through_when_not_installed
*/
public function test_passes_through_when_not_installed_with_empty_username(): void
{
config(['app.installer_completed' => false]);
$this->setDbUsername('');
$response = $this->get('/');
$this->assertNotEquals(503, $response->getStatusCode());
}
/**
* 에러 페이지는 미인증 공개 페이지이므로 실제 DB 계정명을 노출하면 안 된다.
*
* @effects error_page_does_not_leak_account_name
*/
public function test_error_page_does_not_leak_account_name(): void
{
config(['app.installer_completed' => true]);
$this->setDbUsername('postgres');
$response = $this->get('/');
$content = $response->getContent();
$response->assertStatus(503);
$this->assertStringNotContainsString('postgres', $content);
}
/**
* 확장·템플릿이 로딩되지 않은 상태에서 뜨는 페이지이므로
* 외부 에셋(JS/CSS)에 의존하지 않고 자체 완결이어야 한다.
*
* @effects error_page_is_self_contained_without_external_assets
*/
public function test_error_page_has_no_external_dependencies(): void
{
config(['app.installer_completed' => true]);
$this->setDbUsername('root');
$response = $this->get('/');
$content = $response->getContent();
$response->assertStatus(503);
$this->assertStringNotContainsString('<script src=', $content);
$this->assertStringNotContainsString('<link rel="stylesheet" href=', $content);
$this->assertStringContainsString('<style>', $content);
}
/**
* SetLocale 미들웨어가 실행되지 않는 지점이므로 자체 로케일 감지가 동작해야 한다.
*
* @effects error_page_detects_locale_without_setlocale_middleware
*/
#[DataProvider('localeProvider')]
public function test_error_page_is_localized(string $acceptLanguage, string $locale): void
{
config(['app.installer_completed' => true]);
$this->setDbUsername('root');
$response = $this->withHeaders(['Accept-Language' => $acceptLanguage])->get('/');
$response->assertStatus(503);
$response->assertSee(__('database_credential.title', [], $locale));
}
/**
* @return array<string, array{0: string, 1: string}>
*/
public static function localeProvider(): array
{
return [
'한국어' => ['ko,en;q=0.9', 'ko'],
'영어' => ['en,ko;q=0.9', 'en'],
];
}
/**
* 메인터넌스 모드가 우선해야 한다 — 점검 중에는 점검 페이지가 맞다.
*
* @effects maintenance_mode_takes_precedence_over_credential_guard
*/
public function test_maintenance_mode_takes_precedence(): void
{
config(['app.installer_completed' => true]);
$this->setDbUsername('root');
$downFile = storage_path('framework/down');
file_put_contents($downFile, json_encode([
'except' => [], 'redirect' => null, 'retry' => null,
'refresh' => null, 'status' => 503, 'template' => null,
]));
try {
$response = $this->get('/');
$response->assertStatus(503);
$response->assertViewIs('maintenance');
} finally {
if (file_exists($downFile)) {
unlink($downFile);
}
}
}
}
@@ -0,0 +1,112 @@
/**
* 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);
});
@@ -0,0 +1,286 @@
<?php
namespace Tests\Unit\Installer;
use App\Support\PrivilegedDatabaseAccounts;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
/**
* 인스톨러 DB 최고권한 계정 차단 회귀 테스트
*
* 배경: 인스톨러에는 사용자명 검증이 전무했고, `.env.example` fallback 기본값이
* `DB_WRITE_USERNAME=root` 였다. 그 결과 root 로 설치하면 설치는 성공하지만
* 이후 코어 부팅이 확장 로딩 전체를 스킵해 깨진 화면만 남았다.
* 설치 단계에서 미리 차단하는지 보장한다.
*
* 검증 축:
* - Step 3 폼 POST 검증: Write DB / Read DB 양쪽, 최고권한 / 빈 값 / 정상
* - 인스톨러가 코어와 같은 판정 SSoT 를 공유하는지 (목록 이원화 차단)
* - 다국어 키 존재 및 :username 치환 동작 (ko/en)
*/
class PrivilegedDbAccountGuardTest extends TestCase
{
public static function setUpBeforeClass(): void
{
if (! defined('BASE_PATH')) {
define('BASE_PATH', dirname(__DIR__, 3));
}
require_once dirname(__DIR__, 3).'/public/install/includes/config.php';
require_once dirname(__DIR__, 3).'/public/install/includes/functions.php';
require_once dirname(__DIR__, 3).'/public/install/includes/request-handler.php';
}
protected function setUp(): void
{
parent::setUp();
// lang() 은 전역 $translations 를 읽는다 (functions.php:316).
$GLOBALS['translations'] = require dirname(__DIR__, 3).'/public/install/lang/ko.php';
}
/**
* config.php 가 코어의 판정 SSoT 클래스를 로드해야 한다.
* 인스톨러가 자체 목록을 갖게 되면 코어와 판정이 어긋난다.
*
* @effects installer_and_core_share_the_same_judgement_class
*/
public function test_installer_loads_shared_judgement_class(): void
{
$this->assertTrue(
class_exists(PrivilegedDatabaseAccounts::class),
'config.php 가 PrivilegedDatabaseAccounts 를 로드하지 않았습니다.'
);
}
/**
* Step 3 폼 POST 에서 Write DB 최고권한 계정이 거부되어야 한다.
*
* @scenario account_kind=privileged, enforcement_point=installer_step3_write, install_state=not_completed
*
* @effects installer_step3_post_rejects_privileged_username
*/
#[DataProvider('privilegedUsernameProvider')]
public function test_step3_rejects_privileged_write_username(string $username): void
{
$errors = [];
validateDbUsername($username, 'db_write_username', $errors);
$this->assertArrayHasKey(
'db_write_username',
$errors,
sprintf('사용자명 "%s" 이 거부되지 않았습니다.', $username)
);
}
/**
* Read DB 도 동일하게 차단되어야 한다 (Write 만 막으면 Read 로 우회 가능).
*
* @scenario account_kind=privileged, enforcement_point=installer_step3_read, install_state=not_completed
*
* @effects installer_step3_post_rejects_privileged_username
*/
#[DataProvider('privilegedUsernameProvider')]
public function test_step3_rejects_privileged_read_username(string $username): void
{
$errors = [];
validateDbUsername($username, 'db_read_username', $errors);
$this->assertArrayHasKey('db_read_username', $errors);
}
/**
* 빈 사용자명(설정 누락)도 Write DB 에서 거부되어야 한다.
*
* @scenario account_kind=empty, enforcement_point=installer_step3_write, install_state=not_completed
*
* @effects installer_step3_post_rejects_empty_username
*/
#[DataProvider('emptyUsernameProvider')]
public function test_step3_rejects_empty_write_username(string $username): void
{
$errors = [];
validateDbUsername($username, 'db_write_username', $errors);
$this->assertArrayHasKey('db_write_username', $errors);
}
/**
* 빈 사용자명은 Read DB 에서도 거부되어야 한다.
*
* @scenario account_kind=empty, enforcement_point=installer_step3_read, install_state=not_completed
*
* @effects installer_step3_post_rejects_empty_username
*/
#[DataProvider('emptyUsernameProvider')]
public function test_step3_rejects_empty_read_username(string $username): void
{
$errors = [];
validateDbUsername($username, 'db_read_username', $errors);
$this->assertArrayHasKey('db_read_username', $errors);
}
/**
* @return array<string, array{0: string}>
*/
public static function privilegedUsernameProvider(): array
{
return [
'root' => ['root'],
'postgres' => ['postgres'],
'sa' => ['sa'],
'sys' => ['sys'],
'system' => ['system'],
'대문자 ROOT (우회 차단)' => ['ROOT'],
'앞뒤 공백 " root " (우회 차단)' => [' root '],
];
}
/**
* @return array<string, array{0: string}>
*/
public static function emptyUsernameProvider(): array
{
return [
'빈 문자열' => [''],
'공백만' => [' '],
];
}
/**
* 정상 계정은 Write DB 에서 통과해야 한다 — 특히 `admin` 오차단 방지.
*
* @scenario account_kind=normal, enforcement_point=installer_step3_write, install_state=not_completed
*
* @effects installer_step3_post_accepts_normal_username
*/
#[DataProvider('acceptedUsernameProvider')]
public function test_step3_accepts_normal_write_username(string $username): void
{
$errors = [];
validateDbUsername($username, 'db_write_username', $errors);
$this->assertSame(
[],
$errors,
sprintf('정상 사용자명 "%s" 이 잘못 거부됐습니다.', $username)
);
}
/**
* 정상 계정은 Read DB 에서도 통과해야 한다 (과잉 차단 방지).
*
* @scenario account_kind=normal, enforcement_point=installer_step3_read, install_state=not_completed
*
* @effects installer_step3_post_accepts_normal_username
*/
#[DataProvider('acceptedUsernameProvider')]
public function test_step3_accepts_normal_read_username(string $username): void
{
$errors = [];
validateDbUsername($username, 'db_read_username', $errors);
$this->assertSame([], $errors);
}
/**
* @return array<string, array{0: string}>
*/
public static function acceptedUsernameProvider(): array
{
return [
'g7user' => ['g7user'],
'admin (일반 권한 계정 오차단 방지)' => ['admin'],
'rootuser' => ['rootuser'],
'g7_root' => ['g7_root'],
'my_site_db' => ['my_site_db'],
];
}
/**
* 빈 값과 최고권한 계정은 서로 다른 메시지여야 한다 — 운영자가 원인을 구분해야 한다.
*
* @effects empty_and_privileged_produce_distinct_messages
*/
public function test_empty_and_privileged_produce_different_messages(): void
{
$emptyErrors = [];
validateDbUsername('', 'db_write_username', $emptyErrors);
$privilegedErrors = [];
validateDbUsername('root', 'db_write_username', $privilegedErrors);
$this->assertNotSame(
$emptyErrors['db_write_username'],
$privilegedErrors['db_write_username']
);
}
/**
* 차단 메시지는 입력한 계정명을 치환해 보여줘야 한다 (:username).
*
* @effects installer_message_substitutes_username_and_offers_alternative
*/
public function test_privileged_message_substitutes_username(): void
{
$errors = [];
validateDbUsername('postgres', 'db_write_username', $errors);
$message = $errors['db_write_username'];
$this->assertStringContainsString('postgres', $message);
$this->assertStringNotContainsString(':username', $message, '치환되지 않은 플레이스홀더가 남아 있습니다.');
}
/**
* 차단만 하고 해결책이 없으면 사용자가 진행 불가 상태에 갇힌다.
* ko/en 양쪽 문구가 대안(전용 계정 생성)을 제시하는지 확인한다.
*/
#[DataProvider('localeProvider')]
public function test_message_offers_an_alternative(string $locale, string $needle): void
{
$translations = require dirname(__DIR__, 3)."/public/install/lang/{$locale}.php";
$this->assertArrayHasKey('error_db_username_privileged', $translations);
$this->assertStringContainsString($needle, $translations['error_db_username_privileged']);
}
/**
* @return array<string, array{0: string, 1: string}>
*/
public static function localeProvider(): array
{
return [
'ko' => ['ko', '전용 데이터베이스 사용자'],
'en' => ['en', 'dedicated database user'],
];
}
/**
* OPcache 관련 다국어 키가 ko/en 양쪽에 존재해야 한다 (요구사항 카드 렌더용).
*
* @effects installer_opcache_lang_keys_exist_in_ko_and_en
*/
#[DataProvider('opcacheLocaleProvider')]
public function test_opcache_lang_keys_exist(string $locale): void
{
$translations = require dirname(__DIR__, 3)."/public/install/lang/{$locale}.php";
foreach (['opcache', 'opcache_enabled', 'opcache_disabled_short', 'opcache_disabled_warning', 'opcache_unknown'] as $key) {
$this->assertArrayHasKey($key, $translations, sprintf('%s 로케일에 %s 키가 없습니다.', $locale, $key));
}
}
/**
* @return array<string, array{0: string}>
*/
public static function opcacheLocaleProvider(): array
{
return [
'ko' => ['ko'],
'en' => ['en'],
];
}
}
+161
View File
@@ -0,0 +1,161 @@
<?php
namespace Tests\Unit\Support;
use App\Support\OpcacheStatus;
use PHPUnit\Framework\TestCase;
/**
* OPcache 상태 판정 SSoT 단위 테스트
*
* 인스톨러(요구사항 화면)와 코어(관리자 정보 탭)가 같은 답을 내야 하므로,
* 이 클래스는 Laravel 부트 없이 동작해야 한다. 본 테스트가
* `PHPUnit\Framework\TestCase` 를 직접 상속하는 것은 그 "의존성 0" 속성을
* 검증하기 위함이다.
*
* 검증 축:
* - 확장 미로드 → enabled=false (확인 불가 아님)
* - 확장 로드 + opcache.enable=1 → enabled=true
* - 확장 로드 + opcache.enable=0 → enabled=false (로드만으로 판정하면 안 되는 케이스)
* - 확장 로드 + ini_get 차단(disable_functions) → enabled=null (확인 불가)
*/
class OpcacheStatusTest extends TestCase
{
/**
* @scenario opcache_state=not_loaded, surface=judgement_ssot
*
* @effects not_loaded_reports_disabled_not_unknown
*/
public function test_extension_not_loaded_reports_disabled(): void
{
$result = OpcacheStatus::probe(
extensionLoaded: fn () => false,
iniGet: fn () => $this->fail('확장 미로드 시 ini_get 을 호출하면 안 됩니다.'),
);
$this->assertSame(['loaded' => false, 'enabled' => false], $result);
}
/**
* @scenario opcache_state=enabled, surface=judgement_ssot
*
* @effects on_off_directive_values_parsed
*/
public function test_loaded_and_enabled_reports_enabled(): void
{
$result = OpcacheStatus::probe(
extensionLoaded: fn (string $name) => $name === OpcacheStatus::EXTENSION_NAME,
iniGet: fn () => '1',
);
$this->assertSame(['loaded' => true, 'enabled' => true], $result);
}
/**
* 확장이 로드돼 있어도 opcache.enable=0 이면 실제로는 동작하지 않는다.
* 확장 로드 여부만으로 판정하는 회귀를 차단한다.
*
* @scenario opcache_state=loaded_but_disabled, surface=judgement_ssot
*
* @effects loaded_but_disabled_directive_reports_disabled
*/
public function test_loaded_but_disabled_directive_reports_disabled(): void
{
$result = OpcacheStatus::probe(
extensionLoaded: fn () => true,
iniGet: fn () => '0',
);
$this->assertSame(['loaded' => true, 'enabled' => false], $result);
}
/**
* ini_get 이 disable_functions 로 차단돼 Error 를 던지는 환경.
* 경고도 차단도 아닌 "확인 불가"(null) 로 폴백해야 한다.
*
* @scenario opcache_state=ini_get_blocked, surface=judgement_ssot
*
* @effects ini_get_blocked_reports_unknown_null
*/
public function test_ini_get_blocked_reports_unknown(): void
{
$result = OpcacheStatus::probe(
extensionLoaded: fn () => true,
iniGet: fn () => throw new \Error('Call to undefined function ini_get()'),
);
$this->assertSame(['loaded' => true, 'enabled' => null], $result);
}
/**
* ini_get 은 지시자를 못 읽으면 false 를 반환한다. 값 '0'(비활성 확정) 과
* 구분해 "확인 불가" 로 처리해야 한다.
*
* @effects ini_get_false_distinguished_from_value_zero
*/
public function test_ini_get_returning_false_reports_unknown(): void
{
$result = OpcacheStatus::probe(
extensionLoaded: fn () => true,
iniGet: fn () => false,
);
$this->assertSame(['loaded' => true, 'enabled' => null], $result);
}
public function test_ini_get_returning_empty_string_reports_unknown(): void
{
$result = OpcacheStatus::probe(
extensionLoaded: fn () => true,
iniGet: fn () => '',
);
$this->assertSame(['loaded' => true, 'enabled' => null], $result);
}
/**
* php.ini 는 On/Off 표기도 허용한다.
*/
public function test_on_off_directive_values_are_parsed(): void
{
$this->assertTrue(
OpcacheStatus::probe(fn () => true, fn () => 'On')['enabled']
);
$this->assertFalse(
OpcacheStatus::probe(fn () => true, fn () => 'Off')['enabled']
);
}
/**
* 인수 없이 호출해도 예외 없이 계약된 구조를 반환해야 한다
* (실행 환경의 실제 OPcache 상태와 무관하게 형태만 검증).
*/
public function test_default_probe_returns_contracted_shape(): void
{
$result = OpcacheStatus::probe();
$this->assertArrayHasKey('loaded', $result);
$this->assertArrayHasKey('enabled', $result);
$this->assertIsBool($result['loaded']);
$this->assertTrue($result['enabled'] === null || is_bool($result['enabled']));
}
/**
* 인스톨러가 Laravel 오토로드 없이 `require_once` 로 로드할 수 있어야 하므로,
* 소스에 프레임워크 심볼 참조가 없어야 한다.
*/
public function test_source_has_no_framework_dependency(): void
{
$source = file_get_contents(dirname(__DIR__, 3).'/app/Support/OpcacheStatus.php');
$this->assertIsString($source);
foreach (['use Illuminate', 'Illuminate\\', 'config(', 'app(', '__(', 'trans('] as $forbidden) {
$this->assertStringNotContainsString(
$forbidden,
$source,
sprintf('인스톨러 공용 클래스에 프레임워크 의존("%s")이 포함됐습니다.', $forbidden)
);
}
}
}
@@ -0,0 +1,161 @@
<?php
namespace Tests\Unit\Support;
use App\Support\PrivilegedDatabaseAccounts;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
/**
* DB 최고권한 계정 판정 SSoT 단위 테스트
*
* 인스톨러와 코어가 같은 판정을 내려야 하므로, 이 클래스는 Laravel 부트 없이
* 동작해야 한다. 본 테스트가 `PHPUnit\Framework\TestCase` 를 직접 상속하는 것은
* 그 "의존성 0" 속성 자체를 검증하기 위함이다 (Tests\TestCase 사용 금지).
*
* 검증 축:
* - 계정 종류: 최고권한(root/postgres/sa/sys/system) / 일반 / 빈 값 / null
* - 표기 변형: 대문자 / 앞뒤 공백 (우회 차단)
* - isBlocked 와 isUsable 의 책임 분리 (빈 값은 blocked 아님, 그러나 usable 도 아님)
*/
class PrivilegedDatabaseAccountsTest extends TestCase
{
/**
* 최고권한 계정 판정 — 대문자·앞뒤 공백 변형까지 정규화해 차단한다.
*
* @scenario account_kind=privileged, enforcement_point=judgement_ssot, install_state=completed
*
* @effects privileged_account_detected_case_and_whitespace_insensitive
* @effects admin_account_not_blocked
*/
#[DataProvider('blockedProvider')]
public function test_is_blocked_detects_privileged_accounts(?string $username, bool $expected): void
{
$this->assertSame(
$expected,
PrivilegedDatabaseAccounts::isBlocked($username),
sprintf('isBlocked(%s) 판정이 기대와 다릅니다.', var_export($username, true))
);
}
/**
* @return array<string, array{0: string|null, 1: bool}>
*/
public static function blockedProvider(): array
{
return [
'root 차단' => ['root', true],
'postgres 차단' => ['postgres', true],
'sa 차단' => ['sa', true],
'sys 차단' => ['sys', true],
'system 차단' => ['system', true],
'대문자 ROOT 차단' => ['ROOT', true],
'혼합 대소문자 RoOt 차단' => ['RoOt', true],
'앞뒤 공백 " root " 차단' => [' root ', true],
'탭 문자 포함 차단' => ["\troot\n", true],
'일반 계정 g7user 통과' => ['g7user', false],
'admin 은 차단 대상 아님 (오차단 방지)' => ['admin', false],
'root 를 포함한 다른 이름 통과' => ['rootuser', false],
'g7_root 통과' => ['g7_root', false],
'빈 문자열은 blocked 아님' => ['', false],
'공백만 있는 문자열은 blocked 아님' => [' ', false],
'null 은 blocked 아님' => [null, false],
];
}
/**
* 사용 가능 여부 판정 — 빈 값(설정 누락)과 정상 계정을 구분한다.
*
* @scenario account_kind=empty, enforcement_point=judgement_ssot, install_state=completed
*
* @effects empty_username_rejected_as_unusable
*/
#[DataProvider('usableProvider')]
public function test_is_usable_rejects_privileged_and_empty(?string $username, bool $expected): void
{
$this->assertSame(
$expected,
PrivilegedDatabaseAccounts::isUsable($username),
sprintf('isUsable(%s) 판정이 기대와 다릅니다.', var_export($username, true))
);
}
/**
* @return array<string, array{0: string|null, 1: bool}>
*/
public static function usableProvider(): array
{
return [
'일반 계정 g7user 사용 가능' => ['g7user', true],
'admin 사용 가능 (오차단 방지)' => ['admin', true],
'rootuser 사용 가능' => ['rootuser', true],
'숫자 문자열 0 도 유효한 계정명' => ['0', true],
'root 사용 불가' => ['root', false],
'ROOT 사용 불가' => ['ROOT', false],
' root 사용 불가' => [' root ', false],
'postgres 사용 불가' => ['postgres', false],
'빈 문자열 사용 불가 (설정 누락)' => ['', false],
'공백만 있는 문자열 사용 불가' => [' ', false],
'null 사용 불가 (설정 누락)' => [null, false],
];
}
/**
* 목록이 상수 1곳에서만 관리되는지 — 판정이 BLOCKED 상수와 어긋나면 실패한다.
*
* @scenario account_kind=normal, enforcement_point=judgement_ssot, install_state=completed
*
* @effects normal_username_accepted
*/
public function test_every_blocked_constant_entry_is_actually_blocked(): void
{
$this->assertNotEmpty(PrivilegedDatabaseAccounts::BLOCKED);
foreach (PrivilegedDatabaseAccounts::BLOCKED as $account) {
$this->assertSame(
strtolower($account),
$account,
sprintf('BLOCKED 항목 "%s" 는 소문자로 정의되어야 비교가 성립합니다.', $account)
);
$this->assertTrue(PrivilegedDatabaseAccounts::isBlocked($account));
$this->assertFalse(PrivilegedDatabaseAccounts::isUsable($account));
}
}
/**
* `admin` 은 차단 대상이 아니다.
*
* 목록에 `admin` 을 넣으면 일반 권한으로 운영 중인 `admin` 계정 사용자가
* 업그레이드 직후 에러 페이지에 갇힌다. 이 오차단을 구조적으로 고정한다.
*
* @effects admin_account_not_blocked
*/
public function test_admin_is_not_a_blocked_account(): void
{
$this->assertNotContains('admin', PrivilegedDatabaseAccounts::BLOCKED);
$this->assertFalse(PrivilegedDatabaseAccounts::isBlocked('admin'));
$this->assertTrue(PrivilegedDatabaseAccounts::isUsable('admin'));
$this->assertTrue(PrivilegedDatabaseAccounts::isUsable('ADMIN'));
}
/**
* 인스톨러가 Laravel 오토로드 없이 `require_once` 로 로드할 수 있어야 하므로,
* 소스에 프레임워크 심볼 참조가 없어야 한다.
*/
public function test_source_has_no_framework_dependency(): void
{
$source = file_get_contents(
dirname(__DIR__, 3).'/app/Support/PrivilegedDatabaseAccounts.php'
);
$this->assertIsString($source);
foreach (['use Illuminate', 'Illuminate\\', 'config(', 'app(', '__(', 'trans('] as $forbidden) {
$this->assertStringNotContainsString(
$forbidden,
$source,
sprintf('인스톨러 공용 클래스에 프레임워크 의존("%s")이 포함됐습니다.', $forbidden)
);
}
}
}
@@ -0,0 +1,81 @@
feature: DB 최고권한 계정 차단 및 설치 후 자격증명 오류 안내
description: |
G7 은 DB 사용자명을 두 계층에서 다르게 다뤄 왔다. 인스톨러는 `root` 를 자유롭게
허용했고(오히려 `.env.example` fallback 기본값이 DB_WRITE_USERNAME=root), 설치 후
코어 부팅(CoreServiceProvider::boot)은 같은 값을 보고 모듈·플러그인·템플릿 로딩
전체를 조용히 스킵했다. 결과적으로 설치는 성공하지만 이후 모든 요청에서 템플릿 없는
깨진 화면이 뜨고, 원인은 storage/logs 의 ERROR 한 줄에만 남아 운영자가 알 방법이 없었다.
본 기능은 두 계층의 정책을 하나로 맞춘다.
- 판정 SSoT: App\Support\PrivilegedDatabaseAccounts (프레임워크 의존성 0 —
인스톨러가 require_once 로 직접 로드해 코어와 같은 목록·같은 비교 규칙을 쓴다)
- 설치 단계: 서버 2경로(연결 테스트 API, Step 3 폼 POST) + 클라이언트 1경로로 차단
- 설치 후: DatabaseCredentialGuard 미들웨어가 전용 에러 페이지(503)로 원인을 드러냄
`admin` 은 의도적으로 차단 목록에서 제외한다 — 일반 권한으로 운영 중인 `admin`
계정 사용자가 업그레이드 직후 에러 페이지에 갇히는 오차단을 막기 위함이다.
가드를 ServiceProvider::boot 가 아니라 미들웨어에 두는 이유: boot 에서 abort 하면
`php artisan` 자체가 죽어 복구 수단(config:clear 등)을 잃는다. 미들웨어는 웹 요청만
타므로 콘솔이 자연히 통과한다.
axes:
account_kind: [normal, privileged, empty]
enforcement_point: [judgement_ssot, installer_step3_write, installer_step3_read, runtime_web, runtime_api]
install_state: [completed, not_completed]
cross_product: |
account_kind × enforcement_point 이 핵심이다. 서버 경로 중 하나만 막으면 다른 경로로
우회되고, Write 만 막고 Read 를 열어두면 Read DB 로 최고권한 계정이 들어온다.
대문자(`ROOT`)·앞뒤 공백(` root `) 같은 표기 변형은 별도 axis 로 두지 않는다.
판정 SSoT 한 곳에서 정규화하므로 모든 enforcement_point 가 같은 결과를 공유하며,
변형 자체는 DataProvider 로 전수 검증하고 effect
`privileged_account_detected_case_and_whitespace_insensitive` 로 대표한다.
같은 이유로 `postgres`/`sa`/`sys`/`system` 도 privileged 하나로 묶는다.
exclusions:
- { enforcement_point: judgement_ssot, install_state: not_completed, reason: "순수 판정 클래스 — 설치 상태와 무관 (config 접근 없음)" }
- { enforcement_point: installer_step3_write, install_state: completed, reason: "인스톨러는 정의상 미설치 상태 전용 — 설치 완료 후에는 _guard.php 가 410 으로 차단" }
- { enforcement_point: installer_step3_read, install_state: completed, reason: "동일 — 인스톨러 경로는 미설치 전용" }
- { enforcement_point: runtime_api, install_state: not_completed, reason: "미설치 early-return 은 API/HTML 분기보다 앞에서 일어나 분기에 도달하지 않음 — runtime_web 이 대표" }
- { account_kind: normal, enforcement_point: runtime_web, install_state: not_completed, reason: "정상 계정 + 미설치는 통과 사유가 둘 다 성립 — 어느 가드가 통과시켰는지 구별 불가하여 검증가치 없음. privileged/empty 로 미설치 통과를 검증" }
effects:
# 판정 SSoT
- privileged_account_detected_case_and_whitespace_insensitive
- admin_account_not_blocked
- empty_username_rejected_as_unusable
- normal_username_accepted
- installer_and_core_share_the_same_judgement_class
# 설치 단계
- installer_step3_post_rejects_privileged_username
- installer_step3_post_rejects_empty_username
- installer_step3_post_accepts_normal_username
- installer_message_substitutes_username_and_offers_alternative
- empty_and_privileged_produce_distinct_messages
# 설치 후 런타임
- runtime_returns_503_error_page
- runtime_returns_503_json_for_api
- runtime_passes_through_with_normal_account
- runtime_passes_through_when_not_installed
- error_page_does_not_leak_account_name
- error_page_is_self_contained_without_external_assets
- error_page_detects_locale_without_setlocale_middleware
- maintenance_mode_takes_precedence_over_credential_guard
# E2E axis 없음: 인스톨러는 설치 전 전용 순수 PHP 화면이라 Playwright 인증 픽스처
# (issueToken/authenticatePage) 가 성립하지 않고, 런타임 가드는 .env 를 최고권한
# 계정으로 바꿔야 재현되어 E2E 실행 환경 자체를 파괴한다. 두 경로 모두 Feature/Unit 으로
# 검증하고, 브라우저 실측은 Chrome MCP 수동 매트릭스로 대체한다.
# (레이아웃 JSON / 컴포넌트 TSX / 엔진 TS 변경 없음 — installer.js 는 인스톨러 전용
# 독립 스크립트로 템플릿 엔진 자산이 아니다.)
#
# 클라이언트 JS 검증(installer.js)도 axis 로 두지 않는다: 즉시 피드백 용도이며 차단의
# 실체는 서버 2경로다. 목록도 서버 상수를 그대로 내려받아 쓰므로 독립 판정 지점이 아니다.
test_files:
- tests/Unit/Support/PrivilegedDatabaseAccountsTest.php
- tests/Unit/Installer/PrivilegedDbAccountGuardTest.php
- tests/Feature/Middleware/DatabaseCredentialGuardTest.php
@@ -0,0 +1,72 @@
feature: OPcache 상태 노출 (설치 단계 경고 + 관리자 정보 탭)
description: |
OPcache 는 코어 어디에서도 상태를 조회하지 않았다(opcache_reset 호출부 3곳뿐).
비활성 환경에서는 매 요청마다 PHP 코드를 다시 해석해 응답이 느려지는데, 운영자가
그 사실을 인지할 경로가 전혀 없었다.
본 기능은 두 지점에 상태를 노출한다.
- 설치 단계(Step 2 요구사항): 경고 카드로 표시하되 설치를 차단하지 않는다
- 관리자 환경설정 > 정보: 상태 행 + 비활성일 때만 성능 저하 경고 블록
판정 SSoT 는 App\Support\OpcacheStatus (프레임워크 의존성 0 — 인스톨러가
require_once 로 직접 로드). 확장 로드 여부만으로는 부족하다: `Zend OPcache` 가
로드돼 있어도 `opcache.enable=0` 이면 동작하지 않으므로 지시자까지 확인한다.
`ini_get` 이 disable_functions 로 차단된 환경은 enabled=null("확인 불가")로
폴백하며, 이때는 경고도 차단도 하지 않는다.
axes:
opcache_state: [enabled, loaded_but_disabled, not_loaded, ini_get_blocked]
surface: [judgement_ssot, system_info_api, admin_info_row, admin_info_warning_block]
cross_product: |
opcache_state × surface 가 핵심이다. 특히 loaded_but_disabled 는 "확장 로드 =
활성" 으로 판정하는 회귀를 잡는 케이스이고, ini_get_blocked(null) 는 `!enabled`
같은 느슨한 비교를 쓰면 "비활성" 경고가 잘못 뜨는 케이스다. 두 상태가 서로 다른
결과를 내야 한다.
locale 은 axis 로 두지 않는다. 판정값(bool/null)과 문구 해석은 분리돼 있고,
문구는 각 로케일 파일의 키 존재로 보장하면 충분하다 — 로케일마다 판정이 달라질
경로가 없어 axis 로 두면 곱셈만 늘고 검증 가치가 없다. 키 존재는 effect
`installer_opcache_lang_keys_exist_in_ko_and_en` 과 언어팩 동기화 검사가 담당한다.
installer_requirements_card 는 surface 에서 제외한다. 설치 전 전용 화면이라
자동 검증 경로가 없어(아래 E2E 주석 참조) 정직하게 커버할 수 없으며, 그 대신
서버측 판정(judgement_ssot)과 lang 키 존재를 검증하고 화면은 Chrome MCP 로 실측한다.
exclusions:
- { opcache_state: enabled, surface: admin_info_warning_block, reason: "경고 블록은 enabled=false 일 때만 렌더 — 활성 상태에서는 미표시 검증이 admin_info_row 케이스에 포함됨" }
- { opcache_state: not_loaded, surface: admin_info_warning_block, reason: "미로드는 enabled=false 로 수렴 — loaded_but_disabled 와 완전히 동일한 경고 경로" }
- { opcache_state: not_loaded, surface: admin_info_row, reason: "동일 — 화면은 enabled 값만 보므로 loaded_but_disabled 와 구별되지 않음" }
effects:
# 판정 SSoT
- loaded_but_disabled_directive_reports_disabled
- not_loaded_reports_disabled_not_unknown
- ini_get_blocked_reports_unknown_null
- ini_get_false_distinguished_from_value_zero
- on_off_directive_values_parsed
# 설치 단계 (비차단)
- installer_opcache_lang_keys_exist_in_ko_and_en
# 관리자 정보 탭
- opcache_status_exposed_in_system_info
- admin_info_row_shows_enabled_disabled_unknown
- admin_info_warning_shown_only_when_disabled
- admin_info_warning_hidden_when_unknown
- admin_info_defensive_against_missing_opcache_key
# E2E axis: admin_info_row / admin_info_warning_block 는 레이아웃 JSON 변경을 수반하므로
# Playwright spec 을 동반한다 (frontend-change-requires-e2e). API 응답을 route 로 가로채
# 세 상태(enabled/disabled/null)를 모두 주입해 조건부 렌더를 검증한다.
#
# 인스톨러 요구사항 카드는 설치 전 전용 화면이라 Playwright 인증 픽스처가 성립하지 않고,
# 설치 완료 환경에서는 _guard.php 가 410 으로 차단해 자동 접근 경로가 없다. 서버측
# 판정과 lang 키 존재만 자동 검증하고, "카드가 경고로 뜨되 다음 버튼이 활성 유지되는지" 는
# Chrome MCP 수동 매트릭스로 실측한다 (자동 커버 불가 영역을 명시적으로 남긴다).
test_files:
- tests/Unit/Support/OpcacheStatusTest.php
- tests/Unit/Installer/PrivilegedDbAccountGuardTest.php
- tests/Feature/Api/Admin/SettingsControllerTest.php
- templates/_bundled/sirsoft-admin_basic/__tests__/layouts/admin-settings-info-opcache.test.tsx
- tests/Playwright/specs/admin/settings-info-opcache.spec.ts
@@ -16,16 +16,22 @@ description: |
DashboardService 에만 적용되고 SettingsService::buildSystemInfo 에는 disk 한 곳만
부분 보강되어, CPU/메모리 등 다른 probe 로 재발한 결함의 재발 차단.
opcache 항목은 문자열 'unknown' 이 아니라 배열 {loaded:false, enabled:null} 로
폴백한다 — 소비처(관리자 정보 탭)가 구조 분해로 읽으므로 형식을 유지해야 한다.
화면 노출/경고 렌더는 별도 매니페스트(opcache-status-visibility)가 담당한다.
axes:
probe_item: [cpu_info, os_info, memory_usage, disk_usage, php_memory_limit, mysql_version]
probe_item: [cpu_info, os_info, memory_usage, disk_usage, php_memory_limit, mysql_version, opcache]
probe_outcome: [success, throws_error, throws_exception]
auth_state: [authenticated_with_permission, authenticated_without_permission, unauthenticated]
exclusions:
- { probe_item: os_info, probe_outcome: throws_exception, reason: "각 probe_item 은 동일 safeSystemProbe 경로 — cpu_info 대표 검증으로 커버, 나머지는 형식적 확장" }
- { probe_item: opcache, probe_outcome: throws_exception, reason: "opcache 는 ini_get 차단 시 Error 를 던지므로 throws_error 로 대표 검증 — Exception 경로도 동일 safeSystemProbe catch(\\Throwable) 로 흡수" }
- { auth_state: unauthenticated, probe_outcome: throws_error, reason: "인증 가드가 probe 실행 전에 401/403 으로 차단 — probe_outcome 과 무관" }
effects:
- opcache_status_exposed_in_system_info
- failing_probe_isolated_and_api_returns_200
- failed_item_filled_with_unknown_fallback
- usage_array_fallback_keeps_total_used_free_unknown_and_percentage_zero