<?php

namespace MintyPHP\Tests\Http;

use MintyPHP\Http\AccessControl;
use PHPUnit\Framework\TestCase;

class AccessControlTest extends TestCase
{
    public function testConfiguredPublicPathIsAccessible(): void
    {
        $accessControl = new AccessControl(['imprint', 'privacy']);

        $this->assertTrue($accessControl->isPublicPath('imprint'));
        $this->assertTrue($accessControl->isPublicPath('/privacy'));
    }

    public function testPageSlugPathIsNotAutoPublic(): void
    {
        $accessControl = new AccessControl(['imprint']);

        $this->assertTrue($accessControl->isPublicPath('imprint'));
        $this->assertFalse($accessControl->isPublicPath('page/imprint'));
    }

    public function testAlwaysPublicPrefixesRemainAccessible(): void
    {
        $accessControl = new AccessControl([]);

        $this->assertTrue($accessControl->isPublicPath('api/v1/health'));
        $this->assertTrue($accessControl->isPublicPath('auth/microsoft/callback'));
    }
}
