mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 02:28:44 +02:00
WIP
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
@@ -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']]);
|
||||
|
||||
Reference in New Issue
Block a user