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 2961a77f7..a1a032d67 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 @@ -47,6 +47,12 @@ password + + lnkContactTestToServer + contact_test_id + testserver_id + true + diff --git a/tests/php-unit-tests/unitary-tests/core/RestServicesSanitizeOutputTest.php b/tests/php-unit-tests/unitary-tests/core/RestServicesSanitizeOutputTest.php index 8ebaf7ba2..7bae672e9 100644 --- a/tests/php-unit-tests/unitary-tests/core/RestServicesSanitizeOutputTest.php +++ b/tests/php-unit-tests/unitary-tests/core/RestServicesSanitizeOutputTest.php @@ -71,6 +71,33 @@ class RestServicesSanitizeOutputTest extends iTopCustomDatamodelTestCase json_encode($oRestResultWithObject)); } + public function testSanitizeJsonOutputAttributeOnNNRelation() + { + $oContactTest = $this->CreateObject('ContactTest', array( + 'password' => '123456')); + + $oTestServer = $this->CreateObject('TestServer', [ + 'name' => 'testserver', + ]); + + + // create lnkContactTestToServer + $this->CreateObject('lnkContactTestToServer', array( + 'contact_test_id' => $oContactTest->GetKey(), + 'testserver_id' => $oTestServer->GetKey() + )); + + $oRestResultWithObject = new \RestResultWithObjects(); + $oRestResultWithObject->AddObject(0, "ok", $oTestServer, + ['TestServer' => ['contact_list']]); + + $oRestResultWithObject->SanitizeContent(); + $this->assertEquals( + '{"objects":{"}', + json_encode($oRestResultWithObject)); + } + + public function testSanitizeJsonOutputOn1NRelation() { // Impossible to query the class @@ -82,6 +109,9 @@ class RestServicesSanitizeOutputTest extends iTopCustomDatamodelTestCase $oPassword->Set('password', "123456"); $oPassword->Set('server_test_id', $oTestServer->GetKey()); + $oContactList = $oTestServer->Get('contact_list'); + $oContactList->AddItem($oPassword); + $oTestServer->Set('contact_list', $oContactList); $oRestResultWithObject = new \RestResultWithObjects(); $oRestResultWithObject->AddObject(0, "ok", $oTestServer, ['TestServer' => ['id', 'password_list']]);