-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathAccessControlManagerTest.php
More file actions
72 lines (59 loc) · 2.28 KB
/
AccessControlManagerTest.php
File metadata and controls
72 lines (59 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
namespace PHPCR\Tests\AccessControlManagement;
use Jackalope\Security\Principal;
use PHPCR\Security\AccessControlListInterface;
use PHPCR\Security\AccessControlManagerInterface;
use PHPCR\Security\PrivilegeInterface;
require_once(__DIR__ . '/../../inc/BaseCase.php');
class AccessControlManagerTest extends \PHPCR\Test\BaseCase
{
/**
* @var AccessControlManagerInterface
*/
private $manager;
public function setup()
{
parent::setUp();
$this->manager = $this->session->getAccessControlManager();
}
public function testGetSupportedPrivileges()
{
$privileges = $this->manager->getSupportedPrivileges('/tests_general_base');
$privileges = $this->manager->getSupportedPrivileges();
}
public function testGetPolicies()
{
// var_dump($manager->getPolicies('/')->getAccessControlEntries());
}
public function testWriteAcl()
{
$manager = $this->session->getAccessControlManager();
$path = '/tests_general_base';
$list = $manager->getApplicablePolicies($path);
/** @var $policy AccessControlListInterface */
$policy = reset($list);
$policy->addAccessControlEntry(new Principal('foo'), array($this->manager->privilegeFromName(PrivilegeInterface::JCR_READ)));
$manager->setPolicy($path, $policy);
$this->session->save();
$session = $this->renewSession();
$acls = $session->getAccessControlManager()->getPolicies($path);
$acls = $session->getAccessControlManager()->getApplicablePolicies($path);
$this->assertCount(1, $acls);
}
public function testGetPrivilegeFromName()
{
$privilege = $this->manager->privilegeFromName(PrivilegeInterface::JCR_READ);
$this->assertInstanceof('\PHPCR\Security\PrivilegeInterface', $privilege);
$this->assertEquals(PrivilegeInterface::JCR_READ, $privilege->getName());
$this->assertFalse($privilege->isAbstract());
$this->assertFalse($privilege->isAggregate());
$this->assertEquals(array(), $privilege->getAggregatePrivileges());
}
/**
* @expectedException \PHPCR\Security\AccessControlException
*/
public function testGetPrivilegeByNameNotFound()
{
$this->manager->privilegeFromName('foobar');
}
}