|
@@ -12,6 +12,7 @@ namespace Sonata\AdminBundle\Tests\Admin\Security\Acl\Permission;
|
|
|
|
|
|
use Sonata\AdminBundle\Security\Handler\AclSecurityHandler;
|
|
use Sonata\AdminBundle\Security\Handler\AclSecurityHandler;
|
|
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
|
|
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
|
|
|
|
+use Sonata\AdminBundle\Security\Acl\Permission\MaskBuilder;
|
|
|
|
|
|
class AclSecurityHandlerTest extends \PHPUnit_Framework_TestCase
|
|
class AclSecurityHandlerTest extends \PHPUnit_Framework_TestCase
|
|
{
|
|
{
|
|
@@ -27,9 +28,9 @@ class AclSecurityHandlerTest extends \PHPUnit_Framework_TestCase
|
|
->method('isGranted')
|
|
->method('isGranted')
|
|
->will($this->returnValue(true));
|
|
->will($this->returnValue(true));
|
|
|
|
|
|
- $aclProvider = $this->getMock('Symfony\Component\Security\Acl\Model\AclProviderInterface');
|
|
|
|
|
|
+ $aclProvider = $this->getMock('Symfony\Component\Security\Acl\Model\MutableAclProviderInterface');
|
|
|
|
|
|
- $handler = new AclSecurityHandler($securityContext, $aclProvider, array());
|
|
|
|
|
|
+ $handler = new AclSecurityHandler($securityContext, $aclProvider, 'Sonata\AdminBundle\Security\Acl\Permission\MaskBuilder', array());
|
|
|
|
|
|
$this->assertTrue($handler->isGranted($admin, array('TOTO')));
|
|
$this->assertTrue($handler->isGranted($admin, array('TOTO')));
|
|
$this->assertTrue($handler->isGranted($admin, 'TOTO'));
|
|
$this->assertTrue($handler->isGranted($admin, 'TOTO'));
|
|
@@ -39,7 +40,7 @@ class AclSecurityHandlerTest extends \PHPUnit_Framework_TestCase
|
|
->method('isGranted')
|
|
->method('isGranted')
|
|
->will($this->returnValue(false));
|
|
->will($this->returnValue(false));
|
|
|
|
|
|
- $handler = new AclSecurityHandler($securityContext, $aclProvider, array());
|
|
|
|
|
|
+ $handler = new AclSecurityHandler($securityContext, $aclProvider, 'Sonata\AdminBundle\Security\Acl\Permission\MaskBuilder', array());
|
|
|
|
|
|
$this->assertFalse($handler->isGranted($admin, array('TOTO')));
|
|
$this->assertFalse($handler->isGranted($admin, array('TOTO')));
|
|
$this->assertFalse($handler->isGranted($admin, 'TOTO'));
|
|
$this->assertFalse($handler->isGranted($admin, 'TOTO'));
|
|
@@ -61,9 +62,9 @@ class AclSecurityHandlerTest extends \PHPUnit_Framework_TestCase
|
|
->method('getSecurityInformation')
|
|
->method('getSecurityInformation')
|
|
->will($this->returnValue($informations));
|
|
->will($this->returnValue($informations));
|
|
|
|
|
|
- $aclProvider = $this->getMock('Symfony\Component\Security\Acl\Model\AclProviderInterface');
|
|
|
|
|
|
+ $aclProvider = $this->getMock('Symfony\Component\Security\Acl\Model\MutableAclProviderInterface');
|
|
|
|
|
|
- $handler = new AclSecurityHandler($securityContext, $aclProvider, array());
|
|
|
|
|
|
+ $handler = new AclSecurityHandler($securityContext, $aclProvider, 'Sonata\AdminBundle\Security\Acl\Permission\MaskBuilder', array());
|
|
|
|
|
|
$results = $handler->buildSecurityInformation($admin);
|
|
$results = $handler->buildSecurityInformation($admin);
|
|
|
|
|
|
@@ -79,9 +80,9 @@ class AclSecurityHandlerTest extends \PHPUnit_Framework_TestCase
|
|
->method('isGranted')
|
|
->method('isGranted')
|
|
->will($this->throwException(new AuthenticationCredentialsNotFoundException('FAIL')));
|
|
->will($this->throwException(new AuthenticationCredentialsNotFoundException('FAIL')));
|
|
|
|
|
|
- $aclProvider = $this->getMock('Symfony\Component\Security\Acl\Model\AclProviderInterface');
|
|
|
|
|
|
+ $aclProvider = $this->getMock('Symfony\Component\Security\Acl\Model\MutableAclProviderInterface');
|
|
|
|
|
|
- $handler = new AclSecurityHandler($securityContext, $aclProvider, array());
|
|
|
|
|
|
+ $handler = new AclSecurityHandler($securityContext, $aclProvider, 'Sonata\AdminBundle\Security\Acl\Permission\MaskBuilder', array());
|
|
|
|
|
|
$this->assertFalse($handler->isGranted($admin, 'raise exception', $admin));
|
|
$this->assertFalse($handler->isGranted($admin, 'raise exception', $admin));
|
|
}
|
|
}
|
|
@@ -98,9 +99,9 @@ class AclSecurityHandlerTest extends \PHPUnit_Framework_TestCase
|
|
->method('isGranted')
|
|
->method('isGranted')
|
|
->will($this->throwException(new \RunTimeException('FAIL')));
|
|
->will($this->throwException(new \RunTimeException('FAIL')));
|
|
|
|
|
|
- $aclProvider = $this->getMock('Symfony\Component\Security\Acl\Model\AclProviderInterface');
|
|
|
|
|
|
+ $aclProvider = $this->getMock('Symfony\Component\Security\Acl\Model\MutableAclProviderInterface');
|
|
|
|
|
|
- $handler = new AclSecurityHandler($securityContext, $aclProvider, array());
|
|
|
|
|
|
+ $handler = new AclSecurityHandler($securityContext, $aclProvider, 'Sonata\AdminBundle\Security\Acl\Permission\MaskBuilder', array());
|
|
|
|
|
|
$this->assertFalse($handler->isGranted($admin, 'raise exception', $admin));
|
|
$this->assertFalse($handler->isGranted($admin, 'raise exception', $admin));
|
|
}
|
|
}
|