2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
6 * This program is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Affero General Public License version 3 as published by the
8 * Free Software Foundation with the addition of the following permission added
9 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
11 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
18 * You should have received a copy of the GNU Affero General Public License along with
19 * this program; if not, see http://www.gnu.org/licenses or write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
24 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26 * The interactive user interfaces in modified source and object code versions
27 * of this program must display Appropriate Legal Notices, as required under
28 * Section 5 of the GNU Affero General Public License version 3.
30 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31 * these Appropriate Legal Notices must retain the display of the "Powered by
32 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
33 * technical reasons, the Appropriate Legal Notices must display the words
34 * "Powered by SugarCRM".
35 ********************************************************************************/
39 * Bug50780 - Due to the recent security fixes for the web services, subqueries on tables no longer work as expected.
40 * This has presented a problem to some of our partner's since they were relying on the subqueries to return
41 * relationship information on records. We could resolve this by adding back more tables to the allowed list of tables
42 * to be queried in a subquery, but this has been voted against from most of the engineering staff. Another approach
43 * would be to add enhancements to our API to allow for querying limited result sets for relationship data. Adding
44 * offset and limit support to the get_relationships call is one such approach.
47 require_once('include/nusoap/nusoap.php');
48 require_once 'tests/service/SOAPTestCase.php';
50 class Bug50780Test extends SOAPTestCase
52 public function setUp()
54 $this->_soapURL = $GLOBALS['sugar_config']['site_url'] . '/service/v4_1/soap.php';
56 $this->_login(); // Logging in just before the SOAP call as this will also commit any pending DB changes
59 for ($x = 0; $x < 4; $x++) {
60 $mid = SugarTestMeetingUtilities::createMeeting();
61 SugarTestMeetingUtilities::addMeetingUserRelation($mid->id, self::$_user->id);
64 $GLOBALS['db']->commit();
67 public function tearDown()
69 SugarTestMeetingUtilities::removeAllCreatedMeetings();
70 SugarTestMeetingUtilities::removeMeetingUsers();
76 public function testGetRelationshipReturnAllMeetings()
78 $result = $this->_soapClient->call('get_relationships', array(
79 'session' => $this->_sessionId,
80 'module_name' => 'Users',
81 'module_id' => self::$_user->id,
82 'link_field_name' => 'meetings',
83 'related_module_query' => '',
84 'related_fields' => array('id', 'name'),
85 'related_module_link_name_to_fields_array' => '',
87 'order_by' => 'date_entered',
92 $this->assertEquals(4, count($result['entry_list']));
95 public function testGetRelationshipReturnNothingWithOffsetSetHigh()
97 $result = $this->_soapClient->call('get_relationships', array(
98 'session' => $this->_sessionId,
99 'module_name' => 'Users',
100 'module_id' => self::$_user->id,
101 'link_field_name' => 'meetings',
102 'related_module_query' => '',
103 'related_fields' => array('id', 'name'),
104 'related_module_link_name_to_fields_array' => '',
106 'order_by' => 'date_entered',
111 $this->assertEquals(0, count($result['entry_list']));
114 public function testGetRelationshipReturnThirdMeeting()
116 $result = $this->_soapClient->call('get_relationships', array(
117 'session' => $this->_sessionId,
118 'module_name' => 'Users',
119 'module_id' => self::$_user->id,
120 'link_field_name' => 'meetings',
121 'related_module_query' => '',
122 'related_fields' => array('id', 'name'),
123 'related_module_link_name_to_fields_array' => '',
125 'order_by' => 'date_entered',
130 $this->assertEquals(1, count($result['entry_list']));
133 public function testGetRelationshipOffsetDoesntReturnSameRecords()
135 $result1 = $this->_soapClient->call('get_relationships', array(
136 'session' => $this->_sessionId,
137 'module_name' => 'Users',
138 'module_id' => self::$_user->id,
139 'link_field_name' => 'meetings',
140 'related_module_query' => '',
141 'related_fields' => array('id', 'name', 'date_entered'),
142 'related_module_link_name_to_fields_array' => '',
144 'order_by' => 'date_entered',
149 $this->assertEquals(2, count($result1['entry_list']));
151 $result2 = $this->_soapClient->call('get_relationships', array(
152 'session' => $this->_sessionId,
153 'module_name' => 'Users',
154 'module_id' => self::$_user->id,
155 'link_field_name' => 'meetings',
156 'related_module_query' => '',
157 'related_fields' => array('id', 'name', 'date_entered'),
158 'related_module_link_name_to_fields_array' => '',
160 'order_by' => 'date_entered',
165 $this->assertEquals(2, count($result2['entry_list']));