static function update($schema = 'Myisam') { $config = Piwik_Config::getInstance(); $rootLogin = $config->superuser['login']; try { // throws an exception if invalid Piwik::checkValidLoginString($rootLogin); } catch (Exception $e) { throw new Exception('Superuser login name "' . $rootLogin . '" is no longer a valid format. ' . $e->getMessage() . ' Edit your config/config.ini.php to change it.'); } }
function validateOwner() { try { $login = $this->owner->getValue(); if (!empty($login)) { Piwik::checkValidLoginString($login); } } catch (Exception $e) { $this->setMessage($e->getMessage()); return false; } return true; }
public function test_checkValidLoginString() { Piwik::createConfigObject(); Piwik_Config::getInstance()->setTestEnvironment(); $fail = array('', ' ', 'a', 'aa', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'alpha/beta', 'alpha:beta', 'alpha;beta', 'alpha<beta', 'alpha=beta', 'alpha>beta', 'alpha?beta'); foreach ($fail as $toTest) { try { Piwik::checkValidLoginString($toTest); $this->fail('Exception raised, expected fail: ' . $toTest); } catch (Exception $e) { $this->pass(); } } $pass = array('aaa', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', '*****@*****.**'); foreach ($pass as $toTest) { try { Piwik::checkValidLoginString($toTest); $this->pass(); } catch (Exception $e) { $this->fail('Exception raised, expected pass: ' . $toTest); } } }
private function checkLogin($userLogin) { if ($this->userExists($userLogin)) { throw new Exception(Piwik_TranslateException('UsersManager_ExceptionLoginExists', $userLogin)); } Piwik::checkValidLoginString($userLogin); }
/** * @group Core * @group Piwik * @dataProvider getValidLoginStringData */ public function testCheckValidLoginString($toTest) { $this->assertNull(Piwik::checkValidLoginString($toTest)); }