N°9723 - IsActionAllowed should work with non instantiated users objects (#947)

* Replace references to user objects keys since objects can be non-instantiated (so no key available) and replace them by equivalent code

* Rename test + use self variable for profile

---------

Co-authored-by: jf-cbd <jf-cbd@users.noreply.github.com>
This commit is contained in:
jf-cbd
2026-06-25 17:45:43 +02:00
committed by GitHub
parent f09a73c45a
commit 7fca6424ab
2 changed files with 64 additions and 29 deletions

View File

@@ -81,6 +81,17 @@ class UserRightsTest extends ItopDataTestCase
return $oUser;
}
public function testIsActionAllowedWithNonInstantiatedUserObject()
{
$oUser = $this->GivenUserWithProfiles('test1', [self::$aURP_Profiles['Configuration Manager']]); // not a readonly profile
$oAdminUser = $this->GivenUserWithProfiles('test2', [self::$aURP_Profiles['Administrator']]);
$oAdminUser->DBInsert();
$_SESSION = [];
UserRights::Login($oAdminUser->Get('login'));
self::assertTrue(UserRights::IsActionAllowed('Server', UR_ACTION_MODIFY, null, $oUser) === UR_ALLOWED_YES);
}
/**
* @param array $aProfileIds
* @param array $aShouldBeAllowedToSeeClass