public function doGetCallback(Application $app, Request $request, $api_name) { $error_message = ''; try { $api = \Bridge_Api::get_by_api_name($app, $api_name); $connector = $api->get_connector(); $response = $connector->connect(); $user_id = $connector->get_user_id(); try { $account = \Bridge_Account::load_account_from_distant_id($app, $api, $app['authentication']->getUser(), $user_id); } catch (\Bridge_Exception_AccountNotFound $e) { $account = \Bridge_Account::create($app, $api, $app['authentication']->getUser(), $user_id, $connector->get_user_name()); } $settings = $account->get_settings(); if (isset($response['auth_token'])) { $settings->set('auth_token', $response['auth_token']); } if (isset($response['refresh_token'])) { $settings->set('refresh_token', $response['refresh_token']); } $connector->set_auth_settings($settings); $connector->reconnect(); } catch (\Exception $e) { $error_message = $e->getMessage(); } $params = ['error_message' => $error_message]; return $app['twig']->render('prod/actions/Bridge/callback.html.twig', $params); }
public function bootTestCase() { $application = self::$DI['app']; try { self::$api = Bridge_Api::get_by_api_name($application, 'apitest'); } catch (Bridge_Exception_ApiNotFound $e) { self::$api = Bridge_Api::create($application, 'apitest'); } try { self::$account = Bridge_Account::load_account_from_distant_id($application, self::$api, self::$DI['user'], 'kirikoo'); } catch (Bridge_Exception_AccountNotFound $e) { self::$account = Bridge_Account::create($application, self::$api, self::$DI['user'], 'kirikoo', 'coucou'); } }
public function bootTestCase() { self::$DI['user']; if (!self::$object) { $sql = 'DELETE FROM bridge_apis WHERE name = "Apitest"'; $stmt = self::$DI['app']['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute(); $stmt->closeCursor(); self::$api = Bridge_Api::create(self::$DI['app'], 'Apitest'); self::$dist_id = 'EZ1565loPP'; self::$named = 'Fête à pinpins'; $account = Bridge_Account::create(self::$DI['app'], self::$api, self::$DI['user'], self::$dist_id, self::$named); self::$id = $account->get_id(); self::$object = new Bridge_Account(self::$DI['app'], self::$api, self::$id); } }
public function setUp() { parent::setUp(); try { $sql = 'DELETE FROM bridge_apis WHERE name = "Apitest"'; $stmt = self::$DI['app']['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute(); $stmt->closeCursor(); $this->api = Bridge_Api::create(self::$DI['app'], 'Apitest'); $this->dist_id = 'EZ1565loPP'; $this->named = 'Fête à pinpins'; $this->account = Bridge_Account::create(self::$DI['app'], $this->api, self::$DI['user'], $this->dist_id, $this->named); $this->object = new Bridge_AccountSettings(self::$DI['app']['phraseanet.appbox'], $this->account); } catch (Exception $e) { $this->fail($e->getMessage()); } }
public function setUp() { parent::setUp(); $sql = 'DELETE FROM bridge_apis WHERE name = "Apitest"'; $stmt = self::$DI['app']->getApplicationBox()->get_connection()->prepare($sql); $stmt->execute(); $stmt->closeCursor(); $this->api = Bridge_Api::create(self::$DI['app'], 'Apitest'); $this->dist_id = 'EZ1565loPP'; $this->named = 'Fête à pinpins'; $this->account = Bridge_Account::create(self::$DI['app'], $this->api, self::$DI['user'], $this->dist_id, $this->named); $this->title = 'GOGACKO'; $this->status = 'Processing'; $element = Bridge_Element::create(self::$DI['app'], $this->account, self::$DI['record_1'], $this->title, $this->status, $this->account->get_api()->get_connector()->get_default_element_type()); $this->id = $element->get_id(); $this->object = new Bridge_Element(self::$DI['app'], $this->account, $this->id); }
public function setUp() { parent::setUp(); $this->auth = $this->getMock("Bridge_Api_Auth_Interface"); $this->bridgeApi = $this->getMock('Bridge_Api_Abstract', ["is_configured", "initialize_transport", "set_auth_params", "set_transport_authentication_params"], [self::$DI['app']['url_generator'], self::$DI['app']['conf'], $this->auth, self::$DI['app']['translator']]); if (!self::$api) { $application = $this->getApplication(); try { self::$api = Bridge_Api::get_by_api_name($application, 'apitest'); } catch (Bridge_Exception_ApiNotFound $e) { self::$api = Bridge_Api::create($application, 'apitest'); } try { self::$account = Bridge_Account::load_account_from_distant_id($application, self::$api, self::$DI['user'], 'kirikoo'); } catch (Bridge_Exception_AccountNotFound $e) { self::$account = Bridge_Account::create($application, self::$api, self::$DI['user'], 'kirikoo', 'coucou'); } } }
public function testDeleteAccount() { $account = \Bridge_Account::create(self::$DI['app'], self::$api, self::$DI['app']['authentication']->getUser(), 'hello', 'you'); $url = "/prod/bridge/adapter/" . $account->get_id() . "/delete/"; self::$DI['client']->request('POST', $url); $response = self::$DI['client']->getResponse(); $this->assertTrue($response->isOk()); $datas = json_decode($response->getContent(), true); $this->assertArrayHasKey('success', $datas); $this->assertTrue($datas['success']); try { \Bridge_Account::load_account(self::$DI['app'], $account->get_id()); $this->fail('Account is not deleted'); } catch (\Bridge_Exception_AccountNotFound $e) { } unset($account, $response); }