<?php

/*
 * This file is part of the VITICORE2 package.
 *
 * (c) CP Creation <web@cpcreation.fr>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CpCreation\VitiCore\Tests\Security;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Yaml\Yaml;

final class ContentSecurityPolicyConfigTest extends TestCase
{
    public function testProductionPolicyAllowsDefaultDepotMapTiles(): void
    {
        $configuration = Yaml::parseFile(
            \dirname(__DIR__, 2).'/src/Bridge/Symfony/Bundle/Resources/config/packages/prod/nelmio_security.yaml',
        );
        $imageSources = $configuration['nelmio_security']['csp']['enforce']['img-src'] ?? [];

        self::assertContains(
            'https://*.tile.openstreetmap.org',
            $imageSources,
            'La CSP de production doit autoriser les tuiles utilisées par la carte des dépôts VitiCore.',
        );
    }
}
