mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2025-10-08 11:28:48 -04:00
incrementing version number, updating docs
This commit is contained in:
parent
a41d0ca4dd
commit
608605cd54
25 changed files with 271 additions and 124 deletions
|
@ -41,6 +41,8 @@ class RainTPLTest extends PHPUnit_Framework_TestCase
|
|||
$page->assign('FILEUPLOAD', false);
|
||||
$page->assign('BASE64JSVERSION', '2.1.9');
|
||||
$page->assign('NOTICE', 'example');
|
||||
$page->assign('LANGUAGESELECTION', '');
|
||||
$page->assign('LANGUAGES', i18n::getLanguageLabels(i18n::getAvailableLanguages()));
|
||||
$page->assign('EXPIRE', self::$expire);
|
||||
$page->assign('EXPIREDEFAULT', self::$expire_default);
|
||||
ob_start();
|
||||
|
|
12
tst/i18n.php
12
tst/i18n.php
|
@ -25,6 +25,16 @@ class i18nTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertEquals($messageId, i18n::_($messageId), 'fallback to en');
|
||||
}
|
||||
|
||||
public function testCookieLanguageDeDetection()
|
||||
{
|
||||
$_COOKIE['lang'] = 'de';
|
||||
i18n::loadTranslations();
|
||||
$this->assertEquals($this->_translations['en'], i18n::_('en'), 'browser language de');
|
||||
$this->assertEquals('0 Stunden', i18n::_('%d hours', 0), '0 hours in german');
|
||||
$this->assertEquals('1 Stunde', i18n::_('%d hours', 1), '1 hour in german');
|
||||
$this->assertEquals('2 Stunden', i18n::_('%d hours', 2), '2 hours in french');
|
||||
}
|
||||
|
||||
public function testBrowserLanguageDeDetection()
|
||||
{
|
||||
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'de-CH,de;q=0.8,en-GB;q=0.6,en-US;q=0.4,en;q=0.2';
|
||||
|
@ -64,6 +74,6 @@ class i18nTest extends PHPUnit_Framework_TestCase
|
|||
{
|
||||
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'foobar';
|
||||
i18n::loadTranslations();
|
||||
$this->assertEquals('some string + 1', i18n::_('some %s + %d', 'string', 1), 'browser language de');
|
||||
$this->assertEquals('some string + 1', i18n::_('some %s + %d', 'string', 1), 'browser language en');
|
||||
}
|
||||
}
|
||||
|
|
124
tst/zerobin.php
124
tst/zerobin.php
|
@ -71,6 +71,31 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testViewLanguageSelection()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file($this->_conf, true);
|
||||
$options['main']['languageselection'] = true;
|
||||
if (!is_file($this->_conf . '.bak') && is_file($this->_conf))
|
||||
rename($this->_conf, $this->_conf . '.bak');
|
||||
helper::createIniFile($this->_conf, $options);
|
||||
$_COOKIE['lang'] = 'de';
|
||||
ob_start();
|
||||
new zerobin;
|
||||
$content = ob_get_contents();
|
||||
$this->assertTag(
|
||||
array(
|
||||
'tag' => 'title',
|
||||
'content' => 'ZeroBin'
|
||||
),
|
||||
$content,
|
||||
'outputs title correctly'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
|
@ -168,6 +193,27 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertFalse($this->_model->exists(self::$pasteid), 'paste exists after posting data');
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testCreateProxyHeader()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file($this->_conf, true);
|
||||
$options['traffic']['header'] = 'X_FORWARDED_FOR';
|
||||
if (!is_file($this->_conf . '.bak') && is_file($this->_conf))
|
||||
rename($this->_conf, $this->_conf . '.bak');
|
||||
helper::createIniFile($this->_conf, $options);
|
||||
$_POST = self::$paste;
|
||||
$_SERVER['HTTP_X_FORWARDED_FOR'] = '::1';
|
||||
ob_start();
|
||||
new zerobin;
|
||||
$content = ob_get_contents();
|
||||
$response = json_decode($content, true);
|
||||
$this->assertEquals(1, $response['status'], 'outputs error status');
|
||||
$this->assertFalse($this->_model->exists(self::$pasteid), 'paste exists after posting data');
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
|
@ -289,6 +335,35 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertFalse($this->_model->exists(self::$pasteid), 'paste exists after posting data');
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testCreateAttachment()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file($this->_conf, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
$options['main']['fileupload'] = true;
|
||||
if (!is_file($this->_conf . '.bak') && is_file($this->_conf))
|
||||
rename($this->_conf, $this->_conf . '.bak');
|
||||
helper::createIniFile($this->_conf, $options);
|
||||
$_POST = self::$paste;
|
||||
$_POST['attachment'] = self::$comment['data'];
|
||||
$_POST['attachmentname'] = self::$comment['meta']['nickname'];
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
ob_start();
|
||||
new zerobin;
|
||||
$content = ob_get_contents();
|
||||
$response = json_decode($content, true);
|
||||
$this->assertEquals(0, $response['status'], 'outputs status');
|
||||
$this->assertEquals(
|
||||
hash_hmac('sha1', $response['id'], serversalt::get()),
|
||||
$response['deletetoken'],
|
||||
'outputs valid delete token'
|
||||
);
|
||||
$this->assertTrue($this->_model->exists($response['id']), 'paste exists after posting data');
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
|
@ -598,6 +673,55 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertEquals(1, $response['status'], 'outputs error status');
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testReadOldSyntax()
|
||||
{
|
||||
$this->reset();
|
||||
$oldPaste = self::$paste;
|
||||
$oldPaste['meta']['syntaxcoloring'] = true;
|
||||
unset($oldPaste['meta']['formatter']);
|
||||
$this->_model->create(self::$pasteid, $oldPaste);
|
||||
$_SERVER['QUERY_STRING'] = self::$pasteid;
|
||||
ob_start();
|
||||
new zerobin;
|
||||
$content = ob_get_contents();
|
||||
$oldPaste['meta']['formatter'] = 'syntaxhighlighting';
|
||||
$this->assertTag(
|
||||
array(
|
||||
'id' => 'cipherdata',
|
||||
'content' => htmlspecialchars(json_encode($oldPaste), ENT_NOQUOTES)
|
||||
),
|
||||
$content,
|
||||
'outputs data correctly'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testReadOldFormat()
|
||||
{
|
||||
$this->reset();
|
||||
$oldPaste = self::$paste;
|
||||
unset($oldPaste['meta']['formatter']);
|
||||
$this->_model->create(self::$pasteid, $oldPaste);
|
||||
$_SERVER['QUERY_STRING'] = self::$pasteid;
|
||||
ob_start();
|
||||
new zerobin;
|
||||
$content = ob_get_contents();
|
||||
$oldPaste['meta']['formatter'] = 'plaintext';
|
||||
$this->assertTag(
|
||||
array(
|
||||
'id' => 'cipherdata',
|
||||
'content' => htmlspecialchars(json_encode($oldPaste), ENT_NOQUOTES)
|
||||
),
|
||||
$content,
|
||||
'outputs data correctly'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue