N°6458 Security hardening

This commit is contained in:
Pierre Goiffon
2023-11-15 10:31:00 +01:00
parent 77409eed99
commit 5a43448644
14 changed files with 504 additions and 41 deletions

View File

@@ -15,7 +15,6 @@ namespace Combodo\iTop\Test\UnitTest;
use ArchivedObjectException;
use CMDBSource;
use Config;
use Contact;
use DBObject;
use DBObjectSet;
@@ -30,7 +29,6 @@ use lnkFunctionalCIToTicket;
use MetaModel;
use Person;
use Server;
use SetupUtils;
use TagSetFieldData;
use Ticket;
use URP_UserProfile;
@@ -479,6 +477,35 @@ abstract class ItopDataTestCase extends ItopTestCase
return $oUser;
}
/**
* @param string $sLogin
* @param int $iProfileId
*
* @return \UserLocal
* @throws Exception
*/
protected function CreateContactlessUser($sLogin, $iProfileId, $sPassword = null)
{
if (empty($sPassword)) {
$sPassword = $sLogin;
}
$oUserProfile = new URP_UserProfile();
$oUserProfile->Set('profileid', $iProfileId);
$oUserProfile->Set('reason', 'UNIT Tests');
$oSet = DBObjectSet::FromObject($oUserProfile);
/** @var \UserLocal $oUser */
$oUser = $this->createObject('UserLocal', array(
'login' => $sLogin,
'password' => $sPassword,
'language' => 'EN US',
'profile_list' => $oSet,
));
$this->debug("Created {$oUser->GetName()} ({$oUser->GetKey()})");
return $oUser;
}
/**
* @param \DBObject $oUser
* @param int $iProfileId
@@ -658,7 +685,7 @@ abstract class ItopDataTestCase extends ItopTestCase
* @return array
* @throws Exception
*/
protected function AddCIToTicket($oCI, $oTicket, $sImpactCode)
protected function AddCIToTicket($oCI, $oTicket, $sImpactCode = 'manual')
{
$oNewLink = new lnkFunctionalCIToTicket();
$oNewLink->Set('functionalci_id', $oCI->GetKey());