This commit is contained in:
jf-cbd
2025-03-05 15:44:22 +01:00
parent 2fedfa1b4c
commit 6fcbf68013
2 changed files with 36 additions and 0 deletions

View File

@@ -47,6 +47,12 @@
<field id="password" xsi:type="AttributeEncryptedString">
<sql>password</sql>
</field>
<field id="server_test_list" xsi:type="AttributeLinkedSetIndirect">
<linked_class>lnkContactTestToServer</linked_class>
<ext_key_to_me>contact_test_id</ext_key_to_me>
<ext_key_to_remote>testserver_id</ext_key_to_remote>
<is_null_allowed>true</is_null_allowed>
</field>
</fields>
</class>

View File

@@ -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']]);