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(); Helper::dbFixture(SITEMAP_TABLE, array(array('name' => 'sitemap', 'document_name' => Model::ModelName, 'document_id' => 1, 'full_url' => '//' . self::urlFixture), array('name' => 'sitemap2', 'script' => self::scriptPath, 'full_url' => '//' . self::scriptUrlFixture))); $this->dropTable(); $this->createTable(); self::$sitemapScriptCalledFlag = false; }
public function setUp() { include __DIR__ . DIRECTORY_SEPARATOR . 'import.php'; ACL::create(TestModel::PermissionName, ''); Helper::dbFixture(UserAccount::getTableName(), array(array('login' => self::LoginFixture, 'password' => passwordColumn::hash(self::PasswordFixture)))); $user = UserAccount::getById(1); ACL::grant(TestModel::PermissionName, $user->rights->getEntity()); }
/** * @expectedException \ForbiddenException */ public function testPermissionRequired() { TestsHelper::dbFixture(USERS_TABLE, array(array('login' => 'login', 'password' => passwordColumn::hash('testtest')))); TestsHelper::dbFixture(\ACL_GRANT_TABLE, array()); // \UsersLogin::login('login', 'testtest'); $operation = new ApiOperation(); $operation->exec(); }
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 static function run() { TestsHelper::dbFixture(ACL_TABLE, array()); Restorator::restore(); TestsHelper::dbFixture(USERS_TABLE, array(array('login' => self::loginFixture, 'password' => passwordColumn::hash(self::passwordFixture)))); // ACL::create(self::rightFixture); // $user = UserAccount::getByLogin(self::loginFixture); ACL::grant(self::rightFixture, $user->obj_rights->getEntity()); }
public function testCountForUser() { $dates = array(date('Y-m-d H:i:s', strtotime('-3 minute')), date('Y-m-d H:i:s', strtotime('-2 minute')), date('Y-m-d H:i:s', strtotime('-1 minute'))); Helper::dbFixture(UsersLogin::LoginAttemptsTable, array(array('host' => ip2long(self::SecondIpFixture), 'date' => $dates[0], 'status' => LoginAttempt::SuccessStatus, 'user_id' => 1), array('host' => ip2long(self::FirstIpFixture), 'date' => $dates[1], 'status' => LoginAttempt::FailStatus, 'user_id' => 1), array('host' => ip2long(self::FirstIpFixture), 'date' => $dates[2], 'status' => LoginAttempt::FailStatus, 'user_id' => 1))); UsersLogin::login(self::Login, self::Password); $user = UsersLogin::getCurrentSession(); $info = new LoginInfo(); $info->countForUser($user); $fixture = array('success' => array('ip' => self::SecondIpFixture, 'date' => $dates[0], 'method' => ''), 'fail' => array('ip' => self::FirstIpFixture, 'date' => $dates[2], 'count' => 2)); $this->assertEquals($fixture, $info->getViewData()); }
public function setUp() { parent::setUp(); include __DIR__ . DIRECTORY_SEPARATOR . 'import.php'; TestsHelper::dbFixture(USERS_TABLE, array(array('login' => self::loginFixture, 'email' => '*****@*****.**', 'password' => PasswordColumn::hash(self::passwordFixture)), array('login' => 'guest', 'email' => '*****@*****.**', 'password' => PasswordColumn::hash(self::passwordFixture)))); ACL::create(self::testReadRight, ''); ACL::create(self::testWriteRight, ''); try { SimpleCache::clear(ACLUser::CacheKey); } catch (\Exception $e) { } }
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(); }
} Restorator::restore(); \SystemRegisterSample::createCache(); TestsHelper::dbFixture(ACL_TABLE, array()); ACL::create(ApiOperation::RightName); // user record TestsHelper::dbFixture(USERS_TABLE, array(array('login' => 'login', 'password' => passwordColumn::hash('testtest')), array('login' => 'guest', 'password' => passwordColumn::hash('testtest')))); // grant user permission $user = UserAccount::getByLogin('login'); ACL::grant(ApiOperation::RightName, $user->obj_rights->getEntity()); \UsersLogin::login('login', 'testtest'); // base logs TestsHelper::dbFixture(Log::getTableName(), array(array('name' => 'Log1', 'critical' => 0, 'enable_logging' => 1), array('name' => 'Log2', 'critical' => 1, 'enable_logging' => 1))); // base records // - [different by user_id] // - [different by date] // - [different by content] TestsHelper::dbFixture(Record::getTableName(), array(array('log_id' => 1, 'date' => '2001-01-01 00:00:00', 'short' => 'short log', 'full' => 'full_log', 'user_id' => 1, 'user_login' => 'login'), array('log_id' => 2, 'date' => '2001-01-02 00:00:00', 'short' => 'short log', 'full' => 'full_log', 'user_id' => 1, 'user_login' => 'login'), array('log_id' => 1, 'date' => '2001-01-03 00:00:00', 'short' => 'short log', 'full' => 'full_log'))); // Create custom config if it exists $schemaName = 'Audit.CriticalEventName'; try { $config = \CConfig::getSchema($schemaName); $config->delete(); } catch (\Exception $e) { } finally { $config = \CConfig::createSchema($schemaName); $config->addControl('to', 'inputfield', 'Получатели письма', array(), '*****@*****.**'); $config->addControl('subject', 'inputfield', 'Тема письма', array(), 'Email Subject'); $config->addControl('content', 'htmlfield', 'Шаблон письма', array(), 'Message body'); $config->updateSchema($schemaName, 'Шаблон письма-оповещения о наступлении критического события аудита'); }
public function setUp() { Helper::dbFixture(UsersLogin::LoginAttemptsTable, array()); $_SESSION[UsersLogin::LogSessionKey] = 0; }