public function setUp() { parent::setUp(); $model = new TestDocument(); $model->createDatabaseTable(true); Helper::dbFixture(SITEMAP_TABLE, []); \ACL::create(SitemapModel::PermissionName); Configure::write('Sitemap', ['Menu' => ['title' => self::Title, 'depth' => 3]]); Helper::setupUsers([['login' => self::AdminUser, 'rights' => [SitemapModel::PermissionName => true]], ['login' => self::GuestUser]]); $documents = [['name' => 'first', 'sitemap' => ['count' => 1]], ['name' => 'second'], ['name' => 'third', 'sitemap' => ['parent' => 1]]]; foreach ($documents as $key => $row) { $documents[$key] = new TestDocument($row); $documents[$key]->insert(); $sitemapModel = new SitemapModel(); $sitemapModel->name = $row['name']; $sitemapModel->full_url = $row['name']; $sitemapModel->linkToModel($documents[$key]); if (isset($row['sitemap'])) { foreach ($row['sitemap'] as $key => $value) { $sitemapModel->{$key} = $value; } } $sitemapModel->insert(); } }
public function setup() { parent::setUp(); \ACL::create(\CMSAuth::AdministratorRoleName); Helper::setupUsers(array(array('login' => self::login, 'password' => self::password, 'rights' => array(\CMSAuth::AdministratorRoleName => true)))); $user = \UserAccount::getByLogin(self::login); \ACL::grant(\CMSAuth::AdministratorRoleName, $user->rights->getEntity()); }
public function testGrant() { ACL::create('test/test2'); ACL::grant('test/test2', 'e1'); $this->assertEquals(1, DBSimple::getRowsCount(ACL_GRANT_TABLE)); $found = DBSimple::get(ACL_GRANT_TABLE, array('actionId' => 2)); $this->assertEquals('e1', $found['entity']); }
public function testCreateWithCheckValues() { ACL::create('test/test2'); $result = DBSimple::get(ACL_TABLE, array('id' => 1)); $this->assertEquals('test', $result['name']); $result = DBSimple::get(ACL_TABLE, array('id' => 2)); $this->assertEquals('test2', $result['name']); }
public function testExport() { ACL::create('a/b/c'); ACL::create('a/b/d'); ACL::create('a/e'); $exported = ACLMisc::export(); $this->assertEquals(1, sizeof($exported)); $this->assertEquals(2, sizeof($exported[0]['children'])); $this->assertEquals(2, sizeof($exported[0]['children'][0]['children'])); }
public function testCallApiOperationWithGrants() { TestsHelper::dbFixture(\UserAccount::getTableName(), array(array('login' => 'test', 'password' => passwordColumn::hash('testtest')))); $user = \UserAccount::getById(1); \ACL::create(TestApiWithACLOperation::RightName); \ACL::grant(TestApiWithACLOperation::RightName, $user->obj_rights->getEntity()); \UsersLogin::login('test', 'testtest'); $method = new TestApiWithACLOperation(); $this->assertTrue($method->exec()); }
public function testDeleteAndCheckEntityDeletion() { ACL::create('test/test2/test3'); ACL::grant('test/test2/test3', 'o1'); ACL::grant('test', 'o2'); ACL::remove('test/test2'); $this->assertEquals(1, DBSimple::getRowsCount(ACL_GRANT_TABLE)); // Проверяем, что удалились именно нужные данные $this->assertEquals(true, ACL::isGranted('test', 'o2')); }
public function testDeleteGrant() { $path = 'test/test2'; $entity = 'obj1'; ACL::create($path); ACL::grant($path, $entity); $this->assertEquals(true, ACL::isGranted($path, $entity)); ACL::unGrant($path, $entity); $this->assertEquals(false, ACL::isGranted($path, $entity)); }
public function setUp() { parent::setUp(); \EventController::cleanUp(); \ACL::create(\CMSAuth::SystemAdministratorRoleName); \ACL::create(\CMSAuth::AdministratorRoleName); \ACL::create(\UserAccount::PermissionName); \ACL::create(\Extasy\sitemap\Models\SitemapModel::PermissionName); Helper::dbFixtures([SITEMAP_TABLE => [['name' => 'root', 'full_url' => '/root/', 'document_id' => 1], ['name' => '/apple/', 'full_url' => '/apple/', 'document_id' => 1], ['name' => '/banana/', 'full_url' => '/banana/', 'document_id' => 1], ['name' => 'orange', 'full_url' => '/orange/', 'document_id' => 1], ['name' => '/pineapple/', 'full_url' => '/pineapple/', 'document_id' => 1]]]); Helper::setupUsers([['login' => 'root', 'password' => self::PASSWORD, 'rights' => [\CMSAuth::SystemAdministratorRoleName => 1]], ['login' => 'clean_admin', 'password' => self::PASSWORD, 'rights' => [\CMSAuth::AdministratorRoleName => 1]], ['login' => 'users', 'password' => self::PASSWORD, 'rights' => [\CMSAuth::AdministratorRoleName => 1, \UserAccount::PermissionName => 1]], ['login' => 'sitemap', 'password' => self::PASSWORD, 'rights' => [\CMSAuth::AdministratorRoleName => 1, \Extasy\sitemap\Models\SitemapModel::PermissionName => 1]]]); \UsersLogin::logout(); }
public function call($method, $path, $title = '') { switch ($method) { case 'create': print ACL::create($path, $title); break; case 'remove': ACL::remove($path); break; } die; }
public function setUp() { parent::setUp(); Helper::dbFixture(Job::TableName, array()); $this->setRunnerTimeout(0); Restorator::restore(); Helper::setupUsers([['login' => self::Login, 'password' => self::Password], ['login' => 'guest', 'password' => self::Password]]); $user = \UserAccount::getByLogin(self::Login); \ACL::create(\CMSAuth::SystemAdministratorRoleName); \ACL::grant(\CMSAuth::SystemAdministratorRoleName, $user->rights->getEntity()); \UsersLogin::forceLogin($user); TestAction::setUp(); }
public static function cleanACL() { self::dbFixture(ACL_GRANT_TABLE, array()); self::dbFixture(ACL_TABLE, array()); \ACL::create(\CMSAuth::AdministratorRoleName); }
public static function install() { ACL::create(self::SystemAdministratorRoleName, 'System Administrator'); ACL::create(self::AdministratorRoleName, 'Administrator'); }