2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2012 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();
75 public function testGetRelationshipReturnAllMeetings()
77 $result = $this->_soapClient->call('get_relationships', array(
78 'session' => $this->_sessionId,
79 'module_name' => 'Users',
80 'module_id' => self::$_user->id,
81 'link_field_name' => 'meetings',
82 'related_module_query' => '',
83 'related_fields' => array('id', 'name'),
84 'related_module_link_name_to_fields_array' => '',
86 'order_by' => 'date_entered',
91 $this->assertEquals(4, count($result['entry_list']));
94 public function testGetRelationshipReturnNothingWithOffsetSetHigh()
96 $result = $this->_soapClient->call('get_relationships', array(
97 'session' => $this->_sessionId,
98 'module_name' => 'Users',
99 'module_id' => self::$_user->id,
100 'link_field_name' => 'meetings',
101 'related_module_query' => '',
102 'related_fields' => array('id', 'name'),
103 'related_module_link_name_to_fields_array' => '',
105 'order_by' => 'date_entered',
110 $this->assertEquals(0, count($result['entry_list']));
113 public function testGetRelationshipReturnThirdMeeting()
115 $result = $this->_soapClient->call('get_relationships', array(
116 'session' => $this->_sessionId,
117 'module_name' => 'Users',
118 'module_id' => self::$_user->id,
119 'link_field_name' => 'meetings',
120 'related_module_query' => '',
121 'related_fields' => array('id', 'name'),
122 'related_module_link_name_to_fields_array' => '',
124 'order_by' => 'date_entered',
129 $this->assertEquals(1, count($result['entry_list']));
132 public function testGetRelationshipOffsetDoesntReturnSameRecords()
134 $result1 = $this->_soapClient->call('get_relationships', array(
135 'session' => $this->_sessionId,
136 'module_name' => 'Users',
137 'module_id' => self::$_user->id,
138 'link_field_name' => 'meetings',
139 'related_module_query' => '',
140 'related_fields' => array('id', 'name', 'date_entered'),
141 'related_module_link_name_to_fields_array' => '',
143 'order_by' => 'date_entered',
148 $this->assertEquals(2, count($result1['entry_list']));
150 $result2 = $this->_soapClient->call('get_relationships', array(
151 'session' => $this->_sessionId,
152 'module_name' => 'Users',
153 'module_id' => self::$_user->id,
154 'link_field_name' => 'meetings',
155 'related_module_query' => '',
156 'related_fields' => array('id', 'name', 'date_entered'),
157 'related_module_link_name_to_fields_array' => '',
159 'order_by' => 'date_entered',
164 $this->assertEquals(2, count($result2['entry_list']));