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,61 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Extension;
|
||||
|
||||
use App\Extension\Testing\ExtensionTestAllowlist;
|
||||
use Illuminate\Contracts\Http\Kernel as HttpKernelContract;
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Plugins\Sirsoft\Gdpr\Http\Middleware\CookieConsentMiddleware;
|
||||
use Plugins\Sirsoft\Gdpr\Providers\GdprServiceProvider;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* 테스트 환경 확장 격리 회귀 테스트 — allowlist 포함 시나리오
|
||||
*
|
||||
* requiredExtensions 에 GDPR 플러그인을 명시하면 해당 플러그인의
|
||||
* ServiceProvider 와 미들웨어가 정상적으로 로드되어야 한다.
|
||||
*/
|
||||
class ExtensionTestIsolationGdprAllowedTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/**
|
||||
* GDPR 플러그인을 allowlist 에 명시.
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
protected array $requiredExtensions = [
|
||||
'plugins/sirsoft-gdpr',
|
||||
];
|
||||
|
||||
/**
|
||||
* @effects allowlisted_plugin_service_provider_is_registered
|
||||
*/
|
||||
public function test_allowlisted_plugin_service_provider_is_registered(): void
|
||||
{
|
||||
$this->assertTrue(ExtensionTestAllowlist::isAllowed('plugin', 'sirsoft-gdpr'));
|
||||
|
||||
$this->assertTrue(
|
||||
$this->app->providerIsLoaded(GdprServiceProvider::class),
|
||||
'allowlist 에 명시된 GdprServiceProvider 가 등록되지 않았습니다'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @effects allowlisted_plugin_middleware_is_registered_in_web_group
|
||||
*/
|
||||
public function test_allowlisted_plugin_middleware_is_registered_in_web_group(): void
|
||||
{
|
||||
$kernel = $this->app->make(HttpKernelContract::class);
|
||||
$this->assertInstanceOf(HttpKernel::class, $kernel);
|
||||
|
||||
$groups = $kernel->getMiddlewareGroups();
|
||||
|
||||
$this->assertContains(
|
||||
CookieConsentMiddleware::class,
|
||||
$groups['web'] ?? [],
|
||||
'allowlist 에 GDPR 을 명시했으나 web 그룹에 CookieConsentMiddleware 가 없습니다'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Extension;
|
||||
|
||||
use App\Extension\Testing\ExtensionTestAllowlist;
|
||||
use Illuminate\Contracts\Http\Kernel as HttpKernelContract;
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Plugins\Sirsoft\Gdpr\Http\Middleware\CookieConsentMiddleware;
|
||||
use Plugins\Sirsoft\Gdpr\Providers\GdprServiceProvider;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* 테스트 환경 확장 격리 회귀 테스트
|
||||
*
|
||||
* requiredExtensions allowlist 가 ServiceProvider / route / middleware 등록
|
||||
* 범위를 통제하는지 검증합니다.
|
||||
*
|
||||
* - core-only 테스트(requiredExtensions 미선언): GDPR 플러그인 미로드
|
||||
* - requiredExtensions = ['plugins/sirsoft-gdpr']: GDPR 플러그인 로드
|
||||
*
|
||||
* 본 클래스 자체는 requiredExtensions 를 선언하지 않으므로 core-only 시나리오다.
|
||||
*/
|
||||
class ExtensionTestIsolationTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/**
|
||||
* @effects core_only_test_does_not_register_gdpr_service_provider
|
||||
*/
|
||||
public function test_core_only_test_does_not_register_gdpr_service_provider(): void
|
||||
{
|
||||
// allowlist 가 활성(testing + 명시적 set)이어야 격리가 동작
|
||||
$this->assertTrue(ExtensionTestAllowlist::isActive());
|
||||
$this->assertFalse(ExtensionTestAllowlist::isAllowed('plugin', 'sirsoft-gdpr'));
|
||||
|
||||
$this->assertFalse(
|
||||
$this->app->providerIsLoaded(GdprServiceProvider::class),
|
||||
'core-only 테스트에서 GdprServiceProvider 가 등록되었습니다 — 격리 실패'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @effects core_only_test_does_not_register_gdpr_middleware_in_web_group, core_only_test_does_not_register_gdpr_middleware_in_api_group
|
||||
*/
|
||||
public function test_core_only_test_does_not_register_gdpr_middleware_in_groups(): void
|
||||
{
|
||||
$kernel = $this->app->make(HttpKernelContract::class);
|
||||
$this->assertInstanceOf(HttpKernel::class, $kernel);
|
||||
|
||||
$groups = $kernel->getMiddlewareGroups();
|
||||
|
||||
$webGroup = $groups['web'] ?? [];
|
||||
$apiGroup = $groups['api'] ?? [];
|
||||
|
||||
$this->assertNotContains(
|
||||
CookieConsentMiddleware::class,
|
||||
$webGroup,
|
||||
'core-only 테스트의 web 미들웨어 그룹에 CookieConsentMiddleware 가 개입했습니다'
|
||||
);
|
||||
$this->assertNotContains(
|
||||
CookieConsentMiddleware::class,
|
||||
$apiGroup,
|
||||
'core-only 테스트의 api 미들웨어 그룹에 CookieConsentMiddleware 가 개입했습니다'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @effects core_only_test_does_not_register_gdpr_plugin_routes
|
||||
*/
|
||||
public function test_core_only_test_does_not_register_gdpr_plugin_routes(): void
|
||||
{
|
||||
$routes = collect($this->app['router']->getRoutes()->getRoutes())
|
||||
->map(fn ($route) => $route->uri())
|
||||
->filter(fn ($uri) => str_contains($uri, 'plugins/sirsoft-gdpr'));
|
||||
|
||||
$this->assertCount(
|
||||
0,
|
||||
$routes,
|
||||
'core-only 테스트에 GDPR 플러그인 라우트가 등록되었습니다 — 격리 실패'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @effects allowlist_inactive_when_never_configured
|
||||
*/
|
||||
public function test_allowlist_is_inactive_when_never_configured(): void
|
||||
{
|
||||
// 비-테스트 부팅(또는 set 호출 전)에는 가드가 비활성이어야
|
||||
// 운영/개발 환경의 확장 전수 로딩이 보존됨
|
||||
ExtensionTestAllowlist::reset();
|
||||
|
||||
$this->assertFalse(ExtensionTestAllowlist::isActive());
|
||||
|
||||
// 테스트 격리 보존을 위해 본 클래스의 core-only allowlist 복원
|
||||
ExtensionTestAllowlist::set($this->resolveAllowedExtensions());
|
||||
}
|
||||
|
||||
/**
|
||||
* @effects selfExtension_returns_null_for_core_tests
|
||||
*/
|
||||
public function test_selfExtension_returns_null_for_core_tests(): void
|
||||
{
|
||||
// 본 테스트 클래스는 tests/Feature/ 하위 (코어 테스트) →
|
||||
// selfExtension() 의 modules/plugins 경로 패턴에 매칭되지 않아 null 반환
|
||||
$this->assertNull($this->selfExtension());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Extension;
|
||||
|
||||
use App\Contracts\Extension\CacheInterface;
|
||||
use App\Contracts\Extension\StorageInterface;
|
||||
use App\Extension\Cache\CoreCacheDriver;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* 코어 캐시·스토리지 글로벌 바인딩 무결성 회귀 가드.
|
||||
*
|
||||
* 이슈 #392 — 어떤 플러그인 ServiceProvider 도 `app(CacheInterface)` 글로벌 바인딩을
|
||||
* PluginCacheDriver 로 덮어쓰면 안 된다. 글로벌 바인딩이 덮어쓰여지면 코어
|
||||
* LayoutService 등의 `$this->cache->put('ext.cache_version', ...)` 가 플러그인
|
||||
* 도메인으로 누수되어 화면에 반영되지 않는 결함이 재발한다.
|
||||
*
|
||||
* 본 테스트는 코어 컨텍스트에서 모든 ServiceProvider 가 부팅된 직후의 상태를 검증한다.
|
||||
* 플러그인별 contextual binding 정확성 (식별자 prefix 매칭 등) 은 해당 플러그인의
|
||||
* Feature 테스트로 검증한다 (예: PluginCacheContextualBindingTest in
|
||||
* plugins/_bundled/sirsoft-verification_kginicis/tests/Feature/).
|
||||
*
|
||||
* @see tests/scenarios/extension-cache-binding-isolation.yaml
|
||||
*/
|
||||
class PluginCacheBindingIsolationTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @scenario extension_kind=plugin,service_kind=cache_service,global_binding_state=installed_before_provider,manager_state=plugin_resolved,consumer_type=single_class
|
||||
* @effects global_cache_interface_binding_remains_core_cache_driver
|
||||
*/
|
||||
public function test_global_cache_interface_resolves_to_core_cache_driver(): void
|
||||
{
|
||||
$cache = $this->app->make(CacheInterface::class);
|
||||
|
||||
$this->assertInstanceOf(
|
||||
CoreCacheDriver::class,
|
||||
$cache,
|
||||
'app(CacheInterface) 는 항상 CoreCacheDriver 여야 한다. '
|
||||
.'PluginCacheDriver 가 반환되면 어떤 ServiceProvider 가 '
|
||||
.'$this->app->singleton(CacheInterface::class, ...) 로 글로벌 바인딩을 덮어쓰고 있다 (이슈 #392).'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @scenario extension_kind=plugin,service_kind=storage_service,global_binding_state=absent,manager_state=plugin_resolved,consumer_type=no_registration
|
||||
* @effects global_storage_interface_binding_remains_core_storage_driver
|
||||
*/
|
||||
public function test_global_storage_interface_is_not_bound_to_extension_driver(): void
|
||||
{
|
||||
// 코어는 StorageInterface 를 글로벌 바인딩하지 않는다 — 확장은 contextual binding
|
||||
// 으로만 StorageInterface 를 주입해야 한다. 어떤 ServiceProvider 가 글로벌
|
||||
// 바인딩을 등록했다면 그 자체가 결함 후보 (특히 확장 도메인 드라이버로 바인딩 시
|
||||
// 코어/타 확장 도메인의 파일 접근이 누수됨).
|
||||
if (! $this->app->bound(StorageInterface::class)) {
|
||||
$this->assertTrue(true, 'StorageInterface 는 글로벌 바인딩이 없는 상태가 정상.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$storage = $this->app->make(StorageInterface::class);
|
||||
|
||||
$this->assertNotInstanceOf(
|
||||
\App\Extension\Storage\PluginStorageDriver::class,
|
||||
$storage,
|
||||
'app(StorageInterface) 는 PluginStorageDriver 가 아니어야 한다 — 확장 ServiceProvider 의 글로벌 재바인딩 의심.'
|
||||
);
|
||||
$this->assertNotInstanceOf(
|
||||
\App\Extension\Storage\ModuleStorageDriver::class,
|
||||
$storage,
|
||||
'app(StorageInterface) 는 ModuleStorageDriver 가 아니어야 한다 — 확장 ServiceProvider 의 글로벌 재바인딩 의심.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @scenario extension_kind=plugin,service_kind=cache_service,global_binding_state=installed_before_provider,manager_state=plugin_resolved,consumer_type=single_class
|
||||
* @effects layout_service_ext_cache_version_key_written_to_core_namespace
|
||||
*/
|
||||
public function test_core_cache_writes_use_core_namespace_prefix(): void
|
||||
{
|
||||
$cache = $this->app->make(CacheInterface::class);
|
||||
$this->assertInstanceOf(CoreCacheDriver::class, $cache);
|
||||
|
||||
$resolvedKey = $cache->resolveKey('ext.cache_version');
|
||||
|
||||
$this->assertStringStartsWith(
|
||||
'g7:core:',
|
||||
$resolvedKey,
|
||||
'코어 LayoutService 의 ext.cache_version bump 가 플러그인 도메인 (g7:plugin.*:) 으로 누수되면 안 된다.'
|
||||
);
|
||||
|
||||
// 실제 put → has → forget 사이클로 코어 캐시 도메인이 정상 동작함을 검증
|
||||
$cache->put('isolation_probe_392', 'probe', 60);
|
||||
$this->assertTrue($cache->has('isolation_probe_392'));
|
||||
$cache->forget('isolation_probe_392');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user