mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-11 04:52:14 +09:00
동작하지 않던 Unit test 코드 복원
This commit is contained in:
parent
3e58d680d8
commit
0d24de74d3
7 changed files with 141 additions and 123 deletions
|
|
@ -1,3 +1,26 @@
|
||||||
<?php
|
<?php
|
||||||
// This is global bootstrap for autoloading
|
// This is global bootstrap for autoloading
|
||||||
|
if(!defined('__XE__')) define('__XE__', true);
|
||||||
if(!defined('_XE_PATH_')) define('_XE_PATH_', realpath(dirname(__FILE__).'/../').'/');
|
if(!defined('_XE_PATH_')) define('_XE_PATH_', realpath(dirname(__FILE__).'/../').'/');
|
||||||
|
error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_WARNING ^ E_STRICT);
|
||||||
|
|
||||||
|
function _debug() {
|
||||||
|
$args = func_get_args();
|
||||||
|
$bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT, 2);
|
||||||
|
|
||||||
|
if(is_array($bt))
|
||||||
|
{
|
||||||
|
$bt_debug_print = array_shift($bt);
|
||||||
|
$bt_called_function = array_shift($bt);
|
||||||
|
}
|
||||||
|
$file_name = str_replace(_XE_PATH_, '', $bt_debug_print['file']);
|
||||||
|
$line_num = $bt_debug_print['line'];
|
||||||
|
if($bt_called_function) $function = $bt_called_function['class'] . $bt_called_function['type'] . $bt_called_function['function'];
|
||||||
|
|
||||||
|
$print = sprintf("%s() [%s:%d]", $function, $file_name, $line_num);
|
||||||
|
|
||||||
|
codecept_debug("\n" . $print);
|
||||||
|
foreach($args as $arg) {
|
||||||
|
codecept_debug('(' . gettype($arg) . ') ' . var_export($arg, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
require _XE_PATH_.'/config/func.inc.php';
|
|
||||||
|
|
||||||
class FuncIncTest extends \Codeception\TestCase\Test
|
class FuncIncTest extends \Codeception\TestCase\Test
|
||||||
{
|
{
|
||||||
static public function xssProvider()
|
static public function provider()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
// remove iframe
|
// remove iframe
|
||||||
|
|
@ -45,9 +43,9 @@ class FuncIncTest extends \Codeception\TestCase\Test
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider xssProvider
|
* @dataProvider provider
|
||||||
*/
|
*/
|
||||||
public function testXSS($source, $expected)
|
public function testXss($source, $expected)
|
||||||
{
|
{
|
||||||
$result = removeHackTag($source);
|
$result = removeHackTag($source);
|
||||||
$this->assertEquals($result, $expected);
|
$this->assertEquals($result, $expected);
|
||||||
|
|
|
||||||
56
tests/unit/FuncIncTest.php
Normal file
56
tests/unit/FuncIncTest.php
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
require_once( _XE_PATH_.'config/func.inc.php');
|
||||||
|
|
||||||
|
class FuncIncTest extends \Codeception\TestCase\Test
|
||||||
|
{
|
||||||
|
static public function provider()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
// remove iframe
|
||||||
|
array(
|
||||||
|
'<div class="frame"><iframe src="path/to/file.html"></iframe><p><a href="#iframe">IFrame</a></p></div>',
|
||||||
|
// '<div class="frame"><iframe src="path/to/file.html"></iframe><p><a href="#iframe">IFrame</a></p></div>'
|
||||||
|
'<div class="frame"><iframe></iframe><p><a href="#iframe">IFrame</a></p></div>'
|
||||||
|
),
|
||||||
|
// expression
|
||||||
|
array(
|
||||||
|
'<div class="dummy" style="xss:expr/*XSS*/ession(alert(\'XSS\'))">',
|
||||||
|
'<div class="dummy"></div>'
|
||||||
|
),
|
||||||
|
// no quotes and no semicolon - http://ha.ckers.org/xss.html
|
||||||
|
array(
|
||||||
|
'<img src=javascript:alert(\'xss\')>',
|
||||||
|
''
|
||||||
|
),
|
||||||
|
// embedded encoded tab to break up XSS - http://ha.ckers.org/xss.html
|
||||||
|
array(
|
||||||
|
'<IMG SRC="jav	ascript:alert(\'XSS\');">',
|
||||||
|
''
|
||||||
|
),
|
||||||
|
// issue 178
|
||||||
|
array(
|
||||||
|
"<img src=\"invalid.jpg\"\nonerror=\"alert(1)\" />",
|
||||||
|
'<img src="invalid.jpg" alt="invalid.jpg" />'
|
||||||
|
),
|
||||||
|
// issue 534
|
||||||
|
array(
|
||||||
|
'<img src=\'as"df dummy=\'"1234\'" 4321\' asdf/*/>*/" onerror="console.log(\'Yet another XSS\')">',
|
||||||
|
'<img src="as" alt="as"df dummy=" />*/" onerror="console.log(\'Yet another XSS\')">'
|
||||||
|
),
|
||||||
|
// issue 602
|
||||||
|
array(
|
||||||
|
'<img alt="test" src="(http://static.naver.com/www/u/2010/0611/nmms_215646753.gif" onload="eval(String.fromCharCode(105,61,49,48,48,59,119,104,105,108,101, 40,105,62,48,41,97,108,101,114,116,40,40,105,45,45,41,43,39,48264,47564,32, 45908,32,53364,47533,54616,49464,50836,39,41,59));">',
|
||||||
|
''
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider provider
|
||||||
|
*/
|
||||||
|
public function testXss($source, $expected)
|
||||||
|
{
|
||||||
|
$result = removeHackTag($source);
|
||||||
|
$this->assertEquals($result, $expected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<?php //[STAMP] 82bc9161e8772dbad0b5d616567eaa2d
|
<?php //[STAMP] cb6a361b59627f91b689bd53cd926484
|
||||||
|
|
||||||
// This class was automatically generated by build task
|
// This class was automatically generated by build task
|
||||||
// You should not change it manually as it will be overwritten on next build
|
// You should not change it manually as it will be overwritten on next build
|
||||||
|
|
@ -19,9 +19,7 @@ use Codeception\Module\UnitHelper;
|
||||||
* @method void am($role)
|
* @method void am($role)
|
||||||
* @method void lookForwardTo($achieveValue)
|
* @method void lookForwardTo($achieveValue)
|
||||||
* @method void comment($description)
|
* @method void comment($description)
|
||||||
* @method void haveFriend($name, $actorClass = null)
|
* @method void haveFriend($name)
|
||||||
*
|
|
||||||
* @SuppressWarnings(PHPMD)
|
|
||||||
*/
|
*/
|
||||||
class UnitTester extends \Codeception\Actor
|
class UnitTester extends \Codeception\Actor
|
||||||
{
|
{
|
||||||
|
|
@ -58,38 +56,6 @@ class UnitTester extends \Codeception\Actor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* [!] Method is generated. Documentation taken from corresponding module.
|
|
||||||
*
|
|
||||||
* Checks that two variables are same
|
|
||||||
*
|
|
||||||
* @param $expected
|
|
||||||
* @param $actual
|
|
||||||
* @param string $message
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
* @see \Codeception\Module\Asserts::assertSame()
|
|
||||||
*/
|
|
||||||
public function assertSame($expected, $actual, $message = null) {
|
|
||||||
return $this->scenario->runStep(new \Codeception\Step\Action('assertSame', func_get_args()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* [!] Method is generated. Documentation taken from corresponding module.
|
|
||||||
*
|
|
||||||
* Checks that two variables are not same
|
|
||||||
*
|
|
||||||
* @param $expected
|
|
||||||
* @param $actual
|
|
||||||
* @param string $message
|
|
||||||
* @see \Codeception\Module\Asserts::assertNotSame()
|
|
||||||
*/
|
|
||||||
public function assertNotSame($expected, $actual, $message = null) {
|
|
||||||
return $this->scenario->runStep(new \Codeception\Step\Action('assertNotSame', func_get_args()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [!] Method is generated. Documentation taken from corresponding module.
|
* [!] Method is generated. Documentation taken from corresponding module.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
use Codeception\Util\Debug;
|
|
||||||
|
|
||||||
if(!defined('__XE__')) define('__XE__', TRUE);
|
|
||||||
if(!defined('_XE_PATH_')) define('_XE_PATH_', realpath(dirname(__FILE__).'/../').'/');
|
|
||||||
$_SERVER['SCRIPT_NAME'] = '/xe/index.php';
|
$_SERVER['SCRIPT_NAME'] = '/xe/index.php';
|
||||||
|
|
||||||
error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_WARNING ^ E_STRICT);
|
error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_WARNING ^ E_STRICT);
|
||||||
|
|
||||||
|
|
||||||
function _log() {
|
|
||||||
$args = func_get_args();
|
|
||||||
$bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT, 2);
|
|
||||||
|
|
||||||
if(is_array($bt))
|
|
||||||
{
|
|
||||||
$bt_debug_print = array_shift($bt);
|
|
||||||
$bt_called_function = array_shift($bt);
|
|
||||||
}
|
|
||||||
$file_name = str_replace(_XE_PATH_, '', $bt_debug_print['file']);
|
|
||||||
$line_num = $bt_debug_print['line'];
|
|
||||||
$function = $bt_called_function['class'] . $bt_called_function['type'] . $bt_called_function['function'];
|
|
||||||
|
|
||||||
$print = sprintf("%s() [%s:%d]", $function, $file_name, $line_num);
|
|
||||||
|
|
||||||
Debug::debug("\n" . $print);
|
|
||||||
foreach($args as $arg) {
|
|
||||||
Debug::debug('(' . gettype($arg) . ') ' . var_export($arg, true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
require_once _XE_PATH_.'/classes/security/Security.class.php';
|
require_once _XE_PATH_.'classes/security/Security.class.php';
|
||||||
|
|
||||||
class SecurityTest extends \Codeception\TestCase\Test
|
class SecurityTest extends \Codeception\TestCase\Test
|
||||||
{
|
{
|
||||||
protected function setUp()
|
public function _before()
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Setup mock data
|
* Setup mock data
|
||||||
|
|
@ -35,18 +35,19 @@ class SecurityTest extends \Codeception\TestCase\Test
|
||||||
Context::set('array2', $aarr);
|
Context::set('array2', $aarr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEncodeHTML_DefaultContext()
|
public function testEncodeHtmlDefaultContext()
|
||||||
{
|
{
|
||||||
$security = new Security();
|
$security = new Security();
|
||||||
|
$this->assertTrue(true);
|
||||||
|
|
||||||
// normal string - one
|
// normal string - one
|
||||||
$this->setUp();
|
$this->_before();
|
||||||
$this->assertEquals('<strong>Hello, world</strong>', Context::get('content1'));
|
$this->assertEquals('<strong>Hello, world</strong>', Context::get('content1'));
|
||||||
$security->encodeHTML('content1');
|
$security->encodeHTML('content1');
|
||||||
$this->assertEquals('<strong>Hello, world</strong>', Context::get('content1'));
|
$this->assertEquals('<strong>Hello, world</strong>', Context::get('content1'));
|
||||||
|
|
||||||
// normal string - two
|
// normal string - two
|
||||||
$this->setUp();
|
$this->_before();
|
||||||
$this->assertEquals('<strong>Hello, world</strong>', Context::get('content1'));
|
$this->assertEquals('<strong>Hello, world</strong>', Context::get('content1'));
|
||||||
$this->assertEquals('Wow, >_< !', Context::get('content2'));
|
$this->assertEquals('Wow, >_< !', Context::get('content2'));
|
||||||
$security->encodeHTML('content1','content2');
|
$security->encodeHTML('content1','content2');
|
||||||
|
|
@ -61,7 +62,7 @@ class SecurityTest extends \Codeception\TestCase\Test
|
||||||
$this->assertEquals(Context::get('array1'), array('<span class="first">F</span>irst','<u>S</u>econd','<b>T</b>hird'));
|
$this->assertEquals(Context::get('array1'), array('<span class="first">F</span>irst','<u>S</u>econd','<b>T</b>hird'));
|
||||||
$security->encodeHTML('array1.2'); // affects only third element
|
$security->encodeHTML('array1.2'); // affects only third element
|
||||||
$this->assertEquals(Context::get('array1'), array('<span class="first">F</span>irst','<u>S</u>econd','<b>T</b>hird'));
|
$this->assertEquals(Context::get('array1'), array('<span class="first">F</span>irst','<u>S</u>econd','<b>T</b>hird'));
|
||||||
$this->setUp(); // reset;
|
$this->_before(); // reset;
|
||||||
$this->assertEquals(Context::get('array1'), array('<span class="first">F</span>irst','<u>S</u>econd','<b>T</b>hird'));
|
$this->assertEquals(Context::get('array1'), array('<span class="first">F</span>irst','<u>S</u>econd','<b>T</b>hird'));
|
||||||
$security->encodeHTML('array1.'); // affects all items
|
$security->encodeHTML('array1.'); // affects all items
|
||||||
$this->assertEquals(Context::get('array1'), array('<span class="first">F</span>irst','<u>S</u>econd','<b>T</b>hird'));
|
$this->assertEquals(Context::get('array1'), array('<span class="first">F</span>irst','<u>S</u>econd','<b>T</b>hird'));
|
||||||
|
|
@ -74,7 +75,7 @@ class SecurityTest extends \Codeception\TestCase\Test
|
||||||
$this->assertEquals(Context::get('array2'), array('elem1'=>'One <ins>1</ins>','elem2'=>'Two <del>2</del>','elem3'=>'Three <addr>3</addr>'));
|
$this->assertEquals(Context::get('array2'), array('elem1'=>'One <ins>1</ins>','elem2'=>'Two <del>2</del>','elem3'=>'Three <addr>3</addr>'));
|
||||||
$security->encodeHTML('array2.elem2'); // affects only 'elem2'
|
$security->encodeHTML('array2.elem2'); // affects only 'elem2'
|
||||||
$this->assertEquals(Context::get('array2'), array('elem1'=>'One <ins>1</ins>','elem2'=>'Two <del>2</del>','elem3'=>'Three <addr>3</addr>'));
|
$this->assertEquals(Context::get('array2'), array('elem1'=>'One <ins>1</ins>','elem2'=>'Two <del>2</del>','elem3'=>'Three <addr>3</addr>'));
|
||||||
$this->setUp(); // reset;
|
$this->_before(); // reset;
|
||||||
$this->assertEquals(Context::get('array2'), array('elem1'=>'One <ins>1</ins>','elem2'=>'Two <del>2</del>','elem3'=>'Three <addr>3</addr>'));
|
$this->assertEquals(Context::get('array2'), array('elem1'=>'One <ins>1</ins>','elem2'=>'Two <del>2</del>','elem3'=>'Three <addr>3</addr>'));
|
||||||
$security->encodeHTML('array2.'); // affects all items
|
$security->encodeHTML('array2.'); // affects all items
|
||||||
$this->assertEquals(Context::get('array2'), array('elem1'=>'One <ins>1</ins>','elem2'=>'Two <del>2</del>','elem3'=>'Three <addr>3</addr>'));
|
$this->assertEquals(Context::get('array2'), array('elem1'=>'One <ins>1</ins>','elem2'=>'Two <del>2</del>','elem3'=>'Three <addr>3</addr>'));
|
||||||
|
|
@ -94,7 +95,7 @@ class SecurityTest extends \Codeception\TestCase\Test
|
||||||
$security->encodeHTML('object1.prop3'); // affects only 'prop3' property
|
$security->encodeHTML('object1.prop3'); // affects only 'prop3' property
|
||||||
$obj->prop3 = '<strong>Strong</strong> Baby';
|
$obj->prop3 = '<strong>Strong</strong> Baby';
|
||||||
$this->assertEquals(Context::get('object1'), $obj);
|
$this->assertEquals(Context::get('object1'), $obj);
|
||||||
$this->setUp(); // reset
|
$this->_before(); // reset
|
||||||
$obj->prop3 = '<strong>Strong</strong> Baby';
|
$obj->prop3 = '<strong>Strong</strong> Baby';
|
||||||
$this->assertEquals(Context::get('object1'), $obj);
|
$this->assertEquals(Context::get('object1'), $obj);
|
||||||
$security->encodeHTML('object1.'); // affects all properties
|
$security->encodeHTML('object1.'); // affects all properties
|
||||||
|
|
@ -103,7 +104,7 @@ class SecurityTest extends \Codeception\TestCase\Test
|
||||||
$this->assertEquals(Context::get('object1'), $obj);
|
$this->assertEquals(Context::get('object1'), $obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEncodeHTML_CustomContext()
|
public function testEncodeHtmlCustomContext()
|
||||||
{
|
{
|
||||||
$array = array('Hello', 'World', '<b>Bold</b> is not bald');
|
$array = array('Hello', 'World', '<b>Bold</b> is not bald');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,11 @@ require_once _XE_PATH_.'classes/validator/Validator.class.php';
|
||||||
|
|
||||||
class ValidatorTest extends \Codeception\TestCase\Test
|
class ValidatorTest extends \Codeception\TestCase\Test
|
||||||
{
|
{
|
||||||
protected function setUp()
|
public function _before()
|
||||||
{
|
{
|
||||||
global $lang;
|
global $lang;
|
||||||
|
|
||||||
$lang->filter = new stdClass;
|
$lang->filter = new stdClass();
|
||||||
$lang->filter->isnull = 'isnull';
|
$lang->filter->isnull = 'isnull';
|
||||||
$lang->filter->outofrange = 'outofrange';
|
$lang->filter->outofrange = 'outofrange';
|
||||||
$lang->filter->equalto = 'equalto';
|
$lang->filter->equalto = 'equalto';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue