示例#1
0
 public function tearDown()
 {
     parent::tearDown();
     if (UsersLogin::isLogined()) {
         UsersLogin::logout();
     }
 }
示例#2
0
 public function setup()
 {
     parent::setUp();
     $this->api = new TestFacebookApi();
     FacebookApiFactory::setInstance($this->api);
     Helper::dbFixtures([Network::TableName => [['name' => 'facebook'], ['name' => 'vkontakte']], SocialNetworks::UIDTable => [['user_id' => 1, 'network_id' => 1, 'uid' => self::UID]]]);
 }
示例#3
0
 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();
     }
 }
示例#4
0
 public function setUp()
 {
     parent::setUp();
     Helper::setupUsers(array(array('login' => self::Login, 'password' => self::Password, 'email' => self::Email), array('login' => self::SecondLogin, 'password' => self::Password, 'email' => self::Email)));
     //		SocialNetworks::createTables();
     Helper::dbFixtures([\Extasy\Users\Social\Network::TableName => [['name' => 'facebook'], ['name' => 'vkontakte']], SocialNetworks::UIDTable => [['user_id' => 1, 'network_id' => 1, 'uid' => self::UID]]]);
 }
示例#5
0
 public function setUp()
 {
     parent::setUp();
     Restorator::restore();
     Helper::setupUsers([['login' => self::RootLogin, 'password' => self::Password, 'rights' => [\CMSAuth::AdministratorRoleName => true]]]);
     \UsersLogin::login(self::RootLogin, self::Password);
 }
示例#6
0
 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;
 }
示例#7
0
 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());
 }
示例#8
0
 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());
 }
示例#9
0
文件: ApiTest.php 项目: gudwin/extasy
 /**
  * @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();
 }
示例#10
0
 public function setUp()
 {
     parent::setUp();
     Restorator::restore();
     Helper::setupUsers(array(array('login' => self::Login, 'password' => self::Password, 'email' => self::Email)));
     $this->configureLoginAttempts(5, 10);
     $this->cleanUpSchemes();
     RegistrationAcceptedEmail::install();
     RegistrationConfirmationEmail::install();
 }
示例#11
0
 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());
 }
示例#12
0
 public function tearDown()
 {
     if (UsersLogin::isLogined()) {
         UsersLogin::logout();
     }
     Helper::cleanACL();
     Helper::cleanSchedule();
     Helper::cleanAudit();
     parent::tearDown();
 }
示例#13
0
 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());
 }
示例#14
0
 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());
 }
示例#15
0
 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();
 }
示例#16
0
 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();
 }
示例#17
0
}
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, 'Шаблон письма-оповещения о наступлении критического события аудита');
}