def test_odata_escape_single_quotes_in_object_names_custom_request_threads(self): url = "https://localhost:8099/api/v1/Threads?$top=0&$filter=ObjectType eq 'Process' and " \ "ObjectName ne 'Process - Get Params REST'&$count=true" escaped_url = Utils.odata_escape_single_quotes_in_object_names(url) self.assertEqual( escaped_url, url)
def test_odata_escape_single_quotes_in_object_names_element(self): url = "https://localhost:8099/api/v1/Dimensions('dimen'sion')/Hierarchies('hier'archy')/Elements('elem'ent')" escaped_url = Utils.odata_escape_single_quotes_in_object_names(url) self.assertEqual( escaped_url, "https://localhost:8099/api/v1/Dimensions('dimen''sion')/Hierarchies('hier''archy')/Elements('elem''ent')" )
def _url_and_body(self, request, data, odata_escape_single_quotes_in_object_names=True): """ create proper url and payload """ url = self._base_url + request url = url.replace(' ', '%20').replace('#', '%23') if odata_escape_single_quotes_in_object_names: url = Utils.odata_escape_single_quotes_in_object_names(url) if type(data) is not bytes: data = data.encode('utf-8') return url, data
def test_odata_escape_single_quotes_in_object_names(self): url = "https://localhost:8099/api/v1/Dimensions('dime'nsion')/Hierarchies('hier'archy')/Elements('elem'ent')" url1 = "https://localhost:915/api/v1/TransactionLogEntries?$orderby=TimeStamp desc &$filter=Cube eq 'Test 'Case' cube*'" url2 = "https://localhost:915/api/v1/TransactionLogEntries?$orderby=TimeStamp desc &$filter=Cube eq 'Test C_'ase cube'" url3 = "https://localhost:915/api/v1/TransactionLogEntries?$orderby=TimeStamp desc &$filter=Cube eq 'Test C9'as*'&e cube'" url4 = "https://localhost:915/api/v1/TransactionLogEntries?$orderby=TimeStamp desc &$filter=Cube eq 'Test C9'_ase cube'" url5 = "https://localhost:915/api/v1/TransactionLogEntries?$orderby=TimeStamp desc &$filter=Cube eq 'Test Case cube'" escaped_url = Utils.odata_escape_single_quotes_in_object_names(url) escaped_url1 = Utils.odata_escape_single_quotes_in_object_names(url1) escaped_url2 = Utils.odata_escape_single_quotes_in_object_names(url2) escaped_url3 = Utils.odata_escape_single_quotes_in_object_names(url3) escaped_url4 = Utils.odata_escape_single_quotes_in_object_names(url4) escaped_url5 = Utils.odata_escape_single_quotes_in_object_names(url5) self.assertEqual( escaped_url, "https://localhost:8099/api/v1/Dimensions('dime''nsion')/Hierarchies('hier''archy')/Elements('elem''ent')" ) self.assertEqual( escaped_url1, "https://localhost:915/api/v1/TransactionLogEntries?$orderby=TimeStamp desc &$filter=Cube eq 'Test ''Case'' cube*'" ) self.assertEqual( escaped_url2, "https://localhost:915/api/v1/TransactionLogEntries?$orderby=TimeStamp desc &$filter=Cube eq 'Test C_''ase cube'" ) self.assertEqual( escaped_url3, "https://localhost:915/api/v1/TransactionLogEntries?$orderby=TimeStamp desc &$filter=Cube eq 'Test C9''as*''&e cube'" ) self.assertEqual( escaped_url4, "https://localhost:915/api/v1/TransactionLogEntries?$orderby=TimeStamp desc &$filter=Cube eq 'Test C9''_ase cube'" ) self.assertEqual( escaped_url5, "https://localhost:915/api/v1/TransactionLogEntries?$orderby=TimeStamp desc &$filter=Cube eq 'Test Case cube'" )
def test_odata_escape_single_quotes_in_object_names_user(self): url = "https://localhost:8099/api/v1/Users('Us'er')" escaped_url = Utils.odata_escape_single_quotes_in_object_names(url) self.assertEqual( escaped_url, "https://localhost:8099/api/v1/Users('Us''er')")
def test_odata_escape_single_quotes_in_object_names_group(self): url = "https://localhost:8099/api/v1/Groups('Gro'up')" escaped_url = Utils.odata_escape_single_quotes_in_object_names(url) self.assertEqual( escaped_url, "https://localhost:8099/api/v1/Groups('Gro''up')")