Example #1
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());
 }
Example #2
0
 protected function action()
 {
     \UsersRegistration_Registrate::testCaptcha($this->getParam('captcha'));
     $this->api = \Extasy\Users\Social\TwitterApiFactory::getInstance();
     $userTwitterProfile = $this->api->getCurrentSession();
     \UsersRegistration::signup($this->getParam('login'), \Extasy\Columns\Password::generatePassword(), $this->getParam('email'), ['social_networks' => ['twitter' => $userTwitterProfile['id']]]);
     return true;
 }
Example #3
0
 /**
  * @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();
 }
Example #4
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());
 }
Example #5
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());
 }
Example #6
0
 public static function setupUsers($data)
 {
     self::dbFixture(\UserAccount::getTableName(), array());
     foreach ($data as $key => $userRow) {
         $userRights = null;
         if (!isset($userRow['password'])) {
             $userRow['password'] = self::DefaultPassword;
         }
         self::checkUserRow($userRow);
         if (isset($userRow['rights'])) {
             $userRights = $userRow['rights'];
         }
         $userRow['password'] = Password::hash($userRow['password']);
         $user = new \UserAccount($userRow);
         $user->insert();
         if (!empty($userRights)) {
             $user->rights = $userRights;
             $user->update();
         }
     }
 }
Example #7
0
 protected function checkPassword($password, $user)
 {
     return passwordColumn::hash($password) == $user->password->getValue();
 }
Example #8
0
use Extasy\Audit\Api\ApiOperation;
use Extasy\Audit\Record;
use Extasy\Audit\Log;
use Extasy\tests\system_register\Restorator;
use Extasy\Columns\Password as passwordColumn;
$register = new \SystemRegister('/System/');
try {
    $register->delete('Audit');
} catch (\Exception $e) {
}
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);
Example #9
0
 public function testNormalValue()
 {
     Password::validatePassword('abc123\\#');
 }