public function setUp() { parent::setUp(); USVN_Translation::initTranslation("en_US", "app/locale"); $data = array("users_id" => 2, "users_login" => 'testlogin', "users_password" => USVN_Crypt::crypt('testpassword'), "users_is_admin" => false); $this->db->insert("usvn_users", $data); }
public function testCrypt() { $crypt = USVN_Crypt::crypt("toto"); $this->assertTrue(USVN_Crypt::checkPassword("toto", $crypt)); $this->assertFalse(USVN_Crypt::checkPassword("tutu", $crypt)); $crypt = '$apr1$A.IgA/..$vcK1pKAvkEGvAT0ob46Bw0'; $this->assertTrue(USVN_Crypt::checkPassword("toto", $crypt)); }
public function setUp() { parent::setUp(); $this->userTable = new USVN_Db_Table_Users(); $this->user = $this->userTable->fetchNew(); $this->user->users_login = '******'; $this->user->users_password = USVN_Crypt::crypt("test"); $this->userid = $this->user->save(); $this->groups = new USVN_Db_Table_Groups(); $group = $this->groups->insert(array("groups_id" => 42, "groups_name" => "test", "groups_description" => "test")); $this->groups->insert(array("groups_id" => 43, "groups_name" => "test2", "groups_description" => "test2")); $this->groups->insert(array("groups_id" => 44, "groups_name" => "test3", "groups_description" => "test3")); }
/** * Crypt user password if changed * Check login if changed * * @return void * @throws USVN_Exception, Zend_Exception */ protected function _update() { $this->checkEmailAddress($this->_data['users_email']); if ($this->_data['users_login'] != $this->_cleanData['users_login']) { $user = $this->getTable()->fetchRow(array("users_login = ?" => $this->_data['users_login'])); if ($user !== null) { throw new USVN_Exception(sprintf(T_("Login %s already exist."), $user->login)); } $this->checkLogin($this->_data['users_login']); } if ($this->_data['users_password'] != $this->_cleanData['users_password']) { $this->checkPassword($this->_data['users_password']); $this->_data['users_password'] = USVN_Crypt::crypt($this->_data['users_password']); } }
/** * Create and save a user * * @return USVN_Db_Table_Row_User */ protected function createUser($login, $password = "******") { $table = new USVN_Db_Table_Users(); try { $user = $table->insert(array("users_login" => $login, "users_password" => USVN_Crypt::crypt($password), 'users_firstname' => 'firstname', 'users_lastname' => 'lastname', 'users_email' => '*****@*****.**')); $user = $table->find($user)->current(); return $user; } catch (Exception $e) { $this->fail($login . " : " . $e->getMessage()); } }