예제 #1
0
 public function renderConfiguration($owner)
 {
     $controller = new TwitterPluginConfigurationController($owner, 'twitter');
     return $controller->go();
 }
 public function testConfigOptionsMissingRequiredValues()
 {
     $_SERVER['SERVER_NAME'] = 'mytestthinkup';
     $this->simulateLogin('*****@*****.**', true);
     $owner_dao = DAOFactory::getDAO('OwnerDAO');
     $owner = $owner_dao->getByEmail(Session::getLoggedInUser());
     $controller = new TwitterPluginConfigurationController($owner, 'twitter');
     $output = $controller->go();
     // we have a text form element with proper data
     $this->assertPattern('/save options/', $output);
     // should have no submit option
     $this->assertPattern('/plugin_options_oauth_consumer_secret/', $output);
     // should have secret option
     $this->assertPattern('/plugin_options_archive_limit/', $output);
     // should have limit option
     $this->assertPattern('/plugin_options_oauth_consumer_key/', $output);
     // should have key option
     $this->assertPattern('/var is_admin = true/', $output);
     // is a js admin
     //app not configured
     $this->assertPattern('/var required_values_set = false/', $output);
     // is not configured
     //not SSL by default
     $this->assertNoPattern('/https:\\/\\/mytestthinkup/', $output);
 }
 public function testLocalhostOAuthCallbackLink()
 {
     require THINKUP_WEBAPP_PATH . 'config.inc.php';
     $_SERVER['SERVER_NAME'] = 'localhost';
     $options_array = $this->buildPluginOptions();
     $controller = new TwitterPluginConfigurationController(null, 'twitter');
     $config = Config::getInstance();
     //From logged in
     $this->simulateLogin('*****@*****.**');
     $owner_dao = DAOFactory::getDAO('OwnerDAO');
     $owner = $owner_dao->getByEmail(Session::getLoggedInUser());
     $controller = new TwitterPluginConfigurationController($owner, 'twitter');
     $output = $controller->go();
     $v_mgr = $controller->getViewManager();
     //Check if a URL was passed
     $auth_link = $v_mgr->getTemplateDataItem('oauthorize_link');
     $this->assertEqual("test_auth_URL_" . urlencode("http://127.0.0.1" . $THINKUP_CFG['site_root_path'] . "plugins/twitter/auth.php"), $auth_link);
 }
 public function testOwnerProLevelWith9AccountsConnected()
 {
     // build options data
     $options_array = $this->buildPluginOptions();
     //Add 9 connected Twitter accounts
     $i = 9;
     while ($i > 0) {
         $builders[] = FixtureBuilder::build('instances', array('id' => 1 + $i, 'network_user_id' => 14, 'network_username' => 'biz', 'is_public' => 1, 'network' => 'twitter'));
         $builders[] = FixtureBuilder::build('owner_instances', array('owner_id' => 1, 'instance_id' => 1 + $i));
         $i--;
     }
     $config = Config::getInstance();
     $config->setValue('thinkupllc_endpoint', 'http://example.com/user/');
     $this->simulateLogin('*****@*****.**');
     $owner_dao = DAOFactory::getDAO('OwnerDAO');
     $owner = $owner_dao->getByEmail(Session::getLoggedInUser());
     //Set membership_level to Member
     $owner->membership_level = "Pro";
     $controller = new TwitterPluginConfigurationController($owner, 'twitter');
     $output = $controller->go();
     $this->debug($output);
     // Assert that the Add User button isn't there
     $this->assertNoPattern('/Add a Twitter Account/', $output);
     // Assert that the message about the membership cap is there
     $this->assertPattern('/you’ve connected 10 of 10 accounts to ThinkUp./', $output);
 }
    /**
     * Test config isa admin
     */
    public function testConfigOptionsIsAdmin() {

        // build some options data
        $options_arry = $this->buildPluginOptions();
        $this->simulateLogin('*****@*****.**', true);
        $owner_dao = DAOFactory::getDAO('OwnerDAO');
        $owner = $owner_dao->getByEmail(Session::getLoggedInUser());
        $controller = new TwitterPluginConfigurationController($owner, 'twitter');
        $output = $controller->go();
        // we have a text form element with proper data
        $this->assertPattern('/save options/', $output); // should have no submit option
        $this->assertPattern('/plugin_options_oauth_consumer_secret/', $output); // should have secret option
        $this->assertPattern('/plugin_options_archive_limit/', $output); // should have limit option
        $this->assertPattern('/plugin_options_oauth_consumer_key/', $output); // should have key option
        $this->assertPattern('/var is_admin = true/', $output); // is a js admin

        //app not configured
        $controller = new FacebookPluginConfigurationController($owner, 'facebook');
        $output = $controller->go();
        $this->assertPattern('/var required_values_set = false/', $output); // is not configured
    }
 /**
  * Test csrf token
  */
 public function testForDeleteCSRFToken()
 {
     $_SERVER['SERVER_NAME'] = 'mytestthinkup';
     // build some options data
     $options_arry = $this->buildPluginOptions();
     $this->simulateLogin('*****@*****.**', true, true);
     $owner_dao = DAOFactory::getDAO('OwnerDAO');
     $owner = $owner_dao->getByEmail(Session::getLoggedInUser());
     $controller = new TwitterPluginConfigurationController($owner, 'twitter');
     $output = $controller->go();
     $this->assertPattern('/name="csrf_token" value="' . self::CSRF_TOKEN . '"/', $output);
 }
 public function testLoggedInAuthorizeExistingUserAllParams()
 {
     $this->simulateLogin('*****@*****.**');
     $_GET['oauth_token'] = 'XXX';
     $_GET['oauth_verifier'] = 'YYY';
     SessionCache::put('oauth_request_token_secret', 'XXX');
     $namespace = OptionDAO::PLUGIN_OPTIONS . '-1';
     $builders[] = FixtureBuilder::build('options', array('namespace' => $namespace, 'option_name' => 'oauth_consumer_key', 'option_value' => 'XXX'));
     $builders[] = FixtureBuilder::build('options', array('namespace' => $namespace, 'option_name' => 'oauth_consumer_secret', 'option_value' => 'YYY'));
     $builders[] = FixtureBuilder::build('options', array('namespace' => $namespace, 'option_name' => 'num_twitter_errors', 'option_value' => '5'));
     $builders[] = FixtureBuilder::build('instances_twitter', array('last_reply_id' => '1'));
     $builders[] = FixtureBuilder::build('instances', array('id' => 2, 'network_user_id' => '930061', 'network_username' => 'ginatrapani', 'is_public' => 1));
     //Add instance_owner
     $builders[] = FixtureBuilder::build('owner_instances', array('owner_id' => 1, 'instance_id' => 2));
     $controller = new TwitterPluginConfigurationController(null, 'twitter');
     $results = $controller->go();
     $v_mgr = $controller->getViewManager();
     $this->debug($results);
     $msgs = $v_mgr->getTemplateDataItem('success_msgs');
     $this->assertEqual('ginatrapani on Twitter is already set up in ThinkUp! To add a different Twitter account, ' . 'log out of Twitter.com in your browser and authorize ThinkUp again.', $msgs['user_add']);
     $this->assertEqual('', $v_mgr->getTemplateDataItem('error_msg'));
 }
 /**
  * Test user submission
  */
 public function testAddTwitterUserNoTwitterAuth()
 {
     // build some options data
     $options_arry = $this->buildPluginOptions();
     $this->simulateLogin('*****@*****.**');
     $owner_dao = DAOFactory::getDAO('OwnerDAO');
     $owner = $owner_dao->getByEmail(Session::getLoggedInUser());
     $controller = new TwitterPluginConfigurationController($owner, 'twitter');
     $_GET["twitter_username"] = "******";
     $_GET["p"] = "twitter";
     $output = $controller->go();
     $v_mgr = $controller->getViewManager();
     $this->assertEqual($v_mgr->getTemplateDataItem('successmsg'), "Added anildash to ThinkUp.");
     $this->assertIsA($v_mgr->getTemplateDataItem('owner_instances'), 'array', 'Owner instances set');
     $this->assertTrue($v_mgr->getTemplateDataItem('oauthorize_link') != '', 'Authorization link set');
 }
 /**
  * Test user submission
  */
 public function testAddTwitterUserNoTwitterAuth()
 {
     $_SESSION['user'] = '******';
     $owner_dao = DAOFactory::getDAO('OwnerDAO');
     $owner = $owner_dao->getByEmail($_SESSION['user']);
     $controller = new TwitterPluginConfigurationController($owner);
     $_GET["twitter_username"] = "******";
     $_GET["p"] = "twitter";
     $output = $controller->go();
     $v_mgr = $controller->getViewManager();
     $this->assertEqual($v_mgr->getTemplateDataItem('successmsg'), "Added anildash to ThinkTank.");
     $this->assertIsA($v_mgr->getTemplateDataItem('owner_instances'), 'array', 'Owner instances set');
     $this->assertTrue($v_mgr->getTemplateDataItem('oauthorize_link') != '', 'Authorization link set');
 }