v7.0.0 release
This commit is contained in:
1 parent
0e7fa04b03
commit
c4ea9a6cd1
3582 files changed
+626189
-160151
No files matched your search
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Providers;
|
||||
|
||||
use App\Providers\SettingsServiceProvider;
|
||||
use App\Repositories\JsonConfigRepository;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use ReflectionMethod;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* SettingsServiceProvider 앱 설정(site_name) 다국어 안전화 테스트 (공개#49).
|
||||
*
|
||||
* applyAppConfig()가 general.site_name 을 config('app.name')에 주입할 때,
|
||||
* 다국어 JSON array 면 현재/폴백 로케일 string 으로 정규화해 SPA <title>
|
||||
* ({{ config('app.name') }} → Blade e() → htmlspecialchars) TypeError 를 차단하는지 검증.
|
||||
*/
|
||||
class SettingsServiceProviderAppConfigTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* applyAppConfig 를 리플렉션으로 호출합니다.
|
||||
*
|
||||
* @param array $generalSettings general 카테고리 설정 데이터
|
||||
*/
|
||||
private function callApplyAppConfig(array $generalSettings): void
|
||||
{
|
||||
$configRepository = $this->createMock(JsonConfigRepository::class);
|
||||
$configRepository->method('getCategory')
|
||||
->with('general')
|
||||
->willReturn($generalSettings);
|
||||
|
||||
$provider = new SettingsServiceProvider($this->app);
|
||||
$method = new ReflectionMethod($provider, 'applyAppConfig');
|
||||
$method->invoke($provider, $configRepository);
|
||||
}
|
||||
|
||||
/**
|
||||
* 단일 문자열 site_name 은 그대로 config('app.name')에 적용됩니다.
|
||||
*/
|
||||
public function test_string_site_name_applied_as_is(): void
|
||||
{
|
||||
$this->callApplyAppConfig(['site_name' => '그누보드7']);
|
||||
|
||||
$this->assertSame('그누보드7', config('app.name'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 다국어 array site_name 은 현재 로케일 string 으로 정규화되어 적용됩니다.
|
||||
*/
|
||||
public function test_multilingual_site_name_normalized_to_current_locale(): void
|
||||
{
|
||||
Config::set('app.locale', 'ko');
|
||||
Config::set('app.fallback_locale', 'en');
|
||||
|
||||
$this->callApplyAppConfig([
|
||||
'site_name' => ['ko' => '한글몰', 'en' => 'EngMall'],
|
||||
]);
|
||||
|
||||
$name = config('app.name');
|
||||
$this->assertIsString($name, 'config(app.name)은 항상 string 이어야 함 (SPA title TypeError 방지)');
|
||||
$this->assertSame('한글몰', $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 현재 로케일 키가 없으면 폴백 로케일 string 으로 적용됩니다.
|
||||
*/
|
||||
public function test_multilingual_site_name_falls_back_to_fallback_locale(): void
|
||||
{
|
||||
Config::set('app.locale', 'ja');
|
||||
Config::set('app.fallback_locale', 'en');
|
||||
|
||||
$this->callApplyAppConfig([
|
||||
'site_name' => ['en' => 'EngMall'],
|
||||
]);
|
||||
|
||||
$this->assertSame('EngMall', config('app.name'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 정규화 결과가 Blade e() (htmlspecialchars)에서 TypeError 없이 string 으로 렌더됩니다.
|
||||
*/
|
||||
public function test_normalized_site_name_renders_without_type_error(): void
|
||||
{
|
||||
Config::set('app.locale', 'ko');
|
||||
|
||||
$this->callApplyAppConfig([
|
||||
'site_name' => ['ko' => '한글몰', 'en' => 'EngMall'],
|
||||
]);
|
||||
|
||||
// app.blade.php 의 {{ config('app.name') }} 와 동일 경로
|
||||
$rendered = e(config('app.name', '그누보드7'));
|
||||
$this->assertSame('한글몰', $rendered);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Providers;
|
||||
|
||||
use App\Providers\SettingsServiceProvider;
|
||||
use App\Repositories\JsonConfigRepository;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use ReflectionClass;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* SettingsServiceProvider 의 디버그 설정 환경별 분기 동작 테스트.
|
||||
*
|
||||
* 의도:
|
||||
* - production/local 운영 환경에서는 admin UI 의 debug 토글(storage/app/settings/debug.json) 이 SSoT 로
|
||||
* 동작하여 .env 의 APP_DEBUG 보다 우선 적용되어야 한다.
|
||||
* - testing 환경(PHPUnit, .env.testing) 에서는 settings JSON 의 mode 값이 .env.testing 의 APP_DEBUG 를
|
||||
* 덮어쓰지 않아야 한다. 그렇지 않으면 운영 PC 의 settings 값(debug=false) 때문에 PHPUnit / E2E 인프라
|
||||
* (PlaywrightIssueToken 등) 가 의도치 않게 차단된다.
|
||||
*
|
||||
* 회귀 컨텍스트: 이슈 #238 Playwright 도입 작업 중 PO 환경(APP_ENV=production, debug.json mode=false) 에서
|
||||
* --env=testing 으로 artisan 명령을 실행해도 SettingsServiceProvider 가 settings JSON 의 mode=false 로
|
||||
* config('app.debug') 를 false 로 덮어쓰는 문제가 발견됨.
|
||||
*/
|
||||
class SettingsServiceProviderDebugConfigTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* testing 환경에서는 settings JSON 의 debug.mode 가 config('app.debug') 를 덮어쓰지 않아야 한다.
|
||||
*
|
||||
* 검증:
|
||||
* 1. config('app.debug') 를 true 로 사전 설정 (= .env.testing APP_DEBUG=true 상태 시뮬레이션)
|
||||
* 2. settings JSON 에서 debug.mode=false 를 반환하는 가짜 repository 주입
|
||||
* 3. applyDebugConfig 호출
|
||||
* 4. config('app.debug') 가 true 그대로 유지되어야 함 (testing 가드가 settings 덮어쓰기 차단)
|
||||
*/
|
||||
public function test_applyDebugConfig_does_not_override_in_testing_environment(): void
|
||||
{
|
||||
// 현재 PHPUnit 환경은 APP_ENV=testing 이어야 함
|
||||
$this->assertSame('testing', app()->environment(), '본 테스트는 testing 환경에서만 의미를 가진다.');
|
||||
|
||||
Config::set('app.debug', true);
|
||||
|
||||
$fakeRepository = new class extends JsonConfigRepository
|
||||
{
|
||||
public function getCategory(string $category): array
|
||||
{
|
||||
if ($category === 'debug') {
|
||||
return ['mode' => false, 'log_level' => 'error'];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
$provider = new SettingsServiceProvider(app());
|
||||
$reflection = new ReflectionClass($provider);
|
||||
$method = $reflection->getMethod('applyDebugConfig');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$method->invoke($provider, $fakeRepository);
|
||||
|
||||
$this->assertTrue(
|
||||
config('app.debug'),
|
||||
'testing 환경에서는 settings JSON 의 debug.mode 가 config(app.debug) 를 덮어쓰지 않아야 한다.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* G7_PLAYWRIGHT_BYPASS=1 환경변수가 부여된 호출에서도 settings JSON 의 debug.mode 가 덮어쓰지 않아야 한다.
|
||||
*
|
||||
* 의도:
|
||||
* production 환경에서 Playwright E2E 가 토큰 발급 시 PlaywrightIssueToken 이
|
||||
* `Config::set('app.debug', true)` 로 inline override 를 적용한다. 이 시점에 settings JSON
|
||||
* 덮어쓰기가 발생하면 inline override 가 무력화되어 토큰 발급 후 layout JSON 보호 인증 등이
|
||||
* 디버그 정보 누락으로 실패한다. 따라서 bypass flag 가 있으면 settings JSON 분기를 건너뛴다.
|
||||
*/
|
||||
public function test_applyDebugConfig_does_not_override_when_playwright_bypass_flag_is_set(): void
|
||||
{
|
||||
Config::set('app.debug', true);
|
||||
|
||||
$fakeRepository = new class extends JsonConfigRepository
|
||||
{
|
||||
public function getCategory(string $category): array
|
||||
{
|
||||
if ($category === 'debug') {
|
||||
return ['mode' => false, 'log_level' => 'error'];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
// G7_PLAYWRIGHT_BYPASS=1 를 임시 부여하고 종료 시 원복
|
||||
$previous = getenv('G7_PLAYWRIGHT_BYPASS');
|
||||
putenv('G7_PLAYWRIGHT_BYPASS=1');
|
||||
$_ENV['G7_PLAYWRIGHT_BYPASS'] = '1';
|
||||
$_SERVER['G7_PLAYWRIGHT_BYPASS'] = '1';
|
||||
|
||||
try {
|
||||
$provider = new SettingsServiceProvider(app());
|
||||
$reflection = new ReflectionClass($provider);
|
||||
$method = $reflection->getMethod('applyDebugConfig');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$method->invoke($provider, $fakeRepository);
|
||||
|
||||
$this->assertTrue(
|
||||
config('app.debug'),
|
||||
'G7_PLAYWRIGHT_BYPASS=1 이면 settings JSON 의 debug.mode 가 config(app.debug) 를 덮어쓰지 않아야 한다.'
|
||||
);
|
||||
} finally {
|
||||
if ($previous === false) {
|
||||
putenv('G7_PLAYWRIGHT_BYPASS');
|
||||
unset($_ENV['G7_PLAYWRIGHT_BYPASS'], $_SERVER['G7_PLAYWRIGHT_BYPASS']);
|
||||
} else {
|
||||
putenv('G7_PLAYWRIGHT_BYPASS='.$previous);
|
||||
$_ENV['G7_PLAYWRIGHT_BYPASS'] = $previous;
|
||||
$_SERVER['G7_PLAYWRIGHT_BYPASS'] = $previous;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* production 환경 시뮬레이션 에서는 settings JSON 의 debug.mode 가 여전히 SSoT 로 적용되어야 한다.
|
||||
*
|
||||
* (운영 환경 회귀 차단 — testing 가드가 production 동작을 망가뜨리지 않는지 확인)
|
||||
*/
|
||||
public function test_applyDebugConfig_still_overrides_outside_testing_environment(): void
|
||||
{
|
||||
// 본 테스트는 app environment 를 명시적으로 production 으로 모킹할 수 없으므로
|
||||
// SettingsServiceProvider 가 환경 분기 후에도 settings 를 읽는다는 사실만 검증한다.
|
||||
// 자세한 분기 동작은 본 메서드의 testing 케이스가 커버한다.
|
||||
$this->markTestSkipped('production 환경 분기는 통합 테스트 또는 수동 검증으로 커버 (PHPUnit 부팅 환경 강제 변경 불가)');
|
||||
}
|
||||
}
|
||||
@@ -76,4 +76,38 @@ class SettingsServiceProviderTest extends TestCase
|
||||
// 설정값이 null이 아님 = seo 카테고리가 정상 로딩됨
|
||||
$this->assertNotNull($botDetectionEnabled, 'seo.bot_detection_enabled 설정이 로딩되어야 합니다.');
|
||||
}
|
||||
|
||||
/**
|
||||
* CORE_CATEGORIES 에 identity 카테고리가 포함되어 admin UI 본인인증 설정이 로딩되는지 테스트합니다.
|
||||
*
|
||||
* 회귀 차단 (이슈 #275): identity 가 CORE_CATEGORIES 에서 누락되면 admin UI 의
|
||||
* 본인인증 환경설정(기본 프로바이더 / 목적별 / TTL / 최대 시도 횟수) 4개 항목이 모두 무시됨.
|
||||
*/
|
||||
public function test_identity_category_included_in_core_categories(): void
|
||||
{
|
||||
$reflection = new ReflectionClass(SettingsServiceProvider::class);
|
||||
$categories = $reflection->getConstant('CORE_CATEGORIES');
|
||||
|
||||
$this->assertContains('identity', $categories, 'CORE_CATEGORIES 에 identity 카테고리가 포함되어야 합니다.');
|
||||
}
|
||||
|
||||
/**
|
||||
* 본인인증 설정이 config('settings.identity.*') dot-path 로 hydrate 되는지 테스트합니다.
|
||||
*
|
||||
* 회귀 차단 (이슈 #275): IdentityVerificationManager / MailIdentityProvider /
|
||||
* InicisIdentityProvider 등이 `config('settings.identity.*')` 경로로 직접 read 한다.
|
||||
* 이 경로 hydration 이 누락되면 admin UI 저장값이 모두 무시되고 코드 fallback 만 사용된다.
|
||||
*/
|
||||
public function test_settings_identity_dot_path_hydrated(): void
|
||||
{
|
||||
// storage/app/settings/identity.json 이 존재하는 환경에서는 hydrate 되어 array
|
||||
// 부재 환경에서도 최소 null 이어야 함 (Config::set('settings.identity', ...) 의 cover 범위)
|
||||
$identityConfig = config('settings.identity');
|
||||
|
||||
// 카테고리 자체가 등록되어 있어야 함. 빈 배열일 수도 있지만 false 또는 'string' 류는 부적합
|
||||
$this->assertTrue(
|
||||
$identityConfig === null || is_array($identityConfig),
|
||||
'config(\'settings.identity\') 는 null 또는 array 여야 합니다.'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -90,4 +90,47 @@ class SettingsServiceProviderWebsocketConfigTest extends TestCase
|
||||
|
||||
$this->assertSame('null', config('broadcasting.default'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 웹소켓 OFF + .env REVERB_APP_KEY 존재 시 reverb.key가 비워지는지 테스트합니다 (공개#50).
|
||||
*
|
||||
* 프론트(admin/app.blade.php)가 @if(reverb.key)로 연결을 결정하므로, OFF 시 key를 비워야
|
||||
* .env REVERB_APP_KEY가 살아 있어도 브라우저 WebSocket 연결을 차단할 수 있다.
|
||||
*/
|
||||
public function test_reverb_key_blanked_when_websocket_disabled(): void
|
||||
{
|
||||
// .env 초기 상태: REVERB_APP_KEY가 살아 있어 reverb.key가 채워진 상태
|
||||
Config::set('broadcasting.default', 'reverb');
|
||||
Config::set('broadcasting.connections.reverb.key', 'env-reverb-key');
|
||||
|
||||
$this->callApplyWebsocketConfig([
|
||||
'websocket_enabled' => false,
|
||||
]);
|
||||
|
||||
$this->assertSame(
|
||||
'',
|
||||
config('broadcasting.connections.reverb.key'),
|
||||
'웹소켓 OFF 시 reverb.key는 비워져야 함 (프론트 @if(reverb.key) 연결 차단)'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 웹소켓 ON 시 reverb.key가 설정값으로 유지되는지 테스트합니다 (회귀 방지, 공개#50).
|
||||
*/
|
||||
public function test_reverb_key_preserved_when_websocket_enabled(): void
|
||||
{
|
||||
Config::set('broadcasting.default', 'reverb');
|
||||
Config::set('broadcasting.connections.reverb.key', 'env-reverb-key');
|
||||
|
||||
$this->callApplyWebsocketConfig([
|
||||
'websocket_enabled' => true,
|
||||
'websocket_app_key' => 'admin-set-key',
|
||||
]);
|
||||
|
||||
$this->assertSame(
|
||||
'admin-set-key',
|
||||
config('broadcasting.connections.reverb.key'),
|
||||
'웹소켓 ON 시 reverb.key는 환경설정/.env 값으로 유지되어야 함'
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user