mirror of
https://github.com/wallabag/wallabag.git
synced 2025-09-15 18:57:05 +00:00
Add availability to disable an importer
This commit is contained in:
parent
cad5a24fb6
commit
7e7674a4a6
17 changed files with 332 additions and 3 deletions
45
tests/Security/Voter/ImportVoterTest.php
Normal file
45
tests/Security/Voter/ImportVoterTest.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace Security\Voter;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
|
||||
use Wallabag\Entity\SiteCredential;
|
||||
use Wallabag\Entity\User;
|
||||
use Wallabag\Security\Voter\ImportVoter;
|
||||
|
||||
class ImportVoterTest extends TestCase
|
||||
{
|
||||
private $token;
|
||||
private $user;
|
||||
private $importVoter;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->token = $this->createMock(TokenInterface::class);
|
||||
$this->user = new User();
|
||||
|
||||
$this->importVoter = new ImportVoter();
|
||||
}
|
||||
|
||||
public function testVoteReturnsAbstainForInvalidSubject(): void
|
||||
{
|
||||
$this->assertSame(VoterInterface::ACCESS_ABSTAIN, $this->importVoter->vote($this->token, new \stdClass(), [ImportVoter::USE_IMPORTER]));
|
||||
}
|
||||
|
||||
public function testVoteReturnsAbstainForInvalidAttribute(): void
|
||||
{
|
||||
$this->assertSame(VoterInterface::ACCESS_ABSTAIN, $this->importVoter->vote($this->token, new SiteCredential(new User()), ['INVALID']));
|
||||
}
|
||||
|
||||
public function testVoteReturnsDeniedForNonSiteCredentialUserEdit(): void
|
||||
{
|
||||
$this->assertSame(VoterInterface::ACCESS_DENIED, $this->importVoter->vote($this->token, new SiteCredential(new User()), [ImportVoter::USE_IMPORTER]));
|
||||
}
|
||||
|
||||
public function testVoteReturnsGrantedForSiteCredentialUserEdit(): void
|
||||
{
|
||||
$this->assertSame(VoterInterface::ACCESS_GRANTED, $this->importVoter->vote($this->token, new SiteCredential($this->user), [ImportVoter::USE_IMPORTER]));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue