Fix regression introduced with the optimization done in d641504. Cope with the fact that sometimes the admin account already exists, sometimes not.

This commit is contained in:
Romain Quetiez
2023-10-27 09:21:36 +02:00
parent fba668207f
commit 7e8589ba95

View File

@@ -48,11 +48,7 @@ class UserRightsTest extends ItopDataTestCase
{
parent::setUp();
try {
utils::GetConfig()->SetModuleSetting('authent-local', 'password_validation.pattern', '');
}
catch (CoreCannotSaveObjectException $e) {
}
utils::GetConfig()->SetModuleSetting('authent-local', 'password_validation.pattern', '');
}
public static $aClasses = [
@@ -102,6 +98,15 @@ class UserRightsTest extends ItopDataTestCase
public function testLogin($sLogin, $bResult)
{
$_SESSION = [];
if ($sLogin == 'admin') {
// Fixture data required in this case only
try {
self::CreateUser('admin', 1);
}
catch (CoreCannotSaveObjectException $e) {
// The admin account could exist, depending on where and when the test suite is executed
}
}
$this->assertEquals($bResult, UserRights::Login($sLogin));
$this->assertEquals($bResult, UserRights::IsLoggedIn());
UserRights::Logoff();