diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 780744b4c8e..aa9ca1285ed 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2109,7 +2109,7 @@ class User extends CommonObject * @param int $notrigger 1=Does not launch triggers * @param int $nosyncmember Do not synchronize linked member * @param int $passwordalreadycrypted 0=Value is cleartext password, 1=Value is crypted value. - * @return string If OK return clear password, 0 if no change, < 0 if error + * @return string If OK return clear password, 0 if no change (warning, you may retreive 1 instead of 0 even if password was same), < 0 if error */ public function setPassword($user, $password = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0, $passwordalreadycrypted = 0) { diff --git a/test/phpunit/UserTest.php b/test/phpunit/UserTest.php index de92c6e62f4..b8025a3cd41 100644 --- a/test/phpunit/UserTest.php +++ b/test/phpunit/UserTest.php @@ -290,7 +290,7 @@ class UserTest extends PHPUnit\Framework\TestCase $conf->global->USER_PASSWORD_GENERATED = 'standard'; $localobject->error = ''; - $result = $localobject->setPassword($user, '12345678901'); + $result = $localobject->setPassword($user, '123456789AA'); print __METHOD__." set a too small password with USER_PASSWORD_GENERATED = standard\n"; print __METHOD__." localobject->error=".$localobject->error."\n"; $this->assertEquals(-1, $result, 'We must receive a negative error code (pass too small) and we did not here'); @@ -301,7 +301,7 @@ class UserTest extends PHPUnit\Framework\TestCase $conf->global->USER_PASSWORD_PATTERN = '12;2;2;2;3;1'; $localobject->error = ''; - $result = $localobject->setPassword($user, '12345678901'); + $result = $localobject->setPassword($user, '1234567892BB'); print __METHOD__." set a too small password with USER_PASSWORD_GENERATED = perso\n"; print __METHOD__." localobject->error=".$localobject->error."\n"; $this->assertEquals(-1, $result, 'We must receive a negative error code (pass too small) and we did not here'); @@ -321,10 +321,10 @@ class UserTest extends PHPUnit\Framework\TestCase $this->assertEquals(-1, $result, 'We must receive a negative error code (pass without enough uppercase) and we did not here'); $localobject->error = ''; - $result = $localobject->setPassword($user, '$*34567890AB'); + $result = $localobject->setPassword($user, '$*34567890CD'); print __METHOD__." set a password with enough uppercase\n"; print __METHOD__." localobject->error=".$localobject->error."\n"; - $this->assertEquals('$*34567890AB', $result, 'We must get the password as it is valid (pass with enough uppercase) and we did not here'); + $this->assertEquals('$*34567890CD', $result, 'We must get the password as it is valid (pass with enough uppercase) and we did not here'); // Test digits : $chartofound = "!@#$%&*()_-+={}[]\\|:;'/";