/** * Returns URL-encoded parameters needed to make an API call. * @param str $username * @return str Parameters to use in a URL to make an API call */ public static function getAuthParameters($username) { $owner_dao = DAOFactory::getDAO('OwnerDAO'); $pwd_from_db = $owner_dao->getPass($username); $api_secret = Session::getAPISecretFromPassword($pwd_from_db); return 'un=' . urlencode($username) . '&as=' . urlencode($api_secret); }
public function testGetAdditionalItems() { $builders = $this->buildData(); // Test that an item is added in the RSS feed when the crawler log is not writable $controller = new RSSController(true); $config = Config::getInstance(); $config->setValue('log_location', '/something/that/doesnt/exits'); $_GET['un'] = '*****@*****.**'; $_GET['as'] = Session::getAPISecretFromPassword('XXX'); $_SERVER['HTTP_HOST'] = 'http://localhost'; $results = $controller->go(); $this->assertPattern("/Error: crawler log is not writable/", $results); }
public function testIsAPICall() { $builders = $this->buildData(); $controller = new TestAuthAPIController(true); // API call (JSON) $_GET['un'] = '*****@*****.**'; $_GET['as'] = Session::getAPISecretFromPassword('XXX'); $results = $controller->go(); $this->assertPattern('/{"result":"success"}/', $results); $this->assertFalse(strpos($results, '<html')); unset($_GET['as']); unset($_GET['un']); // HTML $this->simulateLogin('*****@*****.**'); $results = $controller->go(); $this->assertFalse(strpos($results, '{"result":"success"}')); $this->assertPattern('/<html/', $results); }
public function testGetAPISecretFromPassword() { $this->assertEqual(Session::getAPISecretFromPassword('XXX'), '1829cc1b13f920a05fb201e8d2a9e4dc58b669b1'); $this->assertEqual(Session::getAPISecretFromPassword('abcdefghijklmnopqrstuvwxyz1234567890,.�;��^=-/\'�":邬+_)(*&?%$#@\\'), '450f86da4df70ba8957cb230c01c0f6c1347e19c'); }