Beispiel #1
0
/**
 *
 * ThinkUp/webapp/account/index.php
 *
 * Copyright (c) 2009-2015 Gina Trapani
 *
 * LICENSE:
 *
 * This file is part of ThinkUp (http://thinkup.com).
 *
 * ThinkUp is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any
 * later version.
 *
 * ThinkUp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with ThinkUp.  If not, see
 * <http://www.gnu.org/licenses/>.
 *
 *
 * @author Gina Trapani <ginatrapani[at]gmail[dot]com>
 * @license http://www.gnu.org/licenses/gpl.html
 * @copyright 2009-2015 Gina Trapani
 */
chdir("..");
require_once 'init.php';
$controller = new AccountConfigurationController();
echo $controller->go();
 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 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 testLoadProperRSSUrlWithPlusSignInEmailAddress()
 {
     $builder = $this->buildRSSData();
     $this->simulateLogin('*****@*****.**', true, true);
     $controller = new AccountConfigurationController(true);
     $this->assertTrue(isset($controller));
     $result = $controller->control();
     $this->debug($result);
     $this->assertPattern('/crawler\\/rss.php\\?un=me153\\%2Bcheckurlencoding%40example.com&as=c9089f3c9adaf0186f6ffb1ee8d6501c/', $result);
 }
 public function testResetAPIKeyBadCSRFToken()
 {
     $this->simulateLogin('*****@*****.**', false, true);
     $_POST['reset_api_key'] = 'Reset API Key';
     $_GET['csrf_token'] = parent::CSRF_TOKEN . 'lalla';
     $controller = new AccountConfigurationController(true);
     $results = $controller->go();
     try {
         $results = $controller->control();
         $this->fail("should throw InvalidCSRFTokenException");
     } catch (InvalidCSRFTokenException $e) {
         $this->assertIsA($e, 'InvalidCSRFTokenException');
     }
 }
 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']);
 }