1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-04 21:57:51 +02:00

New tests for file_class and eHelper placeholder test class added

This commit is contained in:
Cameron
2018-08-10 11:10:59 -07:00
parent bee5c325d6
commit d73bcacaaa
2 changed files with 183 additions and 0 deletions

119
tests/unit/eHelperTest.php Normal file
View File

@@ -0,0 +1,119 @@
<?php
/**
* e107 website system
*
* Copyright (C) 2008-2018 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*/
class eHelperTest extends \Codeception\Test\Unit
{
/** @var eHelper */
protected $hp;
protected function _before()
{
try
{
$this->hp = $this->make('eHelper');
}
catch (Exception $e)
{
$this->fail("Couldn't load eHelper object");
}
}
/*
public function testFormatMetaTitle()
{
}
public function testFormatMetaKeys()
{
}
public function testGetMemoryUsage()
{
}
public function testUnderscore()
{
}
public function testFormatMetaDescription()
{
}
public function testSecureIdAttr()
{
}
public function testTitle2sef()
{
}
public function testCamelize()
{
}
public function testScParams()
{
}
public function testLabelize()
{
}
public function testSecureClassAttr()
{
}
public function testSecureStyleAttr()
{
}
public function testScDualParams()
{
}
public function testDasherize()
{
}
public function testParseMemorySize()
{
}
public function testBuildAttr()
{
}
public function testSecureSef()
{
}*/
}

View File

@@ -14,6 +14,7 @@
/** @var e_file */
protected $fl;
protected $exploitFile = '';
protected function _before()
{
@@ -26,9 +27,72 @@
$this->fail("Couldn't load e_file object");
}
$this->exploitFile = e_TEMP."test_exploit_file.jpg";
$content = "<?php system(\$_GET['q']) ?>";
file_put_contents($this->exploitFile,$content);
}
protected function _after()
{
unlink($this->exploitFile);
}
public function testIsClean()
{
$isCleanTest = array(
array('path'=>$this->exploitFile, 'expected' => false), // suspicious
array('path'=>e_SYSTEM."filetypes.xml", 'expected' => true), // okay
array('path'=>e_PLUGIN."gallery/images/butterfly.jpg", 'expected' => true), // okay
);
foreach($isCleanTest as $file)
{
$actual = $this->fl->isClean($file['path'], $file['path']);
$this->assertEquals($file['expected'],$actual, "isClean() failed with error code: ".$this->fl->getErrorCode());
}
}
public function testGetAllowedFileTypes()
{
$actual = $this->fl->getAllowedFileTypes();
$expected = array (
'zip' => 2048,
'gz' => 2048,
'jpg' => 2048,
'jpeg' => 2048,
'png' => 2048,
'gif' => 2048,
'xml' => 2048,
'pdf' => 2048,
);
$this->assertEquals($expected,$actual);
}
public function testIsAllowedType()
{
$isAllowedTest = array(
array('path'=> 'somefile.bla', 'expected' => false), // suspicious
array('path'=> e_SYSTEM."filetypes.xml", 'expected' => true), // okay
array('path'=> e_PLUGIN."gallery/images/butterfly.jpg", 'expected' => true), // okay
);
foreach($isAllowedTest as $file)
{
$actual = $this->fl->isAllowedType($file['path']);
// $this->assertEquals($file['expected'],$actual, "isAllowedType() failed on: ".$file['path']);
}
}
/*
public function testSend()
{