Skip to content

Commit

Permalink
CI: Add tests for ThemeController - refs BT#21621
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Jul 1, 2024
1 parent c590ece commit d67702b
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/CoreBundle/Controller/ThemeControllerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

/* For licensing terms, see /license.txt */

declare(strict_types=1);

namespace Chamilo\Tests\CoreBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpFoundation\Response;

class ThemeControllerTest extends WebTestCase
{

public function testValidAccess(): void
{
$client = static::createClient();

$client->request('GET', '/themes/chamilo/colors.css');

$this->assertResponseIsSuccessful();
}

public function testInvalidAccess(): void
{
$client = static::createClient();

$client->request('GET', '/themes/chamilo/default.css');

$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
}

public function testAccessToSystemFiles(): void
{
$client = static::createClient();
$client->request('GET', '/themes/chamilo/../../../../../../etc/passwd');

$this->assertResponseStatusCodeSame(Response::HTTP_INTERNAL_SERVER_ERROR);


$client->request('GET', 'themes/chamilo/../../../.env');

$this->assertResponseStatusCodeSame(Response::HTTP_INTERNAL_SERVER_ERROR);
}
}

0 comments on commit d67702b

Please sign in to comment.