@@ -1,8 +0,0 @@
|
||||
<?php
|
||||
class autoTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testAutoloaderReturnsFalseWhenCallingNonExistingClass()
|
||||
{
|
||||
$this->assertFalse(auto::loader('foo2501bar42'), 'calling non existent class');
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,24 @@
|
||||
<?php
|
||||
error_reporting( E_ALL | E_STRICT );
|
||||
|
||||
use PrivateBin\serversalt;
|
||||
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
|
||||
// change this, if your php files and data is outside of your webservers document root
|
||||
if (!defined('PUBLIC_PATH')) define('PUBLIC_PATH', '..');
|
||||
if (!defined('PATH')) define('PATH', '..' . DIRECTORY_SEPARATOR);
|
||||
if (!defined('CONF')) define('CONF', PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini');
|
||||
if (!is_file(CONF)) copy(CONF . '.sample', CONF);
|
||||
if (!defined('PUBLIC_PATH')) {
|
||||
define('PUBLIC_PATH', '..');
|
||||
}
|
||||
if (!defined('PATH')) {
|
||||
define('PATH', '..' . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
if (!defined('CONF')) {
|
||||
define('CONF', PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini');
|
||||
}
|
||||
if (!is_file(CONF)) {
|
||||
copy(CONF . '.sample', CONF);
|
||||
}
|
||||
|
||||
require PATH . 'lib/auto.php';
|
||||
require PATH . 'vendor/autoload.php';
|
||||
|
||||
class helper
|
||||
{
|
||||
@@ -100,8 +111,9 @@ class helper
|
||||
$example = self::getPaste();
|
||||
// the JSON shouldn't contain the salt
|
||||
unset($example['meta']['salt']);
|
||||
if (count($meta))
|
||||
if (count($meta)) {
|
||||
$example['meta'] = $meta;
|
||||
}
|
||||
$example['comments'] = array();
|
||||
$example['comment_count'] = 0;
|
||||
$example['comment_offset'] = 0;
|
||||
@@ -154,19 +166,19 @@ class helper
|
||||
{
|
||||
$path .= DIRECTORY_SEPARATOR;
|
||||
$dir = dir($path);
|
||||
while(false !== ($file = $dir->read())) {
|
||||
if($file != '.' && $file != '..') {
|
||||
if(is_dir($path . $file)) {
|
||||
while (false !== ($file = $dir->read())) {
|
||||
if ($file != '.' && $file != '..') {
|
||||
if (is_dir($path . $file)) {
|
||||
self::rmdir($path . $file);
|
||||
} elseif(is_file($path . $file)) {
|
||||
if(!@unlink($path . $file)) {
|
||||
} elseif (is_file($path . $file)) {
|
||||
if (!@unlink($path . $file)) {
|
||||
throw new Exception('Error deleting file "' . $path . $file . '".');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$dir->close();
|
||||
if(!@rmdir($path)) {
|
||||
if (!@rmdir($path)) {
|
||||
throw new Exception('Error deleting directory "' . $path . '".');
|
||||
}
|
||||
}
|
||||
@@ -178,8 +190,9 @@ class helper
|
||||
*/
|
||||
public static function confBackup()
|
||||
{
|
||||
if (!is_file(CONF . '.bak') && is_file(CONF))
|
||||
if (!is_file(CONF . '.bak') && is_file(CONF)) {
|
||||
rename(CONF, CONF . '.bak');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,8 +202,9 @@ class helper
|
||||
*/
|
||||
public static function confRestore()
|
||||
{
|
||||
if (is_file(CONF . '.bak'))
|
||||
if (is_file(CONF . '.bak')) {
|
||||
rename(CONF . '.bak', CONF);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -206,7 +220,7 @@ class helper
|
||||
$ini = fopen($pathToFile, 'a');
|
||||
foreach ($values as $section => $options) {
|
||||
fwrite($ini, "[$section]" . PHP_EOL);
|
||||
foreach($options as $option => $setting) {
|
||||
foreach ($options as $option => $setting) {
|
||||
if (is_null($setting)) {
|
||||
continue;
|
||||
} elseif (is_string($setting)) {
|
||||
|
||||
@@ -388,7 +388,8 @@ class configurationTestGenerator
|
||||
* constructor, generates the configuration test
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct($options) {
|
||||
public function __construct($options)
|
||||
{
|
||||
$this->_options = $options;
|
||||
// generate all possible combinations of options: options^settings
|
||||
$this->_generateConfigurations();
|
||||
@@ -418,7 +419,7 @@ class configurationTestGenerator
|
||||
while (list($path, $setting) = each($test['conditions'])) {
|
||||
if ($path == 'steps' && !in_array($step, $setting)) {
|
||||
continue 2;
|
||||
} elseif($path != 'steps') {
|
||||
} elseif ($path != 'steps') {
|
||||
list($section, $option) = explode('/', $path);
|
||||
if ($fullOptions[$section][$option] !== $setting) {
|
||||
continue 2;
|
||||
@@ -653,7 +654,8 @@ EOT;
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
private function _addSetting(&$configuration, &$setting, &$section, &$option) {
|
||||
private function _addSetting(&$configuration, &$setting, &$section, &$option)
|
||||
{
|
||||
if (++$this->_iterationCount > self::MAX_ITERATIONS) {
|
||||
echo 'max iterations reached, stopping', PHP_EOL;
|
||||
return $configuration;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\configuration;
|
||||
|
||||
class configurationTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $_options;
|
||||
@@ -125,12 +128,11 @@ class configurationTest extends PHPUnit_Framework_TestCase
|
||||
$options['model']['class'] = 'zerobin_data';
|
||||
helper::createIniFile(CONF, $options);
|
||||
$conf = new configuration;
|
||||
$this->assertEquals('privatebin_data', $conf->getKey('class', 'model'), 'old data class gets renamed');
|
||||
$this->assertEquals('PrivateBin\data\data', $conf->getKey('class', 'model'), 'old data class gets renamed');
|
||||
|
||||
$options['model']['class'] = 'zerobin_db';
|
||||
helper::createIniFile(CONF, $options);
|
||||
$conf = new configuration;
|
||||
$this->assertEquals('privatebin_db', $conf->getKey('class', 'model'), 'old db class gets renamed');
|
||||
$this->assertEquals('PrivateBin\data\db', $conf->getKey('class', 'model'), 'old db class gets renamed');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\filter;
|
||||
|
||||
class filterTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testFilterStripsSlashesDeeply()
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\i18n;
|
||||
|
||||
class i18nTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $_translations = array();
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\data\data;
|
||||
use PrivateBin\privatebin;
|
||||
use PrivateBin\request;
|
||||
use PrivateBin\serversalt;
|
||||
|
||||
class jsonApiTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $_model;
|
||||
@@ -6,7 +12,7 @@ class jsonApiTest extends PHPUnit_Framework_TestCase
|
||||
public function setUp()
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_model = privatebin_data::getInstance(array('dir' => PATH . 'data'));
|
||||
$this->_model = data::getInstance(array('dir' => PATH . 'data'));
|
||||
serversalt::setPath(PATH . 'data');
|
||||
$this->reset();
|
||||
}
|
||||
@@ -22,8 +28,9 @@ class jsonApiTest extends PHPUnit_Framework_TestCase
|
||||
$_POST = array();
|
||||
$_GET = array();
|
||||
$_SERVER = array();
|
||||
if ($this->_model->exists(helper::getPasteId()))
|
||||
if ($this->_model->exists(helper::getPasteId())) {
|
||||
$this->_model->delete(helper::getPasteId());
|
||||
}
|
||||
helper::confRestore();
|
||||
}
|
||||
|
||||
@@ -267,5 +274,4 @@ class jsonApiTest extends PHPUnit_Framework_TestCase
|
||||
ob_end_clean();
|
||||
$this->assertEquals('{}', $content, 'does not output nasty data');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\configuration;
|
||||
use PrivateBin\data\db;
|
||||
use PrivateBin\model;
|
||||
use PrivateBin\model\paste;
|
||||
use PrivateBin\vizhash16x16;
|
||||
|
||||
class modelTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $_conf;
|
||||
@@ -165,9 +172,9 @@ class modelTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testPasteIdValidation()
|
||||
{
|
||||
$this->assertTrue(model_paste::isValidId('a242ab7bdfb2581a'), 'valid paste id');
|
||||
$this->assertFalse(model_paste::isValidId('foo'), 'invalid hex values');
|
||||
$this->assertFalse(model_paste::isValidId('../bar/baz'), 'path attack');
|
||||
$this->assertTrue(paste::isValidId('a242ab7bdfb2581a'), 'valid paste id');
|
||||
$this->assertFalse(paste::isValidId('foo'), 'invalid hex values');
|
||||
$this->assertFalse(paste::isValidId('../bar/baz'), 'path attack');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,37 +221,29 @@ class modelTest extends PHPUnit_Framework_TestCase
|
||||
public function testPurge()
|
||||
{
|
||||
$conf = new configuration;
|
||||
$store = privatebin_db::getInstance($conf->getSection('model_options'));
|
||||
$store = db::getInstance($conf->getSection('model_options'));
|
||||
$store->delete(helper::getPasteId());
|
||||
$expired = helper::getPaste(array('expire_date' => 1344803344));
|
||||
$paste = helper::getPaste(array('expire_date' => time() + 3600));
|
||||
$keys = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'x', 'y', 'z');
|
||||
$ids = array();
|
||||
foreach ($keys as $key)
|
||||
{
|
||||
foreach ($keys as $key) {
|
||||
$ids[$key] = substr(md5($key), 0, 16);
|
||||
$store->delete($ids[$key]);
|
||||
$this->assertFalse($store->exists($ids[$key]), "paste $key does not yet exist");
|
||||
if (in_array($key, array('x', 'y', 'z')))
|
||||
{
|
||||
if (in_array($key, array('x', 'y', 'z'))) {
|
||||
$this->assertTrue($store->create($ids[$key], $paste), "store $key paste");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->assertTrue($store->create($ids[$key], $expired), "store $key paste");
|
||||
}
|
||||
$this->assertTrue($store->exists($ids[$key]), "paste $key exists after storing it");
|
||||
}
|
||||
$this->_model->purge(10);
|
||||
foreach ($ids as $key => $id)
|
||||
{
|
||||
if (in_array($key, array('x', 'y', 'z')))
|
||||
{
|
||||
foreach ($ids as $key => $id) {
|
||||
if (in_array($key, array('x', 'y', 'z'))) {
|
||||
$this->assertTrue($this->_model->getPaste($id)->exists(), "paste $key exists after purge");
|
||||
$this->_model->getPaste($id)->delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->assertFalse($this->_model->getPaste($id)->exists(), "paste $key was purged");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<whitelist>
|
||||
<directory suffix=".php">../lib</directory>
|
||||
<exclude>
|
||||
<file>../lib/privatebin/abstract.php</file>
|
||||
<file>../lib/data/AbstractData.php</file>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\data\data;
|
||||
use PrivateBin\privatebin;
|
||||
use PrivateBin\serversalt;
|
||||
use PrivateBin\trafficlimiter;
|
||||
|
||||
class privatebinTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $_model;
|
||||
@@ -6,7 +12,7 @@ class privatebinTest extends PHPUnit_Framework_TestCase
|
||||
public function setUp()
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_model = privatebin_data::getInstance(array('dir' => PATH . 'data'));
|
||||
$this->_model = data::getInstance(array('dir' => PATH . 'data'));
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
@@ -21,8 +27,9 @@ class privatebinTest extends PHPUnit_Framework_TestCase
|
||||
$_POST = array();
|
||||
$_GET = array();
|
||||
$_SERVER = array();
|
||||
if ($this->_model->exists(helper::getPasteId()))
|
||||
if ($this->_model->exists(helper::getPasteId())) {
|
||||
$this->_model->delete(helper::getPasteId());
|
||||
}
|
||||
helper::confRestore();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\data\data;
|
||||
|
||||
class privatebin_dataTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $_model;
|
||||
@@ -9,7 +12,7 @@ class privatebin_dataTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
$this->_model = privatebin_data::getInstance(array('dir' => $this->_path));
|
||||
$this->_model = data::getInstance(array('dir' => $this->_path));
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
@@ -70,30 +73,22 @@ class privatebin_dataTest extends PHPUnit_Framework_TestCase
|
||||
$paste = helper::getPaste(array('expire_date' => time() + 3600));
|
||||
$keys = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'x', 'y', 'z');
|
||||
$ids = array();
|
||||
foreach ($keys as $key)
|
||||
{
|
||||
foreach ($keys as $key) {
|
||||
$ids[$key] = substr(md5($key), 0, 16);
|
||||
$this->assertFalse($this->_model->exists($ids[$key]), "paste $key does not yet exist");
|
||||
if (in_array($key, array('x', 'y', 'z')))
|
||||
{
|
||||
if (in_array($key, array('x', 'y', 'z'))) {
|
||||
$this->assertTrue($this->_model->create($ids[$key], $paste), "store $key paste");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->assertTrue($this->_model->create($ids[$key], $expired), "store $key paste");
|
||||
}
|
||||
$this->assertTrue($this->_model->exists($ids[$key]), "paste $key exists after storing it");
|
||||
}
|
||||
$this->_model->purge(10);
|
||||
foreach ($ids as $key => $id)
|
||||
{
|
||||
if (in_array($key, array('x', 'y', 'z')))
|
||||
{
|
||||
foreach ($ids as $key => $id) {
|
||||
if (in_array($key, array('x', 'y', 'z'))) {
|
||||
$this->assertTrue($this->_model->exists($id), "paste $key exists after purge");
|
||||
$this->_model->delete($id);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->assertFalse($this->_model->exists($id), "paste $key was purged");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\data\db;
|
||||
|
||||
class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $_model;
|
||||
@@ -13,13 +16,15 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
public function setUp()
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_model = privatebin_db::getInstance($this->_options);
|
||||
$this->_model = db::getInstance($this->_options);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
/* Tear Down Routine */
|
||||
if (is_dir(PATH . 'data')) helper::rmdir(PATH . 'data');
|
||||
if (is_dir(PATH . 'data')) {
|
||||
helper::rmdir(PATH . 'data');
|
||||
}
|
||||
}
|
||||
|
||||
public function testDatabaseBasedDataStoreWorks()
|
||||
@@ -75,31 +80,23 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
$paste = helper::getPaste(array('expire_date' => time() + 3600));
|
||||
$keys = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'x', 'y', 'z');
|
||||
$ids = array();
|
||||
foreach ($keys as $key)
|
||||
{
|
||||
foreach ($keys as $key) {
|
||||
$ids[$key] = substr(md5($key), 0, 16);
|
||||
$this->_model->delete($ids[$key]);
|
||||
$this->assertFalse($this->_model->exists($ids[$key]), "paste $key does not yet exist");
|
||||
if (in_array($key, array('x', 'y', 'z')))
|
||||
{
|
||||
if (in_array($key, array('x', 'y', 'z'))) {
|
||||
$this->assertTrue($this->_model->create($ids[$key], $paste), "store $key paste");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->assertTrue($this->_model->create($ids[$key], $expired), "store $key paste");
|
||||
}
|
||||
$this->assertTrue($this->_model->exists($ids[$key]), "paste $key exists after storing it");
|
||||
}
|
||||
$this->_model->purge(10);
|
||||
foreach ($ids as $key => $id)
|
||||
{
|
||||
if (in_array($key, array('x', 'y', 'z')))
|
||||
{
|
||||
foreach ($ids as $key => $id) {
|
||||
if (in_array($key, array('x', 'y', 'z'))) {
|
||||
$this->assertTrue($this->_model->exists($id), "paste $key exists after purge");
|
||||
$this->_model->delete($id);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->assertFalse($this->_model->exists($id), "paste $key was purged");
|
||||
}
|
||||
}
|
||||
@@ -110,7 +107,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetIbmInstance()
|
||||
{
|
||||
privatebin_db::getInstance(array(
|
||||
db::getInstance(array(
|
||||
'dsn' => 'ibm:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
));
|
||||
@@ -121,7 +118,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetInformixInstance()
|
||||
{
|
||||
privatebin_db::getInstance(array(
|
||||
db::getInstance(array(
|
||||
'dsn' => 'informix:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
));
|
||||
@@ -132,7 +129,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetMssqlInstance()
|
||||
{
|
||||
privatebin_db::getInstance(array(
|
||||
db::getInstance(array(
|
||||
'dsn' => 'mssql:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
));
|
||||
@@ -143,7 +140,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetMysqlInstance()
|
||||
{
|
||||
privatebin_db::getInstance(array(
|
||||
db::getInstance(array(
|
||||
'dsn' => 'mysql:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
));
|
||||
@@ -154,7 +151,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetOciInstance()
|
||||
{
|
||||
privatebin_db::getInstance(array(
|
||||
db::getInstance(array(
|
||||
'dsn' => 'oci:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
));
|
||||
@@ -165,7 +162,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetPgsqlInstance()
|
||||
{
|
||||
privatebin_db::getInstance(array(
|
||||
db::getInstance(array(
|
||||
'dsn' => 'pgsql:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
));
|
||||
@@ -177,7 +174,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetFooInstance()
|
||||
{
|
||||
privatebin_db::getInstance(array(
|
||||
db::getInstance(array(
|
||||
'dsn' => 'foo:', 'usr' => null, 'pwd' => null, 'opt' => null
|
||||
));
|
||||
}
|
||||
@@ -190,7 +187,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$options = $this->_options;
|
||||
unset($options['dsn']);
|
||||
privatebin_db::getInstance($options);
|
||||
db::getInstance($options);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,7 +198,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$options = $this->_options;
|
||||
unset($options['usr']);
|
||||
privatebin_db::getInstance($options);
|
||||
db::getInstance($options);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,7 +209,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$options = $this->_options;
|
||||
unset($options['pwd']);
|
||||
privatebin_db::getInstance($options);
|
||||
db::getInstance($options);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,7 +220,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$options = $this->_options;
|
||||
unset($options['opt']);
|
||||
privatebin_db::getInstance($options);
|
||||
db::getInstance($options);
|
||||
}
|
||||
|
||||
public function testOldAttachments()
|
||||
@@ -233,7 +230,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
@unlink($path);
|
||||
$this->_options['dsn'] = 'sqlite:' . $path;
|
||||
$this->_options['tbl'] = 'bar_';
|
||||
$model = privatebin_db::getInstance($this->_options);
|
||||
$model = db::getInstance($this->_options);
|
||||
|
||||
$original = $paste = helper::getPasteWithAttachment(array('expire_date' => 1344803344));
|
||||
$paste['meta']['attachment'] = $paste['attachment'];
|
||||
@@ -301,7 +298,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
'vizhash BLOB, ' .
|
||||
"postdate INT );"
|
||||
);
|
||||
privatebin_db::getInstance($this->_options);
|
||||
db::getInstance($this->_options);
|
||||
helper::rmdir(PATH . 'data');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\data\db;
|
||||
use PrivateBin\privatebin;
|
||||
use PrivateBin\serversalt;
|
||||
use PrivateBin\trafficlimiter;
|
||||
|
||||
require_once 'privatebin.php';
|
||||
|
||||
class privatebinWithDbTest extends privatebinTest
|
||||
@@ -18,9 +24,11 @@ class privatebinWithDbTest extends privatebinTest
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
if(!is_dir($this->_path)) mkdir($this->_path);
|
||||
if (!is_dir($this->_path)) {
|
||||
mkdir($this->_path);
|
||||
}
|
||||
$this->_options['dsn'] = 'sqlite:' . $this->_path . DIRECTORY_SEPARATOR . 'tst.sq3';
|
||||
$this->_model = privatebin_db::getInstance($this->_options);
|
||||
$this->_model = db::getInstance($this->_options);
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\purgelimiter;
|
||||
|
||||
class purgelimiterTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $_path;
|
||||
@@ -7,7 +10,9 @@ class purgelimiterTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
if(!is_dir($this->_path)) mkdir($this->_path);
|
||||
if (!is_dir($this->_path)) {
|
||||
mkdir($this->_path);
|
||||
}
|
||||
purgelimiter::setPath($this->_path);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\request;
|
||||
|
||||
class requestTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\serversalt;
|
||||
|
||||
class serversaltTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $_path;
|
||||
@@ -13,13 +16,17 @@ class serversaltTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_path = PATH . 'data';
|
||||
if(!is_dir($this->_path)) mkdir($this->_path);
|
||||
if (!is_dir($this->_path)) {
|
||||
mkdir($this->_path);
|
||||
}
|
||||
serversalt::setPath($this->_path);
|
||||
|
||||
$this->_otherPath = $this->_path . DIRECTORY_SEPARATOR . 'foo';
|
||||
|
||||
$this->_invalidPath = $this->_path . DIRECTORY_SEPARATOR . 'bar';
|
||||
if(!is_dir($this->_invalidPath)) mkdir($this->_invalidPath);
|
||||
if (!is_dir($this->_invalidPath)) {
|
||||
mkdir($this->_invalidPath);
|
||||
}
|
||||
$this->_invalidFile = $this->_invalidPath . DIRECTORY_SEPARATOR . 'salt.php';
|
||||
}
|
||||
|
||||
@@ -37,18 +44,18 @@ class serversaltTest extends PHPUnit_Framework_TestCase
|
||||
$salt = serversalt::get();
|
||||
|
||||
// mcrypt mock
|
||||
if (!function_exists('mcrypt_create_iv'))
|
||||
{
|
||||
if (!defined('MCRYPT_DEV_URANDOM')) define('MCRYPT_DEV_URANDOM', 1);
|
||||
if (!function_exists('mcrypt_create_iv')) {
|
||||
if (!defined('MCRYPT_DEV_URANDOM')) {
|
||||
define('MCRYPT_DEV_URANDOM', 1);
|
||||
}
|
||||
function mcrypt_create_iv($int, $flag)
|
||||
{
|
||||
$randomSalt = '';
|
||||
for($i = 0; $i < $int; ++$i) {
|
||||
for ($i = 0; $i < $int; ++$i) {
|
||||
$randomSalt .= base_convert(mt_rand(), 10, 16);
|
||||
}
|
||||
// hex2bin requires an even length, pad if necessary
|
||||
if (strlen($randomSalt) % 2)
|
||||
{
|
||||
if (strlen($randomSalt) % 2) {
|
||||
$randomSalt = '0' . $randomSalt;
|
||||
}
|
||||
return hex2bin($randomSalt);
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\sjcl;
|
||||
|
||||
class sjclTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testSjclValidatorValidatesCorrectly()
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\trafficlimiter;
|
||||
|
||||
class trafficlimiterTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $_path;
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\i18n;
|
||||
use PrivateBin\view;
|
||||
|
||||
class viewTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private static $error = 'foo bar';
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\serversalt;
|
||||
use PrivateBin\vizhash16x16;
|
||||
|
||||
class vizhash16x16Test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $_file;
|
||||
@@ -9,7 +13,9 @@ class vizhash16x16Test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_path = PATH . 'data';
|
||||
if(!is_dir($this->_path)) mkdir($this->_path);
|
||||
if (!is_dir($this->_path)) {
|
||||
mkdir($this->_path);
|
||||
}
|
||||
$this->_file = $this->_path . DIRECTORY_SEPARATOR . 'vizhash.png';
|
||||
serversalt::setPath($this->_path);
|
||||
}
|
||||
@@ -18,7 +24,7 @@ class vizhash16x16Test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/* Tear Down Routine */
|
||||
chmod($this->_path, 0700);
|
||||
if(!@unlink($this->_file)) {
|
||||
if (!@unlink($this->_file)) {
|
||||
throw new Exception('Error deleting file "' . $this->_file . '".');
|
||||
}
|
||||
helper::rmdir($this->_path);
|
||||
|
||||
Reference in New Issue
Block a user