sugar_config_old = $GLOBALS['sugar_config']; $_REQUEST['user_name'] = 'foo'; $_REQUEST['user_password'] = 'bar'; $_SESSION['authenticated_user_id'] = true; $_SESSION['hasExpiredPassword'] = false; $_SESSION['isMobile'] = null; $GLOBALS['sugar_config']['authenticationClass'] = 'SAMLAuthenticate'; //$this->useOutputBuffering = false; } public function tearDown() { unset($GLOBALS['current_user']); $GLOBALS['sugar_config'] = $this->sugar_config_old; unset($_REQUEST['login_module']); unset($_REQUEST['login_action']); unset($_REQUEST['login_record']); unset($_REQUEST['user_name']); unset($_REQUEST['user_password']); unset($_SESSION['authenticated_user_id']); unset($_SESSION['hasExpiredPassword']); unset($_SESSION['isMobile']); } public function testDefaultUserNamePasswordNotSet() { unset($GLOBALS['sugar_config']['default_module']); unset($GLOBALS['sugar_config']['default_action']); $_REQUEST['action'] = 'Authenticate'; $_REQUEST['login_module'] = 'foo'; $_REQUEST['login_action'] = 'bar'; $_REQUEST['login_record'] = '123'; unset($_REQUEST['user_name']); unset($_REQUEST['user_password']); $authController = new AuthenticationController((!empty($GLOBALS['sugar_config']['authenticationClass'])? $GLOBALS['sugar_config']['authenticationClass'] : 'SugarAuthenticate')); $url = ''; require('modules/Users/Authenticate.php'); $this->assertEquals( 'Location: index.php?module=foo&action=bar&record=123', $url ); $this->assertTrue(!empty($_REQUEST['user_name']), 'Assert that we automatically set a user_name in $_REQUEST'); $this->assertEquals('onelogin', $_REQUEST['user_name']); $this->assertTrue(!empty($_REQUEST['user_password']), 'Assert that we automatically set a user_password in $_REQUEST'); $this->assertEquals('onelogin', $_REQUEST['user_password']); } public function testDefaultUserNamePasswordSet() { unset($GLOBALS['sugar_config']['default_module']); unset($GLOBALS['sugar_config']['default_action']); $_REQUEST['action'] = 'Authenticate'; $_REQUEST['login_module'] = 'foo'; $_REQUEST['login_action'] = 'bar'; $_REQUEST['login_record'] = '123'; $authController = new AuthenticationController((!empty($GLOBALS['sugar_config']['authenticationClass'])? $GLOBALS['sugar_config']['authenticationClass'] : 'SugarAuthenticate')); $url = ''; require('modules/Users/Authenticate.php'); $this->assertEquals( 'Location: index.php?module=foo&action=bar&record=123', $url ); $this->assertTrue(!empty($_REQUEST['user_name']), 'Assert that we automatically set a user_name in $_REQUEST'); $this->assertEquals('foo', $_REQUEST['user_name']); $this->assertTrue(!empty($_REQUEST['user_password']), 'Assert that we automatically set a user_password in $_REQUEST'); $this->assertEquals('bar', $_REQUEST['user_password']); } } ?>