mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2024-09-19 19:22:14 +02:00
format
This commit is contained in:
parent
7090b5af75
commit
0096a41693
@ -1084,8 +1084,7 @@ function _pacrypt_dovecot($pw, $pw_db = '') {
|
||||
* @param string $pw_db (can be empty if setting a new password)
|
||||
* @return string crypt'ed password; if it matches $pw_db then $pw is the original password.
|
||||
*/
|
||||
function _pacrypt_php_crypt($pw, $pw_db)
|
||||
{
|
||||
function _pacrypt_php_crypt($pw, $pw_db) {
|
||||
$configEncrypt = Config::read_string('encrypt');
|
||||
|
||||
// use PHPs crypt(), which uses the system's crypt()
|
||||
@ -1110,7 +1109,6 @@ function _pacrypt_php_crypt($pw, $pw_db)
|
||||
$salt = $method_matches[2];
|
||||
$prefix = "{" . $method_matches[1] . "}";
|
||||
}
|
||||
|
||||
} else {
|
||||
$salt_method = 'SHA512'; // hopefully a reasonable default (better than MD5)
|
||||
$hash_difficulty = '';
|
||||
|
@ -1,9 +1,7 @@
|
||||
<?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);
|
||||
@ -12,8 +10,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,8 +21,7 @@ class PaCryptTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertEquals($hash, _pacrypt_crypt('test', $hash));
|
||||
}
|
||||
|
||||
public function testMySQLEncrypt()
|
||||
{
|
||||
public function testMySQLEncrypt() {
|
||||
if (!db_mysql()) {
|
||||
$this->markTestSkipped('Not using MySQL');
|
||||
}
|
||||
@ -49,8 +45,7 @@ class PaCryptTest extends \PHPUnit\Framework\TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testAuthlib()
|
||||
{
|
||||
public function testAuthlib() {
|
||||
global $CONF;
|
||||
|
||||
// too many options!
|
||||
@ -71,8 +66,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");
|
||||
@ -88,8 +82,7 @@ class PaCryptTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertEquals($expected_hash, _pacrypt_dovecot('test', $expected_hash));
|
||||
}
|
||||
|
||||
public function testPhpCrypt()
|
||||
{
|
||||
public function testPhpCrypt() {
|
||||
$config = Config::getInstance();
|
||||
Config::write('encrypt', 'php_crypt:MD5');
|
||||
|
||||
@ -103,11 +96,9 @@ class PaCryptTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertEquals($enc, $expected);
|
||||
|
||||
$fail = _pacrypt_php_crypt('bar', $expected);
|
||||
|
||||
}
|
||||
|
||||
public function testPhpCryptHandlesPrefixAndOrRounds()
|
||||
{
|
||||
public function testPhpCryptHandlesPrefixAndOrRounds() {
|
||||
// try with 1000 rounds
|
||||
Config::write('encrypt', 'php_crypt:SHA256:1000');
|
||||
$password = 'hello';
|
||||
@ -140,8 +131,7 @@ class PaCryptTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertGreaterThan(20, strlen($enc));
|
||||
}
|
||||
|
||||
public function testPhpCryptRandomString()
|
||||
{
|
||||
public function testPhpCryptRandomString() {
|
||||
$str1 = _php_crypt_random_string('abcdefg123456789', 2);
|
||||
$str2 = _php_crypt_random_string('abcdefg123456789', 2);
|
||||
$str3 = _php_crypt_random_string('abcdefg123456789', 2);
|
||||
@ -155,8 +145,7 @@ class PaCryptTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertFalse(strcmp($str1, $str2) == 0 && strcmp($str1, $str3) == 0);
|
||||
}
|
||||
|
||||
public function testSha512B64()
|
||||
{
|
||||
public function testSha512B64() {
|
||||
$str1 = _pacrypt_sha512_b64('test', '');
|
||||
$str2 = _pacrypt_sha512_b64('test', '');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user