|
|
|
@ -2,10 +2,8 @@
|
|
|
|
|
|
|
|
|
|
require_once('common.php');
|
|
|
|
|
|
|
|
|
|
class PaCryptTest extends PHPUnit_Framework_TestCase
|
|
|
|
|
{
|
|
|
|
|
public function testMd5Crypt()
|
|
|
|
|
{
|
|
|
|
|
class PaCryptTest extends PHPUnit_Framework_TestCase {
|
|
|
|
|
public function testMd5Crypt() {
|
|
|
|
|
$hash = _pacrypt_md5crypt('test', '');
|
|
|
|
|
|
|
|
|
|
$this->assertNotEmpty($hash);
|
|
|
|
@ -14,8 +12,7 @@ class PaCryptTest extends PHPUnit_Framework_TestCase
|
|
|
|
|
$this->assertEquals($hash, _pacrypt_md5crypt('test', $hash));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testCrypt()
|
|
|
|
|
{
|
|
|
|
|
public function testCrypt() {
|
|
|
|
|
|
|
|
|
|
// E_NOTICE if we pass in '' for the salt
|
|
|
|
|
$hash = _pacrypt_crypt('test', 'sa');
|
|
|
|
@ -24,11 +21,9 @@ class PaCryptTest extends PHPUnit_Framework_TestCase
|
|
|
|
|
$this->assertNotEquals('test', $hash);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals($hash, _pacrypt_crypt('test', $hash));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testMySQLEncrypt()
|
|
|
|
|
{
|
|
|
|
|
public function testMySQLEncrypt() {
|
|
|
|
|
if (!db_mysql()) {
|
|
|
|
|
$this->markTestSkipped('Not using MySQL');
|
|
|
|
|
}
|
|
|
|
@ -48,8 +43,7 @@ class PaCryptTest extends PHPUnit_Framework_TestCase
|
|
|
|
|
$this->assertEquals($hash2, _pacrypt_mysql_encrypt('test', 'salt'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testAuthlib()
|
|
|
|
|
{
|
|
|
|
|
public function testAuthlib() {
|
|
|
|
|
|
|
|
|
|
// too many options!
|
|
|
|
|
foreach (
|
|
|
|
@ -67,8 +61,7 @@ class PaCryptTest extends PHPUnit_Framework_TestCase
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testPacryptDovecot()
|
|
|
|
|
{
|
|
|
|
|
public function testPacryptDovecot() {
|
|
|
|
|
global $CONF;
|
|
|
|
|
if (!file_exists('/usr/bin/doveadm')) {
|
|
|
|
|
$this->markTestSkipped("No /usr/bin/doveadm");
|
|
|
|
@ -84,8 +77,7 @@ class PaCryptTest extends PHPUnit_Framework_TestCase
|
|
|
|
|
$this->assertEquals($expected_hash, _pacrypt_dovecot('test', $expected_hash));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testPhpCrypt()
|
|
|
|
|
{
|
|
|
|
|
public function testPhpCrypt() {
|
|
|
|
|
global $CONF;
|
|
|
|
|
|
|
|
|
|
$config = Config::getInstance();
|
|
|
|
@ -104,18 +96,15 @@ class PaCryptTest extends PHPUnit_Framework_TestCase
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertNotEquals($fail, $expected);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testPhpCryptRandomString(){
|
|
|
|
|
public function testPhpCryptRandomString() {
|
|
|
|
|
$str1 = _php_crypt_random_string('abcdefg123456789', 2);
|
|
|
|
|
$str2 = _php_crypt_random_string('abcdefg123456789', 2);
|
|
|
|
|
|
|
|
|
|
$this->assertNotEmpty($str1);
|
|
|
|
|
$this->assertNotEmpty($str2);
|
|
|
|
|
$this->assertNotEquals($str1, $str2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|