diff --git a/tests/php-unit-tests/unitary-tests/core/Delta/delta_test_sanitize_output.xml b/tests/php-unit-tests/unitary-tests/core/Delta/delta_test_sanitize_output.xml index 798f5f8a0..4c475c9e7 100644 --- a/tests/php-unit-tests/unitary-tests/core/Delta/delta_test_sanitize_output.xml +++ b/tests/php-unit-tests/unitary-tests/core/Delta/delta_test_sanitize_output.xml @@ -1,116 +1,116 @@ - - - cmdbAbstractObject - - bizmodel - false - autoincrement - test_server - id - - - - - - lnkContactTestToServer - test_server_id - contact_test_id - true - - - PasswordTest - server_test_id - true - - - name - - false - - - + + + cmdbAbstractObject + + bizmodel + false + autoincrement + test_server + id + + + + + + lnkContactTestToServer + test_server_id + contact_test_id + true + + + PasswordTest + server_test_id + true + + + name + + false + + + - - cmdbAbstractObject - - bizmodel - false - autoincrement - contact_test - id - - - - - - password - - - lnkContactTestToServer - contact_test_id - test_server_id - true - - - + + cmdbAbstractObject + + bizmodel + false + autoincrement + contact_test + id + + + + + + password + + + lnkContactTestToServer + contact_test_id + test_server_id + true + + + - - cmdbAbstractObject - - bizmodel - false - autoincrement - lnk_contact_server_test - id - - - - - - contact_test_id - password - - - TestServer - DEL_MANUAL - test_server - false + + cmdbAbstractObject + + bizmodel + false + autoincrement + lnk_contact_server_test + id + + + + + + contact_test_id + password + + + TestServer + DEL_MANUAL + test_server + false - - - ContactTest - DEL_MANUAL - contact_test - false + + + ContactTest + DEL_MANUAL + contact_test + false - - - - - cmdbAbstractObject - - bizmodel - false - autoincrement - password_test - id - - - - - - TestServer - server_test_id - DEL_MANUAL - - - password - - - - + + + + + cmdbAbstractObject + + bizmodel + false + autoincrement + password_test + id + + + + + + TestServer + server_test_id + DEL_MANUAL + + + password + + + + \ No newline at end of file diff --git a/tests/php-unit-tests/unitary-tests/core/RestServicesSanitizeOutputTest.php b/tests/php-unit-tests/unitary-tests/core/RestServicesSanitizeOutputTest.php index 806ad234f..199eeb4bf 100644 --- a/tests/php-unit-tests/unitary-tests/core/RestServicesSanitizeOutputTest.php +++ b/tests/php-unit-tests/unitary-tests/core/RestServicesSanitizeOutputTest.php @@ -21,144 +21,149 @@ use RestResultWithObjects; */ class RestServicesSanitizeOutputTest extends ItopCustomDatamodelTestCase { - private const SIMPLE_PASSWORD = '123456'; + private const SIMPLE_PASSWORD = '123456'; - /** - * @throws Exception - */ - protected function setUp(): void - { - parent::setUp(); - // Workaround to cope with inconsistent settings in itop-config files from the CI - AttributeEncryptedString::$sKey = '6eb9d9afa3ee0fbcebe622a33bf57aaeafb7c37998fd24c403c2522c2d60117f'; - } + /** + * @throws Exception + */ + protected function setUp(): void + { + parent::setUp(); + // Workaround to cope with inconsistent settings in itop-config files from the CI + AttributeEncryptedString::$sKey = '6eb9d9afa3ee0fbcebe622a33bf57aaeafb7c37998fd24c403c2522c2d60117f'; + } - /** - * @return void - * @throws CoreException - */ - public function testSanitizeAttributeOnRequestedObject() - { - $oContactTest = MetaModel::NewObject('ContactTest', [ - 'password' => self::SIMPLE_PASSWORD] - ); - $oRestResultWithObject = new RestResultWithObjects(); - $oRestResultWithObject->AddObject(0, 'ok', $oContactTest, ['ContactTest' => ['password']]); - $oRestResultWithObject->SanitizeContent(); - static::assertEquals( - '{"objects":{"ContactTest::-1":{"code":0,"message":"ok","class":"ContactTest","key":-1,"fields":{"password":"*****"}}},"code":0,"message":null}', - json_encode($oRestResultWithObject)); - } + /** + * @return void + * @throws CoreException + */ + public function testSanitizeAttributeOnRequestedObject() + { + $oContactTest = MetaModel::NewObject('ContactTest', [ + 'password' => self::SIMPLE_PASSWORD + ] + ); + $oRestResultWithObject = new RestResultWithObjects(); + $oRestResultWithObject->AddObject(0, 'ok', $oContactTest, ['ContactTest' => ['password']]); + $oRestResultWithObject->SanitizeContent(); + static::assertEquals( + '{"objects":{"ContactTest::-1":{"code":0,"message":"ok","class":"ContactTest","key":-1,"fields":{"password":"*****"}}},"code":0,"message":null}', + json_encode($oRestResultWithObject)); + } - /** - * @return void - * @throws Exception - */ - public function testSanitizeAttributeExternalFieldOnLink() - { - $oContactTest = $this->createObject('ContactTest', [ - 'password' => self::SIMPLE_PASSWORD] - ); + /** + * @return void + * @throws Exception + */ + public function testSanitizeAttributeExternalFieldOnLink() + { + $oContactTest = $this->createObject('ContactTest', [ + 'password' => self::SIMPLE_PASSWORD + ] + ); - $oTestServer = $this->createObject('TestServer', [ - 'name' => 'test_server', - ]); + $oTestServer = $this->createObject('TestServer', [ + 'name' => 'test_server', + ]); - // create lnkContactTestToServer - $oLnkContactTestToServer = $this->createObject('lnkContactTestToServer', [ - 'contact_test_id' => $oContactTest->GetKey(), - 'test_server_id' => $oTestServer->GetKey() - ]); + // create lnkContactTestToServer + $oLnkContactTestToServer = $this->createObject('lnkContactTestToServer', [ + 'contact_test_id' => $oContactTest->GetKey(), + 'test_server_id' => $oTestServer->GetKey() + ]); - $oRestResultWithObject = new RestResultWithObjects(); - $oRestResultWithObject->AddObject(0, 'ok', $oLnkContactTestToServer, - ['lnkContactTestToServer' => ['contact_test_password']]); + $oRestResultWithObject = new RestResultWithObjects(); + $oRestResultWithObject->AddObject(0, 'ok', $oLnkContactTestToServer, + ['lnkContactTestToServer' => ['contact_test_password']]); - $oRestResultWithObject->SanitizeContent(); + $oRestResultWithObject->SanitizeContent(); - static::assertContains( - '*****', - json_encode($oRestResultWithObject)); + static::assertStringContainsString( + '*****', + json_encode($oRestResultWithObject)); - static::assertNotContains( - self::SIMPLE_PASSWORD, - json_encode($oRestResultWithObject)); - } + static::assertStringNotContainsString( + self::SIMPLE_PASSWORD, + json_encode($oRestResultWithObject)); + } - /** - * @throws Exception - */ - public function testSanitizeAttributeOnObjectRelatedThroughNNRelation() - { - $oContactTest = $this->createObject('ContactTest', [ - 'password' => self::SIMPLE_PASSWORD]); + /** + * @throws Exception + */ + public function testSanitizeAttributeOnObjectRelatedThroughNNRelation() + { + $oContactTest = $this->createObject('ContactTest', [ + 'password' => self::SIMPLE_PASSWORD + ]); - $oTestServer = $this->createObject('TestServer', [ - 'name' => 'test_server', - ]); + $oTestServer = $this->createObject('TestServer', [ + 'name' => 'test_server', + ]); - // create lnkContactTestToServer - $this->createObject('lnkContactTestToServer', [ - 'contact_test_id' => $oContactTest->GetKey(), - 'test_server_id' => $oTestServer->GetKey() - ]); + // create lnkContactTestToServer + $this->createObject('lnkContactTestToServer', [ + 'contact_test_id' => $oContactTest->GetKey(), + 'test_server_id' => $oTestServer->GetKey() + ]); - $oRestResultWithObject = new RestResultWithObjects(); - $oRestResultWithObject->AddObject(0, 'ok', $oTestServer, - ['TestServer' => ['contact_list']]); + $oTestServer->Reload(); - $oRestResultWithObject->SanitizeContent(); - static::assertContains( - '*****', - json_encode($oRestResultWithObject)); + $oRestResultWithObject = new RestResultWithObjects(); + $oRestResultWithObject->AddObject(0, 'ok', $oTestServer, + ['TestServer' => ['contact_list']]); - static::assertNotContains( - self::SIMPLE_PASSWORD, - json_encode($oRestResultWithObject)); - } + $oRestResultWithObject->SanitizeContent(); + static::assertStringContainsString( + '*****', + json_encode($oRestResultWithObject)); + + static::assertStringNotContainsString( + self::SIMPLE_PASSWORD, + json_encode($oRestResultWithObject)); + } - /** - * @throws CoreException - * @throws CoreUnexpectedValue - * @throws ArchivedObjectException - * @throws Exception - */ - public function testSanitizeOnObjectRelatedThrough1NRelation() - { - $oTestServer = $this->createObject('TestServer', [ - 'name' => 'my_server', - ]); + /** + * @throws CoreException + * @throws CoreUnexpectedValue + * @throws ArchivedObjectException + * @throws Exception + */ + public function testSanitizeOnObjectRelatedThrough1NRelation() + { + $oTestServer = $this->createObject('TestServer', [ + 'name' => 'my_server', + ]); - $oPassword = new PasswordTest(); - $oPassword->Set('password', self::SIMPLE_PASSWORD); - $oPassword->Set('server_test_id', $oTestServer->GetKey()); + $oPassword = new PasswordTest(); + $oPassword->Set('password', self::SIMPLE_PASSWORD); + $oPassword->Set('server_test_id', $oTestServer->GetKey()); - /** @var ormLinkSet $oContactList */ - $oContactList = $oTestServer->Get('password_list'); - $oContactList->AddItem($oPassword); - $oTestServer->Set('password_list', $oContactList); + /** @var ormLinkSet $oContactList */ + $oContactList = $oTestServer->Get('password_list'); + $oContactList->AddItem($oPassword); + $oTestServer->Set('password_list', $oContactList); - $oRestResultWithObject = new RestResultWithObjects(); - $oRestResultWithObject->AddObject(0, 'ok', $oTestServer, ['TestServer' => ['id', 'password_list']]); - $oRestResultWithObject->SanitizeContent(); + $oRestResultWithObject = new RestResultWithObjects(); + $oRestResultWithObject->AddObject(0, 'ok', $oTestServer, ['TestServer' => ['id', 'password_list']]); + $oRestResultWithObject->SanitizeContent(); - static::assertContains( - '*****', - json_encode($oRestResultWithObject)); + static::assertStringContainsString( + '*****', + json_encode($oRestResultWithObject)); - static::assertNotContains( - self::SIMPLE_PASSWORD, - json_encode($oRestResultWithObject)); + static::assertStringNotContainsString( + self::SIMPLE_PASSWORD, + json_encode($oRestResultWithObject)); - } + } - /** - * @return string Abs path to the XML delta to use for the tests of that class - */ - public function GetDatamodelDeltaAbsPath(): string - { - return __DIR__ . '/Delta/delta_test_sanitize_output.xml'; - } + /** + * @return string Abs path to the XML delta to use for the tests of that class + */ + public function GetDatamodelDeltaAbsPath(): string + { + return __DIR__.'/Delta/delta_test_sanitize_output.xml'; + } }