<commit_before><?php
/**
 * SecurityComponentTest file
 *
 * PHP versions 4 and 5
 *
 * CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
 * Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 *  Licensed under The Open Group Test Suite License
 *  Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
 * @package       cake
 * @subpackage    cake.tests.cases.libs.controller.components
 * @since         CakePHP(tm) v 1.2.0.5435
 * @license       http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
 */
App::import('Component', 'Security');

/**
* TestSecurityComponent
*
* @package       cake
* @subpackage    cake.tests.cases.libs.controller.components
*/
class TestSecurityComponent extends SecurityComponent {

/**
 * validatePost method
 *
 * @param Controller $controller
 * @return unknown
 */
	function validatePost(&$controller) {
		return $this->_validatePost($controller);
	}
}

/**
* SecurityTestController
*
* @package       cake
* @subpackage    cake.tests.cases.libs.controller.components
*/
class SecurityTestController extends Controller {

/**
 * name property
 *
 * @var string 'SecurityTest'
 * @access public
 */
	var $name = 'SecurityTest';

/**
 * components property
 *
 * @var array
 * @access public
 */
	var $components = array('TestSecurity');

/**
 * failed property
 *
 * @var bool false
 * @access public
 */
	var $failed = false;

/**
 * Used for keeping track of headers in test
 *
 * @var array
 * @access public
 */
	var $testHeaders = array();

/**
 * fail method
 *
 * @access public
 * @return void
 */
	function fail() {
		$this->failed = true;
	}

/**
 * redirect method
 *
 * @param mixed $option
 * @param mixed $code
 * @param mixed $exit
 * @access public
 * @return void
 */
	function redirect($option, $code, $exit) {
		return $code;
	}

/**
 * Conveinence method for header()
 *
 * @param string $status
 * @return void
 * @access public
 */
	function header($status) {
		$this->testHeaders[] = $status;
	}
}

/**
 * SecurityComponentTest class
 *
 * @package       cake
 * @subpackage    cake.tests.cases.libs.controller.components
 */
class SecurityComponentTest extends CakeTestCase {

/**
 * Controller property
 *
 * @var SecurityTestController
 * @access public
 */
	var $Controller;

/**
 * oldSalt property
 *
 * @var string
 * @access public
 */
	var $oldSalt;

/**
 * setUp method
 *
 * @access public
 * @return void
 */
	function setUp() {
		$this->Controller =& new SecurityTestController();
		$this->Controller->Component->init($this->Controller);
		$this->Controller->Security =& $this->Controller->TestSecurity;
		$this->Controller->Security->blackHoleCallback = 'fail';
		$this->oldSalt = Configure::read('Security.salt');
		Configure::write('Security.salt', 'foo!');
	}

/**
 * Tear-down method. Resets environment state.
 *
 * @access public
 * @return void
 */
	function tearDown() {
		Configure::write('Security.salt', $this->oldSalt);
		$this->Controller->Session->delete('_Token');
		unset($this->Controller->Security);
		unset($this->Controller->Component);
		unset($this->Controller);
	}

/**
 * testStartup method
 *
 * @access public
 * @return void
 */
	function testStartup() {
		$this->Controller->Security->startup($this->Controller);
		$result = $this->Controller->params['_Token']['key'];
		$this->assertNotNull($result);
		$this->assertTrue($this->Controller->Session->check('_Token'));
	}

/**<commit_msg>Updating security component test case to use startTest and endTest<commit_after><?php
/**
 * SecurityComponentTest file
 *
 * PHP versions 4 and 5
 *
 * CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
 * Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 *  Licensed under The Open Group Test Suite License
 *  Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
 * @package       cake
 * @subpackage    cake.tests.cases.libs.controller.components
 * @since         CakePHP(tm) v 1.2.0.5435
 * @license       http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
 */
App::import('Component', 'Security');

/**
* TestSecurityComponent
*
* @package       cake
* @subpackage    cake.tests.cases.libs.controller.components
*/
class TestSecurityComponent extends SecurityComponent {

/**
 * validatePost method
 *
 * @param Controller $controller
 * @return unknown
 */
	function validatePost(&$controller) {
		return $this->_validatePost($controller);
	}
}

/**
* SecurityTestController
*
* @package       cake
* @subpackage    cake.tests.cases.libs.controller.components
*/
class SecurityTestController extends Controller {

/**
 * name property
 *
 * @var string 'SecurityTest'
 * @access public
 */
	var $name = 'SecurityTest';

/**
 * components property
 *
 * @var array
 * @access public
 */
	var $components = array('TestSecurity');

/**
 * failed property
 *
 * @var bool false
 * @access public
 */
	var $failed = false;

/**
 * Used for keeping track of headers in test
 *
 * @var array
 * @access public
 */
	var $testHeaders = array();

/**
 * fail method
 *
 * @access public
 * @return void
 */
	function fail() {
		$this->failed = true;
	}

/**
 * redirect method
 *
 * @param mixed $option
 * @param mixed $code
 * @param mixed $exit
 * @access public
 * @return void
 */
	function redirect($option, $code, $exit) {
		return $code;
	}

/**
 * Conveinence method for header()
 *
 * @param string $status
 * @return void
 * @access public
 */
	function header($status) {
		$this->testHeaders[] = $status;
	}
}

/**
 * SecurityComponentTest class
 *
 * @package       cake
 * @subpackage    cake.tests.cases.libs.controller.components
 */
class SecurityComponentTest extends CakeTestCase {

/**
 * Controller property
 *
 * @var SecurityTestController
 * @access public
 */
	var $Controller;

/**
 * oldSalt property
 *
 * @var string
 * @access public
 */
	var $oldSalt;

/**
 * setUp method
 *
 * @access public
 * @return void
 */
	function startTest() {
		$this->Controller =& new SecurityTestController();
		$this->Controller->Component->init($this->Controller);
		$this->Controller->Security =& $this->Controller->TestSecurity;
		$this->Controller->Security->blackHoleCallback = 'fail';
		$this->oldSalt = Configure::read('Security.salt');
		Configure::write('Security.salt', 'foo!');
	}

/**
 * Tear-down method. Resets environment state.
 *
 * @access public
 * @return void
 */
	function endTest() {
		Configure::write('Security.salt', $this->oldSalt);
		$this->Controller->Session->delete('_Token');
		unset($this->Controller->Security);
		unset($this->Controller->Component);
		unset($this->Controller);
	}

/**
 * testStartup method
 *
 * @access public
 * @return void
 */
	function testStartup() {
		$this->Controller->Security->startup($this->Controller);
		$result = $this->Controller->params['_Token']['key'];
		$this->assertNotNull($result);
		$this->assertTrue($this->Controller->Session->check('_Token'));
	}

/**
{'fraction_non_alphanumeric': 0.15442764578833693, 'fraction_numerical': 0.006749460043196544, 'mean_word_length': 3.773840206185567, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 77, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1790532', 'n_tokens_mistral': 2345, 'n_tokens_neox': 2220, 'n_words': 529}