/** * try to set password */ public function testSetPassword() { $user = $this->testAddEmailAccount(); $newPassword = Tinebase_Record_Abstract::generateUID(); $this->_backend->inspectSetPassword($this->_objects['user']->getId(), $newPassword); // fetch email pw from db $queryResult = $this->_fetchUserFromDovecotUsersTable($user->getId()); $hashPw = new Hash_Password(); $this->assertTrue($hashPw->validate($queryResult[0]['password'], $newPassword), 'password mismatch'); }
/** * _authenticateValidateResult() - This method attempts to validate that the record in the * result set is indeed a record that matched the identity provided to this adapter. * * @param array $resultIdentity * @return Zend_Auth_Result */ protected function _authenticateValidateResult($resultIdentity) { $passwordHash = substr($resultIdentity[$this->_credentialColumn], 0, 1) === '{' ? $resultIdentity[$this->_credentialColumn] : '{PLAIN-MD5}' . $resultIdentity[$this->_credentialColumn]; if (Hash_Password::validate($passwordHash, $this->_credential) !== true) { $this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID; $this->_authenticateResultInfo['messages'][] = 'Supplied credential is invalid.'; return $this->_authenticateCreateAuthResult(); } unset($resultIdentity['zend_auth_credential_match']); $this->_resultRow = $resultIdentity; $this->_authenticateResultInfo['code'] = Zend_Auth_Result::SUCCESS; $this->_authenticateResultInfo['messages'][] = 'Authentication successful.'; return $this->_authenticateCreateAuthResult(); }
/** * try to update an email account */ public function testSetPassword() { // add smtp user $user = $this->testAddUser(); $newPassword = Tinebase_Record_Abstract::generateUID(); $this->_backend->setPassword($user->getId(), $newPassword); // fetch email pw from db $db = Tinebase_EmailUser::getInstance(Tinebase_Config::SMTP)->getDb(); $select = $db->select()->from(array('smtp_users'))->where($db->quoteIdentifier('userid') . ' = ?', $user->getId()); $stmt = $db->query($select); $queryResult = $stmt->fetch(); $stmt->closeCursor(); $this->assertTrue(isset($queryResult['passwd']), 'no password in result: ' . print_r($queryResult, TRUE)); $hashPw = new Hash_Password(); $this->assertTrue($hashPw->validate($queryResult['passwd'], $newPassword), 'password mismatch: ' . print_r($queryResult, TRUE)); }