forked from fa/breadcrumb-the-shire
- Move HelpdeskTenantSettingsRepository and HelpdeskTokenRepository from Service/ to Repository/ directory (GR-SEC-003: SQL only in repositories) - Make AccessControl constructor require IntendedUrlService explicitly instead of falling back to `new IntendedUrlService()` (GR-TEST-002: no service instantiation outside factories) - Update all imports and tests accordingly Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace MintyPHP\Tests\Http;
|
|
|
|
use MintyPHP\Http\AccessControl;
|
|
use MintyPHP\Http\IntendedUrlService;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class AccessControlTest extends TestCase
|
|
{
|
|
private function createAccessControl(array $publicPaths = []): AccessControl
|
|
{
|
|
return new AccessControl($publicPaths, new IntendedUrlService());
|
|
}
|
|
|
|
public function testConfiguredPublicPathIsAccessible(): void
|
|
{
|
|
$accessControl = $this->createAccessControl(['imprint', 'privacy']);
|
|
|
|
$this->assertTrue($accessControl->isPublicPath('imprint'));
|
|
$this->assertTrue($accessControl->isPublicPath('/privacy'));
|
|
}
|
|
|
|
public function testPageSlugPathIsNotAutoPublic(): void
|
|
{
|
|
$accessControl = $this->createAccessControl(['imprint']);
|
|
|
|
$this->assertTrue($accessControl->isPublicPath('imprint'));
|
|
$this->assertFalse($accessControl->isPublicPath('page/imprint'));
|
|
}
|
|
|
|
public function testAlwaysPublicPrefixesRemainAccessible(): void
|
|
{
|
|
$accessControl = $this->createAccessControl([]);
|
|
|
|
$this->assertTrue($accessControl->isPublicPath('api/v1/health'));
|
|
$this->assertTrue($accessControl->isPublicPath('auth/microsoft/callback'));
|
|
}
|
|
}
|