mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
PHRAS-508_acl-cache
- wip
This commit is contained in:
@@ -283,7 +283,7 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
|
||||
$this->checkRedirection(self::$DI['client']->getResponse(), '/admin/collection/' . self::$DI['collection']->get_base_id() . '/?success=1');
|
||||
|
||||
$this->assertTrue(self::$DI['app']->getAclForUser(self::$DI['user_alt1'])->has_right_on_base(self::$DI['collection']->get_base_id(), 'order_master'));
|
||||
$this->assertTrue(self::$DI['app']->getAclForUser(self::$DI['user_alt1'])->has_right_on_base(self::$DI['collection']->get_base_id(), \ACL::ORDER_MASTER));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -70,9 +70,9 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$datas = json_decode($response->getContent());
|
||||
$this->assertFalse($datas->error);
|
||||
|
||||
$this->assertTrue(self::$DI['app']->getAclForUser($user)->has_right_on_base(self::$DI['collection']->get_base_id(), "manage"));
|
||||
$this->assertTrue(self::$DI['app']->getAclForUser($user)->has_right_on_base(self::$DI['collection']->get_base_id(), "canpush"));
|
||||
$this->assertTrue(self::$DI['app']->getAclForUser($user)->has_right_on_base(self::$DI['collection']->get_base_id(), "canreport"));
|
||||
$this->assertTrue(self::$DI['app']->getAclForUser($user)->has_right_on_base(self::$DI['collection']->get_base_id(), \ACL::COLL_MANAGE));
|
||||
$this->assertTrue(self::$DI['app']->getAclForUser($user)->has_right_on_base(self::$DI['collection']->get_base_id(), \ACL::CANPUSH));
|
||||
$this->assertTrue(self::$DI['app']->getAclForUser($user)->has_right_on_base(self::$DI['collection']->get_base_id(), \ACL::CANREPORT));
|
||||
|
||||
self::$DI['app']['orm.em']->refresh($user);
|
||||
self::$DI['app']['manipulator.user']->delete($user);
|
||||
@@ -355,10 +355,10 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
self::$DI['app']->getAclForUser($user)->give_access_to_base([$base_id]);
|
||||
|
||||
$rights = [
|
||||
'canputinalbum' => '1'
|
||||
, 'candwnldhd' => '1'
|
||||
, 'candwnldsubdef' => '1'
|
||||
, 'nowatermark' => '1'
|
||||
\ACL::CANPUTINALBUM => '1',
|
||||
\ACL::CANDWNLDHD => '1',
|
||||
'candwnldsubdef' => '1',
|
||||
\ACL::NOWATERMARK => '1'
|
||||
];
|
||||
|
||||
self::$DI['app']->getAclForUser($user)->update_rights_to_base($collection->get_base_id(), $rights);
|
||||
|
@@ -1010,10 +1010,12 @@ class ApiJsonTest extends ApiTestCase
|
||||
$collection->set_public_presentation('none');
|
||||
}
|
||||
$app->getAclForUser(self::$DI['user_notAdmin'])->update_rights_to_base(
|
||||
$collection->get_base_id(), array(
|
||||
'candwnldpreview' => 1,
|
||||
'candwnldhd' => 1
|
||||
));
|
||||
$collection->get_base_id(),
|
||||
[
|
||||
\ACL::CANDWNLDPREVIEW => 1,
|
||||
\ACL::CANDWNLDHD => 1
|
||||
]
|
||||
);
|
||||
|
||||
/** @var \record_adapter $record_1 */
|
||||
$record_1 = self::$DI['record_1'];
|
||||
@@ -1052,8 +1054,8 @@ class ApiJsonTest extends ApiTestCase
|
||||
$this->setToken($this->userAccessToken);
|
||||
|
||||
self::$DI['app']->getAclForUser(self::$DI['user_notAdmin'])->update_rights_to_base(self::$DI['collection']->get_base_id(), array(
|
||||
'candwnldpreview' => 1,
|
||||
'candwnldhd' => 0
|
||||
\ACL::CANDWNLDPREVIEW => 1,
|
||||
\ACL::CANDWNLDHD => 0
|
||||
));
|
||||
|
||||
$route = '/api/v1/records/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/embed/';
|
||||
@@ -1075,10 +1077,13 @@ class ApiJsonTest extends ApiTestCase
|
||||
{
|
||||
$this->setToken($this->userAccessToken);
|
||||
|
||||
self::$DI['app']->getAclForUser(self::$DI['user_notAdmin'])->update_rights_to_base(self::$DI['collection']->get_base_id(), array(
|
||||
'candwnldpreview' => 0,
|
||||
'candwnldhd' => 0
|
||||
));
|
||||
self::$DI['app']->getAclForUser(self::$DI['user_notAdmin'])->update_rights_to_base(
|
||||
self::$DI['collection']->get_base_id(),
|
||||
[
|
||||
\ACL::CANDWNLDPREVIEW => 0,
|
||||
\ACL::CANDWNLDHD => 0
|
||||
]
|
||||
);
|
||||
|
||||
$route = '/api/v1/records/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/embed/';
|
||||
|
||||
|
@@ -85,11 +85,11 @@ class PropertyTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
->will($this->returnValue(true));
|
||||
$acl->expects($this->any())
|
||||
->method('has_right_on_base')
|
||||
->with($this->isType(\PHPUnit_Framework_Constraint_IsType::TYPE_INT), $this->equalTo('chgstatus'))
|
||||
->with($this->isType(\PHPUnit_Framework_Constraint_IsType::TYPE_INT), $this->equalTo(\ACL::CHGSTATUS))
|
||||
->will($this->returnValue(true));
|
||||
$acl->expects($this->any())
|
||||
->method('has_right_on_sbas')
|
||||
->with($this->isType(\PHPUnit_Framework_Constraint_IsType::TYPE_INT), $this->equalTo('chgstatus'))
|
||||
->with($this->isType(\PHPUnit_Framework_Constraint_IsType::TYPE_INT), $this->equalTo(\ACL::CHGSTATUS))
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$aclProvider = $this->getMockBuilder('Alchemy\Phrasea\Authentication\ACLProvider')
|
||||
|
@@ -105,7 +105,10 @@ class RecordsRequestTest extends \PhraseanetAuthenticatedTestCase
|
||||
public function testSimpleWithoutBasRights()
|
||||
{
|
||||
self::$DI['app']->getAclForUser(self::$DI['app']->getAuthenticatedUser())
|
||||
->update_rights_to_base(self::$DI['record_2']->get_base_id(), ['chgstatus' => 0]);
|
||||
->update_rights_to_base(
|
||||
self::$DI['record_2']->get_base_id(),
|
||||
[\ACL::CHGSTATUS => 0]
|
||||
);
|
||||
|
||||
$request = new Request([
|
||||
'lst' => implode(';', [
|
||||
@@ -113,7 +116,7 @@ class RecordsRequestTest extends \PhraseanetAuthenticatedTestCase
|
||||
])
|
||||
]);
|
||||
|
||||
$records = RecordsRequest::fromRequest(self::$DI['app'], $request, false, ['chgstatus']);
|
||||
$records = RecordsRequest::fromRequest(self::$DI['app'], $request, false, [\ACL::CHGSTATUS]);
|
||||
|
||||
$this->assertEquals(0, count($records));
|
||||
$this->assertEquals(1, count($records->received()));
|
||||
|
Reference in New Issue
Block a user