Skip to content

Commit

Permalink
[3902,4983,5992,7174,7169,8033] Add tests for long standing GenQuery1…
Browse files Browse the repository at this point in the history
… parser issues.
  • Loading branch information
korydraughn committed Dec 16, 2024
1 parent 9dea753 commit 438dc71
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
7 changes: 7 additions & 0 deletions scripts/irods/test/test_icp.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ def test_icp_with_apostrophe_logical_path__issue_5759(self):
self.user.assert_icommand(['irm', '-rf', source_collection_path])
self.user.assert_icommand(['imkdir', '-p', source_collection_path])

def test_icp_does_not_break_when_data_object_name_contains_certain_character_sequence__issue_4983(self):
data_object = "' and '"
self.user.assert_icommand(['itouch', data_object])
self.user.assert_icommand(['ils', data_object], 'STDOUT', [data_object])
new_data_object = 'issue_4983'
self.user.assert_icommand(['icp', data_object, new_data_object])
self.user.assert_icommand(['ils', new_data_object], 'STDOUT', [new_data_object])

class test_overwriting(unittest.TestCase):
@classmethod
Expand Down
6 changes: 6 additions & 0 deletions scripts/irods/test/test_ils.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,9 @@ def test_ils_of_data_object_includes_group_prefix_for_group_permissions__issue_6
self.admin.assert_icommand(['ichmod', 'read', 'public', 'foo'])
self.admin.assert_icommand(['ils', '-A', 'foo'], 'STDOUT', [' g:public#{0}:read_object'.format(self.admin.zone_name)])

def test_ils_does_not_produce_a_cpp_exception_when_collection_name_contains_apostrophes__issue_5992(self):
coll_name = "a'b and d"
self.admin.assert_icommand(['imkdir', coll_name])
expected_output = [os.path.join(self.admin.session_collection, coll_name)]
self.admin.assert_icommand(['ils'], 'STDOUT', expected_output)
self.admin.assert_icommand(['ils', coll_name], 'STDOUT', expected_output)
7 changes: 7 additions & 0 deletions scripts/irods/test/test_iquest.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ def test_iquest_incorrect_format_count(self):
self.admin.assert_icommand("iquest \"%s %s\" \"select COLL_NAME where COLL_NAME like '%home%'\"",
'STDERR_SINGLELINE', 'boost::too_few_args: format-string referred to more arguments than were passed')

def test_iquest_does_not_fail_to_find_data_objects_with_SQL_keyword_names_select_and_where__issue_7174(self):
for data_object in ['selected_file', 'where_file', 'select.txt', 'where.txt']:
self.admin.assert_icommand(['itouch', data_object])
self.admin.assert_icommand(['ils', data_object], 'STDOUT', [data_object])
expected_output = ['DATA_NAME = ' + data_object]
self.admin.assert_icommand(['iquest', f"SELECT DATA_NAME, DATA_CREATE_TIME WHERE DATA_NAME = '{data_object}'"], 'STDOUT', expected_output)
self.admin.assert_icommand(['iquest', f"SELECT DATA_NAME, DATA_CREATE_TIME WHERE DATA_NAME like '%{data_object}%'"], 'STDOUT', expected_output)

class test_iquest_with_data_resc_hier(unittest.TestCase):
@classmethod
Expand Down
9 changes: 7 additions & 2 deletions scripts/irods/test/test_itouch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
from . import session
from .. import test

class Test_Itouch(session.make_sessions_mixin([('otherrods', 'rods')], []), unittest.TestCase):
class Test_Itouch(session.make_sessions_mixin([('otherrods', 'rods')], [('alice', 'apass')]), unittest.TestCase):

def setUp(self):
super(Test_Itouch, self).setUp()
self.admin = self.admin_sessions[0]
self.user = self.user_sessions[0]

def tearDown(self):
super(Test_Itouch, self).tearDown()
Expand Down Expand Up @@ -261,6 +262,11 @@ def test_itouch_returns_better_error_message_when_given_a_coordinating_resource_
self.admin.run_icommand(['iadmin', 'rmresc', resc])
self.admin.run_icommand(['iadmin', 'rmresc', pt])

def test_itouch_does_not_return_SYS_NO_GOOD_REPLICA_when_new_data_object_name_contains_single_quote__issue_7169_7972(self):
for data_object in ["just testin'", "test'file"]:
self.user.assert_icommand(['itouch', data_object])
self.user.assert_icommand(['ils', data_object], 'STDOUT', [data_object])

def get_replica_mtime(self, path, replica_number):
collection = os.path.dirname(path)
if len(collection) == 0:
Expand All @@ -284,4 +290,3 @@ def create_resource_ufs(self, resource_name):

def create_resource_pt(self, resource_name):
self.admin.assert_icommand(['iadmin', 'mkresc', resource_name, 'passthru'], 'STDOUT', [resource_name])

19 changes: 19 additions & 0 deletions scripts/irods/test/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,3 +458,22 @@ def test_tcp_keepalive_probes__issue_2533_3824(self):
@unittest.skipIf(test.settings.RUN_IN_TOPOLOGY, "skip for topology testing")
def test_server_side_delay_rule_locking_API__issue_8023(self):
self.admin.assert_icommand(['irule', '-r', 'irods_rule_engine_plugin-irods_rule_language-instance', 'msi_test_delay_rule_locking_api', 'null', 'ruleExecOut'])

def test_logical_path_containing_AND_keyword_and_single_quotes_does_not_result_in_an_error__issue_8033(self):
coll_name = 'colA and colB'
self.admin.assert_icommand(['imkdir', coll_name])
self.admin.assert_icommand(['ils', coll_name], 'STDOUT', [os.path.join(self.admin.session_collection, coll_name)])

data_object = f"{coll_name}/myfile'"
self.admin.assert_icommand(['itouch', data_object])
self.admin.assert_icommand(['ils', data_object], 'STDOUT', [os.path.join(self.admin.session_collection, data_object)])

filename = "myfile' name and id"
try:
lib.make_file(filename, 1)
self.admin.assert_icommand(['iput', filename])
self.admin.assert_icommand(['ils', filename], 'STDOUT', [os.path.join(self.admin.session_collection, filename)])

finally:
if os.path.exists(filename):
os.unlink(filename)

0 comments on commit 438dc71

Please sign in to comment.