public function testExecute() { $uid = 17001; $name = 'superapp5372'; $oldApiKey = 'test_case_key-81753'; $oldSecret = 'nnn283f238h'; $appProps = array(); $keyService = Api_ServiceFactory::create('KeyService'); $domainService = Api_ServiceFactory::create('DomainService'); $localDomainId = $domainService->getNativeIdByName('Ringside'); $ids = $keyService->getKeyset($localDomainId, $localDomainId); $domainKey = $ids['api_key']; $this->assertNotNull($domainKey); $appService = Api_ServiceFactory::create('AppService'); $appId = $appService->createApp($name, $oldApiKey, $oldSecret, $appProps); Api_Dao_App::setAppOwner($uid, $appId); $params = array('app_api_key' => $oldApiKey); $newApiKey = '237825y235nn'; $newSecret = '328752hannafds'; $kprops = array(); $kprops[] = array('network_id' => $domainKey, 'api_key' => $newApiKey, 'secret' => $newSecret); $params = array('app_id' => $appId, 'keys' => json_encode($kprops)); $api = $this->initRest(new AdminSetAppKeys(), $params, $uid, $appId); $this->assertTrue($api->execute()); $params = array('app_api_key' => $newApiKey); $api = $this->initRest(new AdminGetAppKeys(), $params, $uid, $appId); $resp = $api->execute(); $this->assertEquals(1, count($resp['resp'])); $this->assertEquals($newApiKey, $resp['resp'][0]['api_key']); $this->assertEquals($newSecret, $resp['resp'][0]['secret']); $appService->deleteApp($appId); Api_Dao_App::removeAppOwner($uid, $appId); }
public function execute() { if (!Api_Dao_App::checkUserOwnsApp($this->getUserId(), $this->m_appId)) { throw new Exception('Cannot query for app keys, user does not own app.'); } $domainService = Api_ServiceFactory::create('DomainService'); $keyService = Api_ServiceFactory::create('KeyService'); foreach ($this->m_keys as $keyset) { $domainKey = $keyset['network_id']; $domainId = $domainService->getNativeIdByApiKey($domainKey); $newApiKey = $keyset['api_key']; $newSecret = $keyset['secret']; $keyService->updateKeyset($this->m_appId, $domainId, $newApiKey, $newSecret); } return true; }
public function testExecute() { $uid = 17001; $name = 'superapp5372'; $apiKey = 'test_case_key-81753'; $secret = 'nnn283f238h'; $appProps = array(); $appService = Api_ServiceFactory::create('AppService'); $appId = $appService->createApp($name, $apiKey, $secret, $appProps); Api_Dao_App::setAppOwner($uid, $appId); $params = array('app_api_key' => $apiKey); $api = $this->initRest(new AdminGetAppKeys(), $params, $uid, $appId); $resp = $api->execute(); $this->assertEquals(1, count($resp['resp'])); $this->assertEquals($apiKey, $resp['resp'][0]['api_key']); $this->assertEquals($secret, $resp['resp'][0]['secret']); $appService->deleteApp($appId); Api_Dao_App::removeAppOwner($uid, $appId); }
public static function getApp2() { static $app; if (!isset($app)) { $apiKey = "1001"; $callbackUrl = "dbUrl 2"; $canvasUrl = "canUrl 2"; $default = 0; $name = "app name 2"; $secretKey = "secKey 2"; $sidenavUrl = "sideUrl 2"; $app = Api_Dao_App::createApp($apiKey, $callbackUrl, $canvasUrl, $name, $default, $secretKey, $sidenavUrl, null, null); } return $app; }
public function getFbmlForAppName($appName) { // FIXME: This layer should not be able to access the dao directly $appInfo = Api_Dao_App::getApplicationInfoByName($appName, $this->database); $app_id = $appInfo['id']; return $this->getFbmlForApp($app_id, $this->uid); }
/** * Enter description here... * * @param unknown_type $api_key * @param unknown_type $uid * @param unknown_type $ext_perm * @return unknown */ public static function checkUserHasPermission($api_key, $uid, $ext_perm, $network_id) { $q = Doctrine_Query::create(); if ($ext_perm == "status_update") { $q->select('allows_status_update'); } else { if ($ext_perm == "photo_upload") { $q->select('allows_photo_upload'); } else { if ($ext_perm == "create_listing") { $q->select('allows_create_listing'); } else { throw new OpenFBAPIException("No such permission.", FB_ERROR_CODE_PARAMETER_MISSING); } } } $aid = Api_Dao_App::getAppIdByApiKey($api_key, $network_id); $q->from('RingsideUsersApp ua'); $q->where("ua.app_id={$aid} AND ua.user_id = {$uid}"); $perm = $q->execute(); if (count($perm) > 0) { $ret = 0; if ($ext_perm == "status_update") { $ret = $perm[0]->allows_status_update; } else { if ($ext_perm == "photo_upload") { $ret = $perm[0]->allows_photo_upload; } else { if ($ext_perm == "create_listing") { $ret = $perm[0]->allows_create_listing; } } } if (intval($ret) > 0) { return true; } } return false; }
function checkHasData() { try { $dbCon = RingsideApiDbDatabase::getDatabaseConnection(); if ($dbCon === false) { return false; } $data = Api_Dao_App::getApplicationInfoByApiKey(RingsideWebConfig::$networkKey, RingsideSocialConfig::$apiKey, $dbCon); if ($data !== false) { return true; } else { return false; } } catch (Exception $exception) { return false; } }
/** * @dataProvider testGetInfoByCanvasNameProvider */ public function testGetInfoByCanvasName($name, $expected) { $info = Api_Dao_App::getApplicationInfoByCanvasName($name, RingsideSocialConfig::$apiKey); $apps = $info[0]->toArray(); foreach ($expected as $name => $val) { $this->assertEquals($val, $apps[$name]); } }
private function deleteUserAndApp($id, $app) { try { Api_Dao_UsersApp::deleteUserApp($id); } catch (Exception $exception) { // nothing on purpose } try { Api_Dao_App::deleteApp($app); } catch (Exception $exception) { // nothing on purpose } }
public function updateApp($appId, $newProps) { $props = array(); foreach ($newProps as $pname => $pval) { $propName = $pname; if (strpos($pname, '.') === false) { $fullName = "RingsideApp.{$pname}"; } else { $fullName = $pname; $tarr = explode('.', $pname); $propName = $tarr[1]; } if (!array_key_exists($propName, self::$defaultProperties)) { throw new Exception("[AppServiceImpl] unknown property '{$pname}'."); } $props[$fullName] = $pval; } Api_Dao_App::updateAppProperties($appId, $props, null); }
/** * Enter description here... * * @param unknown_type $name * @return unknown */ public static function getAppIdByName($name) { return Api_Dao_App::getAppIdByName($name); }