feat(share) : controllers status/browse/download du partage
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Functional\Controller;
|
||||
|
||||
use App\Entity\User;
|
||||
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class ShareBrowseTest extends WebTestCase
|
||||
{
|
||||
public function testBrowseRequiresAuthentication(): void
|
||||
{
|
||||
$client = self::createClient();
|
||||
$client->request('GET', '/api/share/browse?path=/');
|
||||
|
||||
self::assertSame(401, $client->getResponse()->getStatusCode());
|
||||
}
|
||||
|
||||
public function testBrowseRejectsPathTraversal(): void
|
||||
{
|
||||
$client = self::createClient();
|
||||
$this->login($client);
|
||||
|
||||
$client->request('GET', '/api/share/browse?path='.urlencode('../etc'));
|
||||
|
||||
self::assertSame(400, $client->getResponse()->getStatusCode());
|
||||
}
|
||||
|
||||
public function testBrowseReturns409WhenNotConfigured(): void
|
||||
{
|
||||
$client = self::createClient();
|
||||
$this->login($client);
|
||||
|
||||
$client->request('GET', '/api/share/browse?path=');
|
||||
|
||||
self::assertSame(409, $client->getResponse()->getStatusCode());
|
||||
}
|
||||
|
||||
public function testStatusReturnsDisabledByDefault(): void
|
||||
{
|
||||
$client = self::createClient();
|
||||
$this->login($client);
|
||||
|
||||
$client->request('GET', '/api/share/status');
|
||||
|
||||
self::assertResponseIsSuccessful();
|
||||
$data = json_decode($client->getResponse()->getContent(), true);
|
||||
self::assertFalse($data['enabled']);
|
||||
}
|
||||
|
||||
private function login(KernelBrowser $client): void
|
||||
{
|
||||
$em = self::getContainer()->get('doctrine.orm.entity_manager');
|
||||
$user = $em->getRepository(User::class)->findOneBy(['username' => 'alice']);
|
||||
$client->loginUser($user);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user