public function testAuthControlLoggedInChangePasswordNewPwdTooShort()
 {
     $this->simulateLogin('*****@*****.**');
     $_POST['changepass'] = '******';
     $_POST['oldpass'] = '******';
     $_POST['pass1'] = 'new1';
     $_POST['pass2'] = 'new1';
     $controller = new AccountConfigurationController(true);
     $results = $controller->go();
     //test if view variables were set correctly
     $v_mgr = $controller->getViewManager();
     $this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
     $this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 6);
     $owner = $v_mgr->getTemplateDataItem('owner');
     $this->assertIsA($owner, 'Owner');
     $this->assertTrue(!$owner->is_admin);
     $this->assertEqual($owner->full_name, 'ThinkUp J. User');
     $this->assertEqual($owner->email, '*****@*****.**');
     $this->assertEqual($v_mgr->getTemplateDataItem('errormsg'), 'New password must be at least 5 characters. Your password has not been changed.');
     //not set: owners, body, successmsg, errormsg
     $this->assertTrue(!$v_mgr->getTemplateDataItem('owners'));
     $this->assertTrue(!$v_mgr->getTemplateDataItem('body'));
     $this->assertTrue(!$v_mgr->getTemplateDataItem('successmsg'));
 }
 public function testResetAPIKey()
 {
     $this->simulateLogin('*****@*****.**', false, true);
     $_POST['reset_api_key'] = 'Reset API Key';
     $_GET['csrf_token'] = parent::CSRF_TOKEN;
     $controller = new AccountConfigurationController(true);
     $results = $controller->go();
     //test if view variables were set correctly
     $v_mgr = $controller->getViewManager();
     $this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
     $this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 7);
     $owner = $v_mgr->getTemplateDataItem('owner');
     $this->assertIsA($owner, 'Owner');
     $this->assertTrue(!$owner->is_admin);
     $this->assertEqual($owner->full_name, 'ThinkUp J. User');
     $this->assertEqual($owner->email, '*****@*****.**');
     $success_msgs = $v_mgr->getTemplateDataItem('success_msgs');
     $this->assertEqual($success_msgs['api_key'], 'Your API Key has been reset! Please update your ThinkUp RSS feed subscription.');
     // Has API Key actually changed
     $this->assertNotEqual('c9089f3c9adaf0186f6ffb1ee8d6501c', $owner->api_key);
     //not set: owners, body, success_msg, error_msg
     $this->assertTrue(!$v_mgr->getTemplateDataItem('owners'));
     $this->assertTrue(!$v_mgr->getTemplateDataItem('body'));
     $this->assertTrue(!$v_mgr->getTemplateDataItem('error_msg'));
 }
 public function testPluginShownWhenPSet()
 {
     $this->simulateLogin('*****@*****.**', true, true);
     $_GET['p'] = "twitter";
     $controller = new AccountConfigurationController(true);
     $controller->go();
     $v_mgr = $controller->getViewManager();
     $this->assertTrue($v_mgr->getTemplateDataItem('force_plugin'));
     $_GET = array();
     $controller = new AccountConfigurationController(true);
     $controller->go();
     $v_mgr = $controller->getViewManager();
     $this->assertNull($v_mgr->getTemplateDataItem('force_plugin'));
 }
 public function testAuthControlInviteUser()
 {
     $this->simulateLogin('*****@*****.**', false, true);
     $_SERVER['HTTP_HOST'] = "mytestthinkup/";
     $_SERVER['HTTPS'] = null;
     $_POST['invite'] = 'Create Invitation';
     $_POST['csrf_token'] = parent::CSRF_TOKEN;
     $controller = new AccountConfigurationController(true);
     $results = $controller->go();
     $v_mgr = $controller->getViewManager();
     $msgs_array = $v_mgr->getTemplateDataItem('success_msgs');
     $this->assertPattern('/Invitation created!/', $msgs_array['invite']);
     $this->assertPattern('/http:\\/\\/mytestthinkup\\/tests\\/session\\/register.php\\?code=/', $msgs_array['invite']);
     //test HTTPS
     $_SERVER['HTTPS'] = 1;
     $_SERVER['HTTP_HOST'] = "myotherwtestthinkup/";
     $_POST['invite'] = 'Create Invitation';
     $controller = new AccountConfigurationController(true);
     $results = $controller->go();
     $v_mgr = $controller->getViewManager();
     $msgs_array = $v_mgr->getTemplateDataItem('success_msgs');
     $this->assertPattern('/Invitation created!/', $msgs_array['invite']);
     $this->assertPattern('/https:\\/\\/myotherwtestthinkup\\/tests\\/session\\/register.php\\?code=/', $msgs_array['invite']);
 }