mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-27 12:38:44 +02:00
Merge branch 'support/3.2' into develop
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Bruno DA SILVA, working for Combodo
|
||||
* Date: 21/11/2019
|
||||
@@ -7,7 +8,6 @@
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Module\AuthentLocal;
|
||||
|
||||
|
||||
use AttributeDate;
|
||||
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
||||
use Config;
|
||||
@@ -27,7 +27,6 @@ use utils;
|
||||
*/
|
||||
class UserLocalTest extends ItopDataTestCase
|
||||
{
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -52,17 +51,16 @@ class UserLocalTest extends ItopDataTestCase
|
||||
}
|
||||
|
||||
/** @var UserLocal $oUserLocal */
|
||||
$oUserLocal = MetaModel::NewObject(UserLocal::class, array('login' => 'john'));
|
||||
$oUserLocal = MetaModel::NewObject(UserLocal::class, ['login' => 'john']);
|
||||
/** @var ormLinkSet $oProfileSet */
|
||||
$oProfileSet = $oUserLocal->Get('profile_list');
|
||||
|
||||
$oProfileSet->AddItem(
|
||||
MetaModel::NewObject(URP_UserProfile::class, array('profileid' => 1))
|
||||
MetaModel::NewObject(URP_UserProfile::class, ['profileid' => 1])
|
||||
);
|
||||
|
||||
$aValidatorCollection = array();
|
||||
foreach ($aValidatorNames as $class)
|
||||
{
|
||||
$aValidatorCollection = [];
|
||||
foreach ($aValidatorNames as $class) {
|
||||
$aValidatorCollection[] = new $class();
|
||||
}
|
||||
|
||||
@@ -79,168 +77,167 @@ class UserLocalTest extends ItopDataTestCase
|
||||
|
||||
public function ProviderValidatePassword()
|
||||
{
|
||||
return array(
|
||||
'validPattern' => array(
|
||||
return [
|
||||
'validPattern' => [
|
||||
'password' => 'foo',
|
||||
'aValidatorCollection' => array(
|
||||
'aValidatorCollection' => [
|
||||
'UserPasswordPolicyRegex',
|
||||
),
|
||||
'valueMap' => array(
|
||||
array('authent-local', 'password_validation.pattern', null, '.{1,10}'),
|
||||
),
|
||||
],
|
||||
'valueMap' => [
|
||||
['authent-local', 'password_validation.pattern', null, '.{1,10}'],
|
||||
],
|
||||
'expectedCheckStatus' => true,
|
||||
),
|
||||
'notValidPattern' => array(
|
||||
],
|
||||
'notValidPattern' => [
|
||||
'password' => 'foo',
|
||||
'aValidatorCollection' => array(
|
||||
'aValidatorCollection' => [
|
||||
'UserPasswordPolicyRegex',
|
||||
),
|
||||
'valueMap' => array(
|
||||
array('authent-local', 'password_validation.pattern', null, '.{6,10}'),
|
||||
),
|
||||
],
|
||||
'valueMap' => [
|
||||
['authent-local', 'password_validation.pattern', null, '.{6,10}'],
|
||||
],
|
||||
'expectedCheckStatus' => false,
|
||||
),
|
||||
'noPattern' => array(
|
||||
],
|
||||
'noPattern' => [
|
||||
'password' => 'foo',
|
||||
'aValidatorCollection' => array(
|
||||
'aValidatorCollection' => [
|
||||
'UserPasswordPolicyRegex',
|
||||
),
|
||||
'valueMap' => array(
|
||||
array('authent-local', 'password_validation.pattern', null, '')
|
||||
),
|
||||
],
|
||||
'valueMap' => [
|
||||
['authent-local', 'password_validation.pattern', null, ''],
|
||||
],
|
||||
'expectedCheckStatus' => true,
|
||||
),
|
||||
'validClass' => array(
|
||||
],
|
||||
'validClass' => [
|
||||
'password' => 'foo',
|
||||
'aValidatorCollection' => array(
|
||||
'aValidatorCollection' => [
|
||||
'UserLocalPasswordPolicyMockValid',
|
||||
),
|
||||
'valueMap' => array(),
|
||||
],
|
||||
'valueMap' => [],
|
||||
'expectedCheckStatus' => true,
|
||||
),
|
||||
'notValidClass' => array(
|
||||
],
|
||||
'notValidClass' => [
|
||||
'password' => 'foo',
|
||||
'aValidatorCollection' => array(
|
||||
'aValidatorCollection' => [
|
||||
'UserLocalPasswordPolicyMockNotValid',
|
||||
),
|
||||
'valueMap' => array(),
|
||||
],
|
||||
'valueMap' => [],
|
||||
'expectedCheckStatus' => false,
|
||||
),
|
||||
],
|
||||
|
||||
'validation_composition_10' => array(
|
||||
'validation_composition_10' => [
|
||||
'password' => 'foo',
|
||||
'aValidatorCollection' => array(
|
||||
'aValidatorCollection' => [
|
||||
'UserLocalPasswordPolicyMockValid',
|
||||
'UserLocalPasswordPolicyMockNotValid',
|
||||
),
|
||||
'valueMap' => array(),
|
||||
],
|
||||
'valueMap' => [],
|
||||
'expectedCheckStatus' => false,
|
||||
'expectedCheckIssues' => 'UserLocalPasswordPolicyMockNotValid',
|
||||
),
|
||||
],
|
||||
|
||||
|
||||
'validation_composition_01' => array(
|
||||
'validation_composition_01' => [
|
||||
'password' => 'foo',
|
||||
'aValidatorCollection' => array(
|
||||
'aValidatorCollection' => [
|
||||
'UserLocalPasswordPolicyMockNotValid',
|
||||
'UserLocalPasswordPolicyMockValid',
|
||||
),
|
||||
'valueMap' => array(),
|
||||
],
|
||||
'valueMap' => [],
|
||||
'expectedCheckStatus' => false,
|
||||
'expectedCheckIssues' => 'UserLocalPasswordPolicyMockNotValid',
|
||||
),
|
||||
],
|
||||
|
||||
'validation_composition_11' => array(
|
||||
'validation_composition_11' => [
|
||||
'password' => 'foo',
|
||||
'aValidatorCollection' => array(
|
||||
'aValidatorCollection' => [
|
||||
'UserLocalPasswordPolicyMockValid',
|
||||
'UserLocalPasswordPolicyMockValidBis',
|
||||
),
|
||||
'valueMap' => array(),
|
||||
],
|
||||
'valueMap' => [],
|
||||
'expectedCheckStatus' => true,
|
||||
),
|
||||
'validation_composition_00' => array(
|
||||
],
|
||||
'validation_composition_00' => [
|
||||
'password' => 'foo',
|
||||
'aValidatorCollection' => array(
|
||||
'aValidatorCollection' => [
|
||||
'UserLocalPasswordPolicyMockNotValid',
|
||||
'UserLocalPasswordPolicyMockNotValidBis',
|
||||
),
|
||||
'valueMap' => array(),
|
||||
],
|
||||
'valueMap' => [],
|
||||
'expectedCheckStatus' => false,
|
||||
'expectedCheckIssues' => 'UserLocalPasswordPolicyMockNotValid',
|
||||
),
|
||||
],
|
||||
|
||||
'notValidPattern custom message FR' => array(
|
||||
'notValidPattern custom message FR' => [
|
||||
'password' => 'foo',
|
||||
'aValidatorCollection' => array(
|
||||
'aValidatorCollection' => [
|
||||
'UserPasswordPolicyRegex',
|
||||
),
|
||||
'valueMap' => array(
|
||||
array('authent-local', 'password_validation.pattern', null, '.{6,10}'),
|
||||
array('authent-local', 'password_validation.message', null, array('FR FR' => 'fr message', 'EN US' => 'en message')),
|
||||
],
|
||||
'valueMap' => [
|
||||
['authent-local', 'password_validation.pattern', null, '.{6,10}'],
|
||||
['authent-local', 'password_validation.message', null, ['FR FR' => 'fr message', 'EN US' => 'en message']],
|
||||
|
||||
),
|
||||
],
|
||||
'expectedCheckStatus' => false,
|
||||
'expectedCheckIssues' => 'fr message',
|
||||
'userLanguage' => 'FR FR',
|
||||
),
|
||||
'notValidPattern custom message EN' => array(
|
||||
],
|
||||
'notValidPattern custom message EN' => [
|
||||
'password' => 'foo',
|
||||
'aValidatorCollection' => array(
|
||||
'aValidatorCollection' => [
|
||||
'UserPasswordPolicyRegex',
|
||||
),
|
||||
'valueMap' => array(
|
||||
array('authent-local', 'password_validation.pattern', null, '.{6,10}'),
|
||||
array('authent-local', 'password_validation.message', null, array('FR FR' => 'fr message', 'EN US' => 'en message')),
|
||||
],
|
||||
'valueMap' => [
|
||||
['authent-local', 'password_validation.pattern', null, '.{6,10}'],
|
||||
['authent-local', 'password_validation.message', null, ['FR FR' => 'fr message', 'EN US' => 'en message']],
|
||||
|
||||
),
|
||||
],
|
||||
'expectedCheckStatus' => false,
|
||||
'expectedCheckIssues' => 'en message',
|
||||
'userLanguage' => 'EN US',
|
||||
),
|
||||
'notValidPattern custom message Fallback' => array(
|
||||
],
|
||||
'notValidPattern custom message Fallback' => [
|
||||
'password' => 'foo',
|
||||
'aValidatorCollection' => array(
|
||||
'aValidatorCollection' => [
|
||||
'UserPasswordPolicyRegex',
|
||||
),
|
||||
'valueMap' => array(
|
||||
array('authent-local', 'password_validation.pattern', null, '.{6,10}'),
|
||||
array('authent-local', 'password_validation.message', null, array('EN US' => 'en message')),
|
||||
],
|
||||
'valueMap' => [
|
||||
['authent-local', 'password_validation.pattern', null, '.{6,10}'],
|
||||
['authent-local', 'password_validation.message', null, ['EN US' => 'en message']],
|
||||
|
||||
),
|
||||
],
|
||||
'expectedCheckStatus' => false,
|
||||
'expectedCheckIssues' => 'en message',
|
||||
'userLanguage' => 'FR FR',
|
||||
),
|
||||
'notValidPattern custom message empty array' => array(
|
||||
],
|
||||
'notValidPattern custom message empty array' => [
|
||||
'password' => 'foo',
|
||||
'aValidatorCollection' => array(
|
||||
'aValidatorCollection' => [
|
||||
'UserPasswordPolicyRegex',
|
||||
),
|
||||
'valueMap' => array(
|
||||
array('authent-local', 'password_validation.pattern', null, '.{6,10}'),
|
||||
array('authent-local', 'password_validation.message', null, array()),
|
||||
],
|
||||
'valueMap' => [
|
||||
['authent-local', 'password_validation.pattern', null, '.{6,10}'],
|
||||
['authent-local', 'password_validation.message', null, []],
|
||||
|
||||
),
|
||||
],
|
||||
'expectedCheckStatus' => false,
|
||||
'expectedCheckIssues' => 'Password must be at least 8 characters and include uppercase, lowercase, numeric and special characters.',
|
||||
'userLanguage' => 'EN US',
|
||||
),
|
||||
'notValidPattern custom message string not array' => array(
|
||||
],
|
||||
'notValidPattern custom message string not array' => [
|
||||
'password' => 'foo',
|
||||
'aValidatorCollection' => array(
|
||||
'aValidatorCollection' => [
|
||||
'UserPasswordPolicyRegex',
|
||||
),
|
||||
'valueMap' => array(
|
||||
array('authent-local', 'password_validation.pattern', null, '.{6,10}'),
|
||||
array('authent-local', 'password_validation.message', null, 'not an array'),
|
||||
],
|
||||
'valueMap' => [
|
||||
['authent-local', 'password_validation.pattern', null, '.{6,10}'],
|
||||
['authent-local', 'password_validation.message', null, 'not an array'],
|
||||
|
||||
),
|
||||
],
|
||||
'expectedCheckStatus' => false,
|
||||
'expectedCheckIssues' => 'not an array',
|
||||
'userLanguage' => 'EN US',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -254,9 +251,8 @@ class UserLocalTest extends ItopDataTestCase
|
||||
$oNow = date($sDateFormat);
|
||||
$oExpectedAfter = is_null($sExpectedAfter) ? null : date($sDateFormat, strtotime($sExpectedAfter));
|
||||
|
||||
$aUserLocalValues = array('login' => 'john');
|
||||
if (!is_null($oBefore))
|
||||
{
|
||||
$aUserLocalValues = ['login' => 'john'];
|
||||
if (!is_null($oBefore)) {
|
||||
$aUserLocalValues['password_renewed_date'] = $oBefore;
|
||||
}
|
||||
|
||||
@@ -266,7 +262,7 @@ class UserLocalTest extends ItopDataTestCase
|
||||
$oProfileSet = $oUserLocal->Get('profile_list');
|
||||
|
||||
$oProfileSet->AddItem(
|
||||
MetaModel::NewObject(URP_UserProfile::class, array('profileid' => 1))
|
||||
MetaModel::NewObject(URP_UserProfile::class, ['profileid' => 1])
|
||||
);
|
||||
|
||||
$this->assertEquals($oBefore, $oUserLocal->Get('password_renewed_date'));
|
||||
@@ -298,20 +294,20 @@ class UserLocalTest extends ItopDataTestCase
|
||||
|
||||
public function ProviderPasswordRenewal()
|
||||
{
|
||||
return array(
|
||||
'nominal case' => array(
|
||||
return [
|
||||
'nominal case' => [
|
||||
'oExpectedBefore' => null,
|
||||
'oExpectedAfter' => 'now',
|
||||
),
|
||||
'date initiated' => array(
|
||||
],
|
||||
'date initiated' => [
|
||||
'oBefore' => '-1 day',
|
||||
'oExpectedAfter' => 'now',
|
||||
),
|
||||
'date initiated in the future' => array(
|
||||
],
|
||||
'date initiated in the future' => [
|
||||
'oBefore' => '+1 day',
|
||||
'oExpectedAfter' => 'now',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,9 +320,8 @@ class UserLocalTest extends ItopDataTestCase
|
||||
$oNow = date(AttributeDate::GetInternalFormat());
|
||||
$oExpectedAfter = $bRenewedDateTouched ? $oNow : $oBefore;
|
||||
|
||||
$aUserLocalValues = array('login' => 'john');
|
||||
if (!is_null($oBefore))
|
||||
{
|
||||
$aUserLocalValues = ['login' => 'john'];
|
||||
if (!is_null($oBefore)) {
|
||||
$aUserLocalValues['password_renewed_date'] = $oBefore;
|
||||
}
|
||||
|
||||
@@ -336,7 +331,7 @@ class UserLocalTest extends ItopDataTestCase
|
||||
$oProfileSet = $oUserLocal->Get('profile_list');
|
||||
|
||||
$oProfileSet->AddItem(
|
||||
MetaModel::NewObject(URP_UserProfile::class, array('profileid' => 1))
|
||||
MetaModel::NewObject(URP_UserProfile::class, ['profileid' => 1])
|
||||
);
|
||||
|
||||
$this->assertEquals($oBefore, $oUserLocal->Get('password_renewed_date'));
|
||||
@@ -360,38 +355,38 @@ class UserLocalTest extends ItopDataTestCase
|
||||
|
||||
public function CanExpireFixProvider()
|
||||
{
|
||||
return array(
|
||||
'EXPIRE_CAN: nominal case' => array(
|
||||
return [
|
||||
'EXPIRE_CAN: nominal case' => [
|
||||
'sExpirationMode' => 'can_expire',
|
||||
'oExpectedBefore' => null,
|
||||
'bRenewedDateTouched' => true,
|
||||
),
|
||||
'EXPIRE_NEVER (default mode): nothing changed on UserLocal' => array(
|
||||
],
|
||||
'EXPIRE_NEVER (default mode): nothing changed on UserLocal' => [
|
||||
'sExpirationMode' => 'never_expire',
|
||||
'oExpectedBefore' => null,
|
||||
'bRenewedDateTouched' => false,
|
||||
),
|
||||
'EXPIRE_FORCE: nominal case' => array(
|
||||
],
|
||||
'EXPIRE_FORCE: nominal case' => [
|
||||
'sExpirationMode' => 'force_expire',
|
||||
'oExpectedBefore' => null,
|
||||
'bRenewedDateTouched' => true,
|
||||
),
|
||||
'EXPIRE_ONE_TIME_PWD: nominal case' => array(
|
||||
],
|
||||
'EXPIRE_ONE_TIME_PWD: nominal case' => [
|
||||
'sExpirationMode' => 'otp_expire',
|
||||
'oExpectedBefore' => null,
|
||||
'bRenewedDateTouched' => true,
|
||||
),
|
||||
'date initiated' => array(
|
||||
],
|
||||
'date initiated' => [
|
||||
'sExpirationMode' => 'can_expire',
|
||||
'oBefore' => '-1 day',
|
||||
'bRenewedDateTouched' => false,
|
||||
),
|
||||
'date initiated in the future' => array(
|
||||
],
|
||||
'date initiated in the future' => [
|
||||
'sExpirationMode' => 'can_expire',
|
||||
'oBefore' => '+1 day',
|
||||
'bRenewedDateTouched' => false,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,4 +449,3 @@ class UserLocalTest extends ItopDataTestCase
|
||||
return $oUser->Get('profile_list');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
class UserLocalPasswordPolicyMockValid implements \UserLocalPasswordValidator
|
||||
{
|
||||
const CHECK_STATUS = true;
|
||||
const MESSAGE = null;
|
||||
public const CHECK_STATUS = true;
|
||||
public const MESSAGE = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -23,8 +24,8 @@ class UserLocalPasswordPolicyMockValid implements \UserLocalPasswordValidator
|
||||
|
||||
class UserLocalPasswordPolicyMockNotValid extends UserLocalPasswordPolicyMockValid
|
||||
{
|
||||
const CHECK_STATUS = false;
|
||||
const MESSAGE = 'UserLocalPasswordPolicyMockNotValid';
|
||||
public const CHECK_STATUS = false;
|
||||
public const MESSAGE = 'UserLocalPasswordPolicyMockNotValid';
|
||||
}
|
||||
|
||||
class UserLocalPasswordPolicyMockValidBis extends UserLocalPasswordPolicyMockValid
|
||||
@@ -33,5 +34,5 @@ class UserLocalPasswordPolicyMockValidBis extends UserLocalPasswordPolicyMockVal
|
||||
|
||||
class UserLocalPasswordPolicyMockNotValidBis extends UserLocalPasswordPolicyMockNotValid
|
||||
{
|
||||
const MESSAGE = 'UserLocalPasswordPolicyMockNotValidBis';
|
||||
}
|
||||
public const MESSAGE = 'UserLocalPasswordPolicyMockNotValidBis';
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Module\ItopAttachment;
|
||||
|
||||
use Combodo\iTop\Service\Events\EventData;
|
||||
@@ -13,7 +15,7 @@ class TestAttachment extends ItopDataTestCase
|
||||
{
|
||||
private string $sAddAttachmentName;
|
||||
private string $sRemoveAttachmentName;
|
||||
const CREATE_TEST_ORG = true;
|
||||
public const CREATE_TEST_ORG = true;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -12,10 +13,9 @@ use MetaModel;
|
||||
|
||||
class DBObjectTest extends ItopDataTestCase
|
||||
{
|
||||
const USE_TRANSACTION = true;
|
||||
const CREATE_TEST_ORG = true;
|
||||
const DEBUG_UNIT_TEST = false;
|
||||
|
||||
public const USE_TRANSACTION = true;
|
||||
public const CREATE_TEST_ORG = true;
|
||||
public const DEBUG_UNIT_TEST = false;
|
||||
|
||||
public function testReloadNotNecessaryForInsert()
|
||||
{
|
||||
@@ -170,8 +170,7 @@ class DBObjectTest extends ItopDataTestCase
|
||||
try {
|
||||
$oPerson->Set('email', 'test1@combodo.com');
|
||||
$this->assertTrue(false, 'Set() should have raised a CoreException');
|
||||
}
|
||||
catch (\CoreException $e) {
|
||||
} catch (\CoreException $e) {
|
||||
$this->assertEquals($sMessage, $e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2010-2024 Combodo SAS
|
||||
*
|
||||
@@ -36,8 +37,7 @@ class ConfigPlaceholdersResolverTest extends ItopTestCase
|
||||
*/
|
||||
public function testResolve($aEnv, $aServer, $sValue, $sExpected, $sExpectedExceptionClass = null)
|
||||
{
|
||||
if ($sExpectedExceptionClass)
|
||||
{
|
||||
if ($sExpectedExceptionClass) {
|
||||
$this->expectException($sExpectedExceptionClass);
|
||||
}
|
||||
|
||||
@@ -49,118 +49,118 @@ class ConfigPlaceholdersResolverTest extends ItopTestCase
|
||||
|
||||
public function providerResolve()
|
||||
{
|
||||
$stdObj = (object) array('%env(HTTP_PORT)?:8080%', '%server(toto)?:8080%', '%foo(toto)?:8080%');
|
||||
$stdObj = (object) ['%env(HTTP_PORT)?:8080%', '%server(toto)?:8080%', '%foo(toto)?:8080%'];
|
||||
|
||||
return array(
|
||||
'basic behaviour' => array(
|
||||
'aEnv' => array('ITOP_CONFIG_PLACEHOLDERS' => 1, 'HTTP_PORT' => '443'),
|
||||
'aServer' => array(),
|
||||
return [
|
||||
'basic behaviour' => [
|
||||
'aEnv' => ['ITOP_CONFIG_PLACEHOLDERS' => 1, 'HTTP_PORT' => '443'],
|
||||
'aServer' => [],
|
||||
'sValue' => '%env(HTTP_PORT)%',
|
||||
'sExpected' => '443',
|
||||
),
|
||||
],
|
||||
|
||||
'disabled if no ITOP_CONFIG_PLACEHOLDERS' => array(
|
||||
'aEnv' => array('HTTP_PORT' => '443'),
|
||||
'aServer' => array(),
|
||||
'disabled if no ITOP_CONFIG_PLACEHOLDERS' => [
|
||||
'aEnv' => ['HTTP_PORT' => '443'],
|
||||
'aServer' => [],
|
||||
'sValue' => '%env(HTTP_PORT)%',
|
||||
'sExpected' => '%env(HTTP_PORT)%',
|
||||
),
|
||||
],
|
||||
|
||||
'basic with default not used' => array(
|
||||
'aEnv' => array('ITOP_CONFIG_PLACEHOLDERS' => 1, 'HTTP_PORT' => '443'),
|
||||
'aServer' => array(),
|
||||
'basic with default not used' => [
|
||||
'aEnv' => ['ITOP_CONFIG_PLACEHOLDERS' => 1, 'HTTP_PORT' => '443'],
|
||||
'aServer' => [],
|
||||
'sValue' => '%env(HTTP_PORT)?:foo%',
|
||||
'sExpected' => '443',
|
||||
),
|
||||
],
|
||||
|
||||
'basic with default used' => array(
|
||||
'aEnv' => array('ITOP_CONFIG_PLACEHOLDERS' => 1, ),
|
||||
'aServer' => array(),
|
||||
'basic with default used' => [
|
||||
'aEnv' => ['ITOP_CONFIG_PLACEHOLDERS' => 1, ],
|
||||
'aServer' => [],
|
||||
'sValue' => '%env(HTTP_PORT)?:foo%',
|
||||
'sExpected' => 'foo',
|
||||
),
|
||||
],
|
||||
|
||||
'basic with default used and empty' => array(
|
||||
'aEnv' => array('ITOP_CONFIG_PLACEHOLDERS' => 1, ),
|
||||
'aServer' => array(),
|
||||
'basic with default used and empty' => [
|
||||
'aEnv' => ['ITOP_CONFIG_PLACEHOLDERS' => 1, ],
|
||||
'aServer' => [],
|
||||
'sValue' => '%env(HTTP_PORT)?:%',
|
||||
'sExpected' => '',
|
||||
),
|
||||
],
|
||||
|
||||
'mixed with static' => array(
|
||||
'aEnv' => array('ITOP_CONFIG_PLACEHOLDERS' => 1, 'HTTP_PORT' => '443'),
|
||||
'aServer' => array('toto' => 'tutu'),
|
||||
'mixed with static' => [
|
||||
'aEnv' => ['ITOP_CONFIG_PLACEHOLDERS' => 1, 'HTTP_PORT' => '443'],
|
||||
'aServer' => ['toto' => 'tutu'],
|
||||
'sValue' => 'http://localhost:%env(HTTP_PORT)?:8080%/',
|
||||
'sExpected' => 'http://localhost:443/',
|
||||
),
|
||||
],
|
||||
|
||||
'multiple occurrences' => array(
|
||||
'aEnv' => array('ITOP_CONFIG_PLACEHOLDERS' => 1, 'HTTP_PORT' => '443'),
|
||||
'aServer' => array('SERVER_NAME' => 'localhost'),
|
||||
'multiple occurrences' => [
|
||||
'aEnv' => ['ITOP_CONFIG_PLACEHOLDERS' => 1, 'HTTP_PORT' => '443'],
|
||||
'aServer' => ['SERVER_NAME' => 'localhost'],
|
||||
'sValue' => 'http://%server(SERVER_NAME)%:%env(HTTP_PORT)%/',
|
||||
'sExpected' => 'http://localhost:443/',
|
||||
),
|
||||
],
|
||||
|
||||
'array as source' => array(
|
||||
'aEnv' => array('ITOP_CONFIG_PLACEHOLDERS' => 1, 'HTTP_PORT' => '443'),
|
||||
'aServer' => array('toto' => 'tutu'),
|
||||
'sValue' => array('http://localhost:%env(HTTP_PORT)?:8080%/', '%foo(HTTP_PORT)?:8080%', '%server(toto)?:8080%'),
|
||||
'sExpected' => array('http://localhost:443/', '%foo(HTTP_PORT)?:8080%', 'tutu'),
|
||||
),
|
||||
'array as source' => [
|
||||
'aEnv' => ['ITOP_CONFIG_PLACEHOLDERS' => 1, 'HTTP_PORT' => '443'],
|
||||
'aServer' => ['toto' => 'tutu'],
|
||||
'sValue' => ['http://localhost:%env(HTTP_PORT)?:8080%/', '%foo(HTTP_PORT)?:8080%', '%server(toto)?:8080%'],
|
||||
'sExpected' => ['http://localhost:443/', '%foo(HTTP_PORT)?:8080%', 'tutu'],
|
||||
],
|
||||
|
||||
'invalid source' => array(
|
||||
'aEnv' => array('toto' => 'tutu'),
|
||||
'aServer' => array('HTTP_PORT' => '443'),
|
||||
'invalid source' => [
|
||||
'aEnv' => ['toto' => 'tutu'],
|
||||
'aServer' => ['HTTP_PORT' => '443'],
|
||||
'sValue' => '%foo(HTTP_PORT)?:8080%',
|
||||
'sExpected' => '%foo(HTTP_PORT)?:8080%',
|
||||
),
|
||||
],
|
||||
|
||||
'ignored source' => array(
|
||||
'aEnv' => array('ITOP_CONFIG_PLACEHOLDERS' => 1, 'HTTP_PORT' => '443'),
|
||||
'aServer' => array('toto' => 'tutu'),
|
||||
'ignored source' => [
|
||||
'aEnv' => ['ITOP_CONFIG_PLACEHOLDERS' => 1, 'HTTP_PORT' => '443'],
|
||||
'aServer' => ['toto' => 'tutu'],
|
||||
'sValue' => $stdObj,
|
||||
'sExpected' => $stdObj,
|
||||
),
|
||||
],
|
||||
|
||||
'env matching port' => array(
|
||||
'aEnv' => array('ITOP_CONFIG_PLACEHOLDERS' => 1, 'HTTP_PORT' => '443'),
|
||||
'aServer' => array('toto' => 'tutu'),
|
||||
'env matching port' => [
|
||||
'aEnv' => ['ITOP_CONFIG_PLACEHOLDERS' => 1, 'HTTP_PORT' => '443'],
|
||||
'aServer' => ['toto' => 'tutu'],
|
||||
'sValue' => '%env(HTTP_PORT)?:8080%',
|
||||
'sExpected' => '443',
|
||||
),
|
||||
'env no matching port with default ' => array(
|
||||
'aEnv' => array('ITOP_CONFIG_PLACEHOLDERS' => 1, 'foo' => 'bar'),
|
||||
'aServer' => array('toto' => 'tutu'),
|
||||
],
|
||||
'env no matching port with default ' => [
|
||||
'aEnv' => ['ITOP_CONFIG_PLACEHOLDERS' => 1, 'foo' => 'bar'],
|
||||
'aServer' => ['toto' => 'tutu'],
|
||||
'sValue' => '%env(HTTP_PORT)?:8080%',
|
||||
'sExpected' => '8080',
|
||||
),
|
||||
'env no matching port' => array(
|
||||
'aEnv' => array('ITOP_CONFIG_PLACEHOLDERS' => 1, 'foo' => 'bar'),
|
||||
'aServer' => array('toto' => 'tutu'),
|
||||
],
|
||||
'env no matching port' => [
|
||||
'aEnv' => ['ITOP_CONFIG_PLACEHOLDERS' => 1, 'foo' => 'bar'],
|
||||
'aServer' => ['toto' => 'tutu'],
|
||||
'sValue' => '%env(HTTP_PORT)%',
|
||||
'sExpected' => null,
|
||||
'sExpectedExceptionClass' => 'ConfigException',
|
||||
),
|
||||
],
|
||||
|
||||
'server matching port' => array(
|
||||
'aEnv' => array('ITOP_CONFIG_PLACEHOLDERS' => 1, 'toto' => 'tutu'),
|
||||
'aServer' => array('HTTP_PORT' => '443'),
|
||||
'server matching port' => [
|
||||
'aEnv' => ['ITOP_CONFIG_PLACEHOLDERS' => 1, 'toto' => 'tutu'],
|
||||
'aServer' => ['HTTP_PORT' => '443'],
|
||||
'sValue' => '%server(HTTP_PORT)?:8080%',
|
||||
'sExpected' => '443',
|
||||
),
|
||||
'server no matching port with default ' => array(
|
||||
'aEnv' => array('ITOP_CONFIG_PLACEHOLDERS' => 1, 'toto' => 'tutu'),
|
||||
'aServer' => array('foo' => 'bar'),
|
||||
],
|
||||
'server no matching port with default ' => [
|
||||
'aEnv' => ['ITOP_CONFIG_PLACEHOLDERS' => 1, 'toto' => 'tutu'],
|
||||
'aServer' => ['foo' => 'bar'],
|
||||
'sValue' => '%server(HTTP_PORT)?:8080%',
|
||||
'sExpected' => '8080',
|
||||
),
|
||||
'server no matching port' => array(
|
||||
'aEnv' => array('ITOP_CONFIG_PLACEHOLDERS' => 1, 'toto' => 'tutu'),
|
||||
'aServer' => array('foo' => 'bar'),
|
||||
],
|
||||
'server no matching port' => [
|
||||
'aEnv' => ['ITOP_CONFIG_PLACEHOLDERS' => 1, 'toto' => 'tutu'],
|
||||
'aServer' => ['foo' => 'bar'],
|
||||
'sValue' => '%server(HTTP_PORT)%',
|
||||
'sExpected' => null,
|
||||
'sExpectedExceptionClass' => 'ConfigException',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2010-2024 Combodo SAS
|
||||
*
|
||||
@@ -60,34 +61,34 @@ class ConfigTest extends ItopTestCase
|
||||
|
||||
public function ProviderPreserveVarOnWriteToFile()
|
||||
{
|
||||
return array(
|
||||
'preserve var' => array(
|
||||
return [
|
||||
'preserve var' => [
|
||||
'sConfigFile' => __DIR__.'/ConfigTest/config-itop-var.php',
|
||||
'sExpectedContains' => "'app_root_url' => 'http://' . (isset(\$_SERVER['SERVER_NAME']) ? \$_SERVER['SERVER_NAME'] : 'localhost') . '/itop/iTop/'",
|
||||
'aChanges' => array(),
|
||||
),
|
||||
'preserve joker' => array(
|
||||
'aChanges' => [],
|
||||
],
|
||||
'preserve joker' => [
|
||||
'sConfigFile' => __DIR__.'/ConfigTest/config-itop-joker.php',
|
||||
'sExpectedContains' => "'app_root_url' => 'http://%server(SERVER_NAME)?:localhost%/itop/iTop/'",
|
||||
'aChanges' => array(),
|
||||
),
|
||||
'aChanges' => [],
|
||||
],
|
||||
|
||||
'preserve set same value' => array(
|
||||
'preserve set same value' => [
|
||||
'sConfigFile' => __DIR__.'/ConfigTest/config-itop-var.php',
|
||||
'sExpectedContains' => "'app_root_url' => 'http://' . (isset(\$_SERVER['SERVER_NAME']) ? \$_SERVER['SERVER_NAME'] : 'localhost') . '/itop/iTop/'",
|
||||
'aChanges' => array('app_root_url' => 'http://localhost/itop/iTop/'),
|
||||
),
|
||||
'aChanges' => ['app_root_url' => 'http://localhost/itop/iTop/'],
|
||||
],
|
||||
|
||||
'overwrite var' => array(
|
||||
'overwrite var' => [
|
||||
'sConfigFile' => __DIR__.'/ConfigTest/config-itop-var.php',
|
||||
'sExpectedContains' => "'app_root_url' => 'foo",
|
||||
'aChanges' => array('app_root_url' => 'foo'),
|
||||
),
|
||||
'overwrite joker' => array(
|
||||
'aChanges' => ['app_root_url' => 'foo'],
|
||||
],
|
||||
'overwrite joker' => [
|
||||
'sConfigFile' => __DIR__.'/ConfigTest/config-itop-joker.php',
|
||||
'sExpectedContains' => "'app_root_url' => 'foo",
|
||||
'aChanges' => array('app_root_url' => 'foo'),
|
||||
),
|
||||
);
|
||||
'aChanges' => ['app_root_url' => 'foo'],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Bruno DA SILVA, working for Combodo
|
||||
* Date: 31/12/2019
|
||||
@@ -14,7 +15,6 @@ use PhpParser\PrettyPrinter\Standard;
|
||||
|
||||
class iTopConfigAstValidatorTest extends ItopTestCase
|
||||
{
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -23,7 +23,6 @@ class iTopConfigAstValidatorTest extends ItopTestCase
|
||||
$this->RequireOnceItopFile('env-production/itop-config/src/Validator/iTopConfigAstValidator.php');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @dataProvider InvalidDataProvider
|
||||
* @param $sConf
|
||||
@@ -34,10 +33,9 @@ class iTopConfigAstValidatorTest extends ItopTestCase
|
||||
{
|
||||
$oiTopConfigValidator = new iTopConfigAstValidator();
|
||||
$this->expectException(\Exception::class);
|
||||
try{
|
||||
try {
|
||||
$oiTopConfigValidator->Validate($sConf);
|
||||
}catch (\Exception $e)
|
||||
{
|
||||
} catch (\Exception $e) {
|
||||
$this->assertStringStartsWith('Invalid configuration:', $e->getMessage());
|
||||
throw $e;
|
||||
}
|
||||
@@ -45,29 +43,28 @@ class iTopConfigAstValidatorTest extends ItopTestCase
|
||||
|
||||
public function InvalidDataProvider()
|
||||
{
|
||||
return array(
|
||||
'invalid PHP' => array(
|
||||
'sConf' => '<?php fiction Method(){}'
|
||||
),
|
||||
'function call' => array(
|
||||
'sConf' => '<?php FunctionCall();'
|
||||
),
|
||||
'function declaration' => array(
|
||||
'sConf' => '<?php function foo() {};'
|
||||
),
|
||||
'class instantiation' => array(
|
||||
'sConf' => '<?php new Class {};'
|
||||
),
|
||||
'Class declaration' => array(
|
||||
'sConf' => '<?php class foo {};'
|
||||
),
|
||||
'echo' => array(
|
||||
'sConf' => '<?php echo "toto"; ?>'
|
||||
),
|
||||
);
|
||||
return [
|
||||
'invalid PHP' => [
|
||||
'sConf' => '<?php fiction Method(){}',
|
||||
],
|
||||
'function call' => [
|
||||
'sConf' => '<?php FunctionCall();',
|
||||
],
|
||||
'function declaration' => [
|
||||
'sConf' => '<?php function foo() {};',
|
||||
],
|
||||
'class instantiation' => [
|
||||
'sConf' => '<?php new Class {};',
|
||||
],
|
||||
'Class declaration' => [
|
||||
'sConf' => '<?php class foo {};',
|
||||
],
|
||||
'echo' => [
|
||||
'sConf' => '<?php echo "toto"; ?>',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @dataProvider ValidDataProvider
|
||||
* @doesNotPerformAssertions
|
||||
@@ -85,13 +82,13 @@ class iTopConfigAstValidatorTest extends ItopTestCase
|
||||
|
||||
public function ValidDataProvider()
|
||||
{
|
||||
return array(
|
||||
'simple code' => array(
|
||||
'sConf' => '<?php $var = array("toto"); ?>'
|
||||
),
|
||||
'class constant' => array(
|
||||
'sConf' => '<?php $var = array(foo::bar);'
|
||||
),
|
||||
);
|
||||
return [
|
||||
'simple code' => [
|
||||
'sConf' => '<?php $var = array("toto"); ?>',
|
||||
],
|
||||
'class constant' => [
|
||||
'sConf' => '<?php $var = array(foo::bar);',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Bruno DA SILVA, working for Combodo
|
||||
* Date: 31/12/2019
|
||||
@@ -15,7 +16,6 @@ use PhpParser\PrettyPrinter\Standard;
|
||||
|
||||
class iTopConfigSyntaxValidatorTest extends ItopTestCase
|
||||
{
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -24,7 +24,6 @@ class iTopConfigSyntaxValidatorTest extends ItopTestCase
|
||||
$this->RequireOnceItopFile('env-production/itop-config/src/Validator/iTopConfigSyntaxValidator.php');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
* @doesNotPerformAssertions
|
||||
@@ -40,7 +39,7 @@ class iTopConfigSyntaxValidatorTest extends ItopTestCase
|
||||
$oiTopConfigValidator = new iTopConfigSyntaxValidator();
|
||||
|
||||
$this->expectException(\Exception::class);
|
||||
try{
|
||||
try {
|
||||
$oiTopConfigValidator->Validate("<?php \n zef;zefzef \n zdadz = azdazd \n zerfgzaezerfgzef>");
|
||||
} catch (\Exception $e) {
|
||||
if (version_compare(phpversion(), '8.0.0', '<')) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Module\LaunchTest;
|
||||
@@ -8,38 +9,38 @@ use TokenValidation;
|
||||
|
||||
class TokenValidationTest extends ItopDataTestCase
|
||||
{
|
||||
/**
|
||||
* @param string $sSetupToken
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function createSetupTokenFile(string $sSetupToken): string
|
||||
{
|
||||
$sSetupTokenFile = APPROOT . 'data/.setup';
|
||||
file_put_contents($sSetupTokenFile, $sSetupToken);
|
||||
/**
|
||||
* @param string $sSetupToken
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function createSetupTokenFile(string $sSetupToken): string
|
||||
{
|
||||
$sSetupTokenFile = APPROOT.'data/.setup';
|
||||
file_put_contents($sSetupTokenFile, $sSetupToken);
|
||||
|
||||
return $sSetupTokenFile;
|
||||
}
|
||||
return $sSetupTokenFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @group itop-community
|
||||
* @return void
|
||||
*/
|
||||
public function testLaunch()
|
||||
{
|
||||
$this->RequireOnceItopFile('datamodels/2.x/itop-hub-connector/TokenValidation.php');
|
||||
/**
|
||||
* @group itop-community
|
||||
* @return void
|
||||
*/
|
||||
public function testLaunch()
|
||||
{
|
||||
$this->RequireOnceItopFile('datamodels/2.x/itop-hub-connector/TokenValidation.php');
|
||||
|
||||
$oTokenValidation = new TokenValidation();
|
||||
$oTokenValidation = new TokenValidation();
|
||||
|
||||
$sSetupToken = bin2hex(random_bytes(12));
|
||||
$this->assertFalse($oTokenValidation->isSetupTokenValid('lol'));
|
||||
$this->assertFalse($oTokenValidation->isSetupTokenValid(''));
|
||||
$this->assertFalse($oTokenValidation->isSetupTokenValid($sSetupToken));
|
||||
$this->createSetupTokenFile($sSetupToken);
|
||||
$this->assertFalse($oTokenValidation->isSetupTokenValid('lol'));
|
||||
$this->createSetupTokenFile($sSetupToken);
|
||||
$this->assertFalse($oTokenValidation->isSetupTokenValid(''));
|
||||
$this->createSetupTokenFile($sSetupToken);
|
||||
$this->assertTrue($oTokenValidation->isSetupTokenValid($sSetupToken));
|
||||
}
|
||||
$sSetupToken = bin2hex(random_bytes(12));
|
||||
$this->assertFalse($oTokenValidation->isSetupTokenValid('lol'));
|
||||
$this->assertFalse($oTokenValidation->isSetupTokenValid(''));
|
||||
$this->assertFalse($oTokenValidation->isSetupTokenValid($sSetupToken));
|
||||
$this->createSetupTokenFile($sSetupToken);
|
||||
$this->assertFalse($oTokenValidation->isSetupTokenValid('lol'));
|
||||
$this->createSetupTokenFile($sSetupToken);
|
||||
$this->assertFalse($oTokenValidation->isSetupTokenValid(''));
|
||||
$this->createSetupTokenFile($sSetupToken);
|
||||
$this->assertTrue($oTokenValidation->isSetupTokenValid($sSetupToken));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Module\iTopPortalBase;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2010-2024 Combodo SAS
|
||||
*
|
||||
@@ -30,7 +31,7 @@ use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
||||
*/
|
||||
class ApplicationHelperTest extends ItopDataTestCase
|
||||
{
|
||||
const PASSWORD = "aBCDEFG@123456789";
|
||||
public const PASSWORD = "aBCDEFG@123456789";
|
||||
|
||||
protected function LoadRequiredItopFiles(): void
|
||||
{
|
||||
@@ -64,7 +65,7 @@ class ApplicationHelperTest extends ItopDataTestCase
|
||||
->willReturn("Administrator");
|
||||
|
||||
$_SESSION = [];
|
||||
$oUser = $this->CreateContactlessUser("$sAssociatedProfileName-" . uniqid(), self::$aURP_Profiles[$sAssociatedProfileName], self::PASSWORD);
|
||||
$oUser = $this->CreateContactlessUser("$sAssociatedProfileName-".uniqid(), self::$aURP_Profiles[$sAssociatedProfileName], self::PASSWORD);
|
||||
\UserRights::Login($oUser->Get('login'));
|
||||
|
||||
$this->InvokeNonPublicStaticMethod(ApplicationHelper::class, 'LoadBrickSecurity', [$oBrick]);
|
||||
@@ -85,11 +86,10 @@ class ApplicationHelperTest extends ItopDataTestCase
|
||||
->willReturn("Administrator");
|
||||
|
||||
$_SESSION = [];
|
||||
$oUser = $this->CreateContactlessUser("$sAssociatedProfileName-" . uniqid(), self::$aURP_Profiles[$sAssociatedProfileName], self::PASSWORD);
|
||||
$oUser = $this->CreateContactlessUser("$sAssociatedProfileName-".uniqid(), self::$aURP_Profiles[$sAssociatedProfileName], self::PASSWORD);
|
||||
\UserRights::Login($oUser->Get('login'));
|
||||
|
||||
$this->InvokeNonPublicStaticMethod(ApplicationHelper::class, 'LoadBrickSecurity', [$oBrick]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2010-2024 Combodo SAS
|
||||
*
|
||||
@@ -32,7 +33,6 @@ use Symfony\Component\HttpFoundation\RequestStack;
|
||||
*/
|
||||
class RequestManipulatorTest extends ItopDataTestCase
|
||||
{
|
||||
|
||||
protected function LoadRequiredItopFiles(): void
|
||||
{
|
||||
parent::LoadRequiredItopFiles();
|
||||
@@ -53,7 +53,7 @@ class RequestManipulatorTest extends ItopDataTestCase
|
||||
$oRequestManipulatorHelper = new RequestManipulatorHelper($oRequestStack);
|
||||
|
||||
// I - default null value
|
||||
$oNullArrayValue = $oRequestManipulatorHelper->ReadParam('null_array_value', null, FILTER_UNSAFE_RAW, FILTER_REQUIRE_ARRAY);
|
||||
$oNullArrayValue = $oRequestManipulatorHelper->ReadParam('null_array_value', null, FILTER_UNSAFE_RAW, FILTER_REQUIRE_ARRAY);
|
||||
$this->assertNull($oNullArrayValue);
|
||||
|
||||
// II - default empty array value
|
||||
@@ -69,5 +69,4 @@ class RequestManipulatorTest extends ItopDataTestCase
|
||||
$this->assertEquals($aValue, $aReadValue);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// Copyright (c) 2010-2024 Combodo SAS
|
||||
//
|
||||
// This file is part of iTop.
|
||||
@@ -25,7 +26,6 @@ use MetaModel;
|
||||
use Organization;
|
||||
use UserRights;
|
||||
|
||||
|
||||
/**
|
||||
* @group itopVirtualizationMgmt
|
||||
* @group itopConfigMgmt
|
||||
@@ -33,7 +33,7 @@ use UserRights;
|
||||
*/
|
||||
class UpdateImpactedItemsTest extends ItopDataTestCase
|
||||
{
|
||||
const CREATE_TEST_ORG = true;
|
||||
public const CREATE_TEST_ORG = true;
|
||||
/**
|
||||
* @var Object Names to Ids
|
||||
*/
|
||||
@@ -63,7 +63,7 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
|
||||
Server_1 <-> Person_1
|
||||
EOF);
|
||||
$oTicket = $this->GivenTicketWithCIsOrPersons([
|
||||
'Server_1' => 'manual'
|
||||
'Server_1' => 'manual',
|
||||
]);
|
||||
|
||||
$oTicket->UpdateImpactedItems(); // impact analysis
|
||||
@@ -71,7 +71,7 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
|
||||
$this->assertCIsOrPersonsListEquals($oTicket, [
|
||||
'Server_1' => 'manual',
|
||||
'Hypervisor_1' => 'computed',
|
||||
'Test Person_1' => 'computed'
|
||||
'Test Person_1' => 'computed',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
|
||||
Hypervisor_1 -> Server_1
|
||||
EOF);
|
||||
$oTicket = $this->GivenTicketWithCIsOrPersons([
|
||||
'Hypervisor_1' => 'manual'
|
||||
'Hypervisor_1' => 'manual',
|
||||
]);
|
||||
|
||||
$oTicket->UpdateImpactedItems(); // impact analysis
|
||||
@@ -106,7 +106,7 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
|
||||
Farm_1 <-> Person_1
|
||||
EOF);
|
||||
$oTicket = $this->GivenTicketWithCIsOrPersons([
|
||||
'Server_1' => 'manual'
|
||||
'Server_1' => 'manual',
|
||||
]);
|
||||
|
||||
$oTicket->UpdateImpactedItems(); // impact analysis
|
||||
@@ -115,7 +115,7 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
|
||||
'Server_1' => 'manual',
|
||||
'Hypervisor_1' => 'computed',
|
||||
'Farm_1' => 'computed',
|
||||
'Test Person_1' => 'computed'
|
||||
'Test Person_1' => 'computed',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
|
||||
EOF);
|
||||
$this->GivenCINotAllowedToCurrentUser('Hypervisor_1');
|
||||
$oTicket = $this->GivenTicketWithCIsOrPersons([
|
||||
'Server_1' => 'manual'
|
||||
'Server_1' => 'manual',
|
||||
]);
|
||||
|
||||
MetaModel::GetConfig()->Set('relations.complete_analysis', false);
|
||||
@@ -193,7 +193,7 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
|
||||
EOF);
|
||||
$this->GivenCINotAllowedToCurrentUser('Hypervisor_1');
|
||||
$oTicket = $this->GivenTicketWithCIsOrPersons([
|
||||
'Server_1' => 'manual'
|
||||
'Server_1' => 'manual',
|
||||
]);
|
||||
|
||||
MetaModel::GetConfig()->Set('relations.complete_analysis', true);
|
||||
@@ -254,7 +254,7 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
|
||||
'Hypervisor_1' => 'manual',
|
||||
'Hypervisor_2' => 'manual',
|
||||
'Farm_1' => 'computed',
|
||||
'Test Person_1' => 'computed'
|
||||
'Test Person_1' => 'computed',
|
||||
]);
|
||||
}
|
||||
public function testPreviouslyComputedNodesShouldBeIgnored()
|
||||
@@ -272,7 +272,7 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
|
||||
$oTicket = $this->GivenTicketWithCIsOrPersons([
|
||||
'Server_1' => 'manual',
|
||||
'Server_2' => 'computed',
|
||||
'Person_2' => 'computed'
|
||||
'Person_2' => 'computed',
|
||||
]);
|
||||
|
||||
$oTicket->UpdateImpactedItems(); // impact analysis
|
||||
@@ -280,7 +280,7 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
|
||||
$this->assertCIsOrPersonsListEquals($oTicket, [
|
||||
'Server_1' => 'manual',
|
||||
'Hypervisor_1' => 'computed',
|
||||
'Test Person_1' => 'computed'
|
||||
'Test Person_1' => 'computed',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
|
||||
EOF);
|
||||
$oTicket = $this->GivenTicketWithCIsOrPersons([
|
||||
'Hypervisor_1' => 'computed',
|
||||
'Person_1' => 'computed'
|
||||
'Person_1' => 'computed',
|
||||
]);
|
||||
|
||||
$oTicket->UpdateImpactedItems(); // impact analysis
|
||||
@@ -303,7 +303,6 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
|
||||
$this->assertCIsOrPersonsListEquals($oTicket, []);
|
||||
}
|
||||
|
||||
|
||||
public function testNoImpactWhenNoCI()
|
||||
{
|
||||
$oTicket = $this->GivenTicketWithCIsOrPersons([]);
|
||||
@@ -325,13 +324,13 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
|
||||
Hypervisor_2 -> Farm_1
|
||||
DOT);
|
||||
$oTicket = $this->GivenTicketWithCIsOrPersons([
|
||||
'Hypervisor_1' => 'manual'
|
||||
'Hypervisor_1' => 'manual',
|
||||
]);
|
||||
|
||||
$oTicket->UpdateImpactedItems(); // impact analysis
|
||||
|
||||
$this->assertCIsOrPersonsListEquals($oTicket, [
|
||||
'Hypervisor_1' => 'manual'
|
||||
'Hypervisor_1' => 'manual',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -348,7 +347,7 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
|
||||
DOT);
|
||||
$oTicket = $this->GivenTicketWithCIsOrPersons([
|
||||
'Hypervisor_1' => 'manual',
|
||||
'Hypervisor_2' => 'manual'
|
||||
'Hypervisor_2' => 'manual',
|
||||
]);
|
||||
|
||||
$oTicket->UpdateImpactedItems(); // impact analysis
|
||||
@@ -356,7 +355,7 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
|
||||
$this->assertCIsOrPersonsListEquals($oTicket, [
|
||||
'Hypervisor_1' => 'manual',
|
||||
'Hypervisor_2' => 'manual',
|
||||
'Farm_1' => 'computed'
|
||||
'Farm_1' => 'computed',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -373,7 +372,7 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
|
||||
$oTicket = $this->GivenTicketWithCIsOrPersons([
|
||||
'Server_1' => 'manual',
|
||||
'Hypervisor_1' => 'not_impacted',
|
||||
'Person_1' => 'do_not_notify'
|
||||
'Person_1' => 'do_not_notify',
|
||||
]);
|
||||
|
||||
$oTicket->UpdateImpactedItems(); // impact analysis
|
||||
@@ -381,7 +380,7 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
|
||||
$this->assertCIsOrPersonsListEquals($oTicket, [
|
||||
'Server_1' => 'manual',
|
||||
'Hypervisor_1' => 'not_impacted',
|
||||
'Test Person_1' => 'do_not_notify'
|
||||
'Test Person_1' => 'do_not_notify',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -395,14 +394,14 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
|
||||
DOT);
|
||||
$oTicket = $this->GivenTicketWithCIsOrPersons([
|
||||
'Hypervisor_1' => 'not_impacted',
|
||||
'Person_1' => 'do_not_notify'
|
||||
'Person_1' => 'do_not_notify',
|
||||
]);
|
||||
|
||||
$oTicket->UpdateImpactedItems(); // impact analysis
|
||||
|
||||
$this->assertCIsOrPersonsListEquals($oTicket, [
|
||||
'Hypervisor_1' => 'not_impacted',
|
||||
'Test Person_1' => 'do_not_notify'
|
||||
'Test Person_1' => 'do_not_notify',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -459,7 +458,6 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
|
||||
$this->assertEquals($aExpected, $aActual, 'Unexpected value for functionalcis_list');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int|string|null $sTicketId
|
||||
*
|
||||
@@ -541,7 +539,7 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
|
||||
return $this->aCIs[$sDescriptor];
|
||||
}
|
||||
|
||||
private function GivenTicketWithCIsOrPersons(array $aLinkedObjects) : \UserRequest
|
||||
private function GivenTicketWithCIsOrPersons(array $aLinkedObjects): \UserRequest
|
||||
{
|
||||
$oTicket = $this->GivenTicketObject(1);
|
||||
foreach ($aLinkedObjects as $sObjectDescriptor => $sRole) {
|
||||
|
||||
Reference in New Issue
Block a user