From b52b5578664c98de65e2abb925a0a61f40ee4bfd Mon Sep 17 00:00:00 2001 From: d-w-moore Date: Sun, 1 Nov 2026 08:15:00 -0500 Subject: [PATCH 01/11] [_843] iRODSGroup - proper zone attribute handling Evince the zone attribute of iRODSGroup objects. This attribute will always reflect the local zone name, since remote iRODS groups have no meaningful representation outside their own zones. --- irods/manager/user_manager.py | 35 ++++++++++++++++++++++------------- irods/user.py | 4 ++++ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/irods/manager/user_manager.py b/irods/manager/user_manager.py index 50b35ecae..c84658a49 100644 --- a/irods/manager/user_manager.py +++ b/irods/manager/user_manager.py @@ -2,25 +2,27 @@ import os import warnings -from irods.models import User, Group +import irods.password_obfuscation as obf +from irods.api_number import api_number +from irods.exception import ( + CAT_SQL_ERR, + GroupDoesNotExist, + MultipleResultsFound, + NoResultFound, + UserDoesNotExist, +) from irods.manager import Manager from irods.message import ( - UserAdminRequest, GeneralAdminRequest, + GetTempPasswordForOtherOut, + GetTempPasswordForOtherRequest, + UserAdminRequest, _do_GeneralAdminRequest, iRODSMessage, - GetTempPasswordForOtherRequest, - GetTempPasswordForOtherOut, -) -from irods.exception import ( - UserDoesNotExist, - GroupDoesNotExist, - NoResultFound, - CAT_SQL_ERR, ) -from irods.api_number import api_number -from irods.user import iRODSUser, iRODSGroup, Bad_password_change_parameter -import irods.password_obfuscation as obf +from irods.models import Group, User +from irods.user import Bad_password_change_parameter, iRODSGroup, iRODSUser + from .. import MAX_PASSWORD_LENGTH logger = logging.getLogger(__name__) @@ -281,12 +283,19 @@ def get__group_create__user_type__default(session): class GroupManager(UserManager): def get(self, name, user_zone=""): + if user_zone not in ("", local_zone := self.sess.zone): + msg = 'Specified user_zone must be local, since remote groups are not listed locally.' + raise GroupDoesNotExist(msg) + query = self.sess.query(Group).filter(Group.name == name) try: result = query.one() + except MultipleResultsFound: + result = query.filter(User.name == name, User.zone == local_zone).one() except NoResultFound: raise GroupDoesNotExist() + return iRODSGroup(self, result) def _api_info(self, group_admin_flag): diff --git a/irods/user.py b/irods/user.py index 4312eef64..be3d6ab81 100644 --- a/irods/user.py +++ b/irods/user.py @@ -82,6 +82,10 @@ def remove_quota(self, resource="total"): def set_quota(self, amount, resource="total"): self.manager.set_quota(self.name, amount, resource=resource) + @property + def zone(self): + return self.manager.sess.zone + def __init__(self, manager, result=None): self.manager = manager if result: From 99acefc800123e6954e3a222d6efb7b38c231945 Mon Sep 17 00:00:00 2001 From: d-w-moore Date: Tue, 1 Dec 2026 01:51:47 -0500 Subject: [PATCH 02/11] [_847] user and group equality operators Provide __eq__ methods appropriate for iRODSUser and iRODSGroup objects. This also allows (iRODSUser_instance in iRODSGroup.members) to properly indicate user membership in a group. --- irods/test/user_group_test.py | 17 +++++++++++++++++ irods/user.py | 12 ++++++++++++ 2 files changed, 29 insertions(+) diff --git a/irods/test/user_group_test.py b/irods/test/user_group_test.py index ad7d0900a..1eed8e842 100644 --- a/irods/test/user_group_test.py +++ b/irods/test/user_group_test.py @@ -710,6 +710,23 @@ def test_we_cannot_overwrite_irodsA_without_overwrite_option_true__issue_635(sel with open(auth_file, "rb") as f: self.assertEqual(auth_file_contents, f.read()) + def test_that_the_in_operator_detects_a_user_among_group_members__issue_847(self): + test_user = test_group = None + try: + test_user = self.sess.users.create('bob', user_type='rodsuser') + test_group = self.sess.groups.create('lab') + + # By default, the new user shouldn't be among the new group's members + self.assertNotIn(test_user, test_group.members) + + # Add the user as a member and show the "in" operator works for iRODSUser objects. + test_group.addmember(test_user.name) + self.assertIn(test_user, test_group.members) + finally: + if test_user: + test_user.remove() + if test_group: + test_group.remove() if __name__ == "__main__": # let the tests find the parent irods lib diff --git a/irods/user.py b/irods/user.py index be3d6ab81..76b0d4055 100644 --- a/irods/user.py +++ b/irods/user.py @@ -17,6 +17,13 @@ def remove_quota(self, resource="total"): def set_quota(self, amount, resource="total"): self.manager.set_quota(self.name, amount, resource=resource) + def __eq__(self, other_user): + # For the case of (iRODSUser_instance == iRODSGroup_instance), iRODSGroup.__eq__ is the fallback + # chosen by the Python interpreter when NotImplemented is returned. + if not isinstance(other_user, iRODSUser): + return NotImplemented + return (self.name, self.zone) == (other_user.name, other_user.zone) + def __init__(self, manager, result=None): self.manager = manager if result: @@ -86,6 +93,11 @@ def set_quota(self, amount, resource="total"): def zone(self): return self.manager.sess.zone + def __eq__(self, other_group_or_user): + if not isinstance(other_group_or_user, (iRODSUser, iRODSGroup)): + return NotImplemented + return (self.name, self.zone) == (other_group_or_user.name, other_group_or_user.zone) + def __init__(self, manager, result=None): self.manager = manager if result: From 4855b07061bc373912fffc176bdc28508de5d6ff Mon Sep 17 00:00:00 2001 From: d-w-moore Date: Mon, 9 Nov 2026 10:19:23 -0500 Subject: [PATCH 03/11] [_846] update python versions for GitHub test and source check actions --- .github/workflows/main.yml | 2 +- .github/workflows/run-test-programs-single-node.yml | 2 +- .github/workflows/run-test-suite-multiple-node.yml | 2 +- .github/workflows/run-test-suite-single-node.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1c9fcf912..3f8c06b03 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: - python-version: ['3.9'] + python-version: ['3.10'] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/run-test-programs-single-node.yml b/.github/workflows/run-test-programs-single-node.yml index 03f35ad2a..211d4f1e4 100644 --- a/.github/workflows/run-test-programs-single-node.yml +++ b/.github/workflows/run-test-programs-single-node.yml @@ -20,7 +20,7 @@ jobs: working-directory: ./test_harness/single_node strategy: matrix: - python: ['3.9','3.13'] + python: ['3.10','3.15'] irods_server: ['4.3.5','5.0.2'] steps: diff --git a/.github/workflows/run-test-suite-multiple-node.yml b/.github/workflows/run-test-suite-multiple-node.yml index 3d2f20c2f..de621c3da 100644 --- a/.github/workflows/run-test-suite-multiple-node.yml +++ b/.github/workflows/run-test-suite-multiple-node.yml @@ -14,7 +14,7 @@ jobs: working-directory: ./test_harness/multiple_node strategy: matrix: - python: ['3.9','3.13'] + python: ['3.10','3.15'] irods_server: ['4.3.5','5.0.2'] steps: diff --git a/.github/workflows/run-test-suite-single-node.yml b/.github/workflows/run-test-suite-single-node.yml index d65dfa2ed..37cdfc838 100644 --- a/.github/workflows/run-test-suite-single-node.yml +++ b/.github/workflows/run-test-suite-single-node.yml @@ -14,7 +14,7 @@ jobs: working-directory: ./test_harness/single_node strategy: matrix: - python: ['3.9','3.13'] + python: ['3.10','3.15'] irods_server: ['4.3.5','5.0.2'] steps: From 0eac2d2bb668999dd6ab317890d277c00fe9dde7 Mon Sep 17 00:00:00 2001 From: d-w-moore Date: Thu, 22 Oct 2026 12:09:26 -0400 Subject: [PATCH 04/11] [_561] implement get_maximum_permissions_for_path functionality and test A query is done to determine the highest permission level the given user (or group) has on the target collection/data_object. A specific query will be used if the calling user has the availability, otherwise a reasonably efficient general query is used instead. --- irods/access.py | 1 - irods/manager/access_manager.py | 150 +++++++++++++++++++++++++++++++- irods/query.py | 7 ++ irods/test/access_test.py | 128 ++++++++++++++++++++++++++- 4 files changed, 283 insertions(+), 3 deletions(-) diff --git a/irods/access.py b/irods/access.py index 1ad6660a7..27e0f061f 100644 --- a/irods/access.py +++ b/irods/access.py @@ -20,7 +20,6 @@ "null", ) - class _Access_LookupMeta(type): @staticmethod def _codes(): diff --git a/irods/manager/access_manager.py b/irods/manager/access_manager.py index 5873c1e15..11f2536f9 100644 --- a/irods/manager/access_manager.py +++ b/irods/manager/access_manager.py @@ -2,12 +2,14 @@ import logging from os.path import basename, dirname +import typing from irods.access import iRODSAccess from irods.api_number import api_number from irods.collection import iRODSCollection from irods.column import In from irods.data_object import irods_basename, irods_dirname, iRODSDataObject +from irods.exception import CAT_NO_ROWS_FOUND from irods.manager import Manager from irods.message import JSON_Message, ModAclRequest, iRODSMessage from irods.models import ( @@ -16,9 +18,12 @@ CollectionUser, DataAccess, DataObject, + Group, User, ) -from irods.user import iRODSUser +from irods.query import SpecificQuery +from irods.user import iRODSUser, iRODSGroup + logger = logging.getLogger(__name__) @@ -35,7 +40,150 @@ def users_by_ids(session, ids=()): return [iRODSUser(session.users, i) for i in session.query(User.id, User.name, User.type, User.zone).filter(*cond)] +class QueryParameterError(ValueError): + pass + + +# This is the alias where we expect to find a specific query +alias_for_get_maximum_permission_for_path = 'get_maximum_permission_for_path' + + +class _iRODSPermission(typing.NamedTuple): + as_string: str + as_integer: int + + class AccessManager(Manager): + def get_maximum_permission_for_path( + self, + user: (iRODSUser | iRODSGroup), + collection: (str | iRODSCollection | None) = None, + data_object: (str | iRODSDataObject | None) = None, + specific_query: (SpecificQuery | str | None) = '', + ) -> _iRODSPermission | None: + """ + Return the highest permission the named user/group has with respect to the + given data object or collection. In calculating this result, all ACLs and + group memberships are factored in. + + Only one of 'data_object' or 'collection' may be specified. + + Args: + user: an iRODSUser or iRODSGroup object for whom the permission is to be calculated. + collection: an iRODS logical path or iRODSCollection. + data_object: an iRODS logical path or iRODSDataObject. + specific_query (default ""): a SpecificQuery object or an alias specifying + the specific query used for the calculation. The default value of "" will be + interpreted to mean the designated specific query preconfigured for this express + purpose. If the server does not cache a query under that alias, or if None is + given as a value, then the calculation will be done via a general query. + + Returns: + a named tuple representing the permission results in terms of both the symbolic + string (.as_string) and integer code (.as_integer). If no ACLs + exist granting permission for the named user or group, then None is returned. + """ + ses = self.sess + + # Convert user or group to object. Need to know if we are dealing with a rodsadmin + if isinstance(user, (iRODSUser, iRODSGroup)): + pass + else: + msg = "'user' argument should be of type iRODSUser or iRODSGroup." + raise QueryParameterError(msg) + + _specific_query = None + + if specific_query == '': + specific_query = alias_for_get_maximum_permission_for_path + + if isinstance(specific_query, SpecificQuery): + _specific_query = specific_query + elif isinstance(specific_query, str): + _specific_query = SpecificQuery(ses, alias=specific_query) + + query_type_logger = logging.getLogger('issue_561_query_type_detection') + + # Dispatch to the available/chosen query method. + if _specific_query is not None: + query_type_logger.debug('SPECIFIC') + + def denullify(s): + return s or "x" + + _specific_query.reset_for_new_query( + args=[ + user.name, + getattr(user, 'zone', ses.zone), + denullify(collection.path if isinstance(collection, iRODSCollection) else collection), + denullify(data_object.path if isinstance(data_object, iRODSDataObject) else data_object), + ] + ) + max_permission = self._get_maximum_permission_for_path_via_SpecificQuery(_specific_query) + res = [max_permission] + else: + query_type_logger.debug('GENERAL') + res = None + groups = {g[Group.id] for g in ses.query(Group, User).filter(Group.id != user.id, User.id == user.id)} + groups |= {user.id} + + if data_object: + if isinstance(data_object, str): + collN = irods_dirname(data_object) + dataN = irods_basename(data_object) + join_criteria = [DataObject.name == dataN, Collection.name == collN] + elif isinstance(data_object, iRODSDataObject): + join_criteria = [DataAccess.data_id == data_object.id] + else: + msg = "'data_object' parameter must be full logical path or data object" + raise ValueError(msg) + + q = ( + ses + .query(DataAccess.type) + .filter(In(DataAccess.user_id, groups), *join_criteria) + .order_by(DataAccess.type, order='desc') + ) + + res = [_[DataAccess.type] for _ in q] + + elif collection: + if isinstance(collection, str): + join_criteria = [Collection.name == collection] + elif isinstance(collection, iRODSCollection): + join_criteria = [ + CollectionAccess.access_id == collection.id + ] + else: + msg = "'collection' parameter must be full logical path or collection object" + raise ValueError(msg) + + q = ( + ses + .query(CollectionAccess) + .filter(In(CollectionAccess.user_id, groups), *join_criteria) + .order_by(CollectionAccess.type, order='desc') + ) + + res = [_[CollectionAccess.type] for _ in q] + + else: + msg = 'Need a collection or data object' + raise QueryParameterError(msg) + + res = res[0] if res else None + return _iRODSPermission(iRODSAccess.strings[res], as_integer=res) if isinstance(res, int) else None + + @staticmethod + def _get_maximum_permission_for_path_via_SpecificQuery(spec_query): + try: + row = next(iter(spec_query.execute())) + except (StopIteration, CAT_NO_ROWS_FOUND): + row = {} + + highest_perm = row.get(0) + return None if highest_perm is None else int(highest_perm) + @staticmethod def _to_acl_operation_json(op_input: iRODSAccess): return { diff --git a/irods/query.py b/irods/query.py index aa6e7a514..9bbeb618e 100644 --- a/irods/query.py +++ b/irods/query.py @@ -290,6 +290,11 @@ def __init__(self, sess, sql=None, alias=None, columns=None, args=None): self._columns = columns self._args = args or [] + def reset_for_new_query(self, args=None): + self._continue_index = 0 + if args is not None: + self._args = args + def register(self): if not self._sql: raise ValueError("Empty query") @@ -363,6 +368,8 @@ def get_results(self): yield result + + # Record a copy of the original value of IRODS_QUERY_LIMIT for possible future access. import irods.helpers as helpers diff --git a/irods/test/access_test.py b/irods/test/access_test.py index 142bb2f5c..76b0db436 100644 --- a/irods/test/access_test.py +++ b/irods/test/access_test.py @@ -1,15 +1,21 @@ #! /usr/bin/env python +import io +import logging import os import sys +import textwrap import unittest +import uuid from irods.access import ACLOperation, iRODSAccess from irods.collection import iRODSCollection from irods.column import In, Like -from irods.exception import UserDoesNotExist +from irods.exception import CAT_NO_ROWS_FOUND, UserDoesNotExist +from irods.manager.access_manager import alias_for_get_maximum_permission_for_path from irods.models import Collection, DataObject, User from irods.path import iRODSPath +from irods.query import SpecificQuery from irods.session import iRODSSession from irods.test import helpers from irods.user import iRODSUser @@ -532,6 +538,126 @@ def test_atomic_acls__issue_505(self): if zone: zone.remove() + def test_get_maximum_permission_for_path__issue_561(self): + SQL = textwrap.dedent(''' + WITH target_user AS ( + SELECT user_id + FROM r_user_main + WHERE user_name = ? + AND zone_name = ? + ), + resolved_object AS ( + -- The path names a collection + SELECT coll_id AS object_id + FROM r_coll_main + WHERE coll_name = ? + + UNION + + -- The path names a data object: collection path + '/' + data name + SELECT d.data_id AS object_id + FROM r_data_main AS d + JOIN r_coll_main AS c ON c.coll_id = d.coll_id + WHERE CONCAT(c.coll_name, '/', d.data_name) = ? + ), + grants AS ( + -- Direct grants + SELECT a.access_type_id + FROM r_objt_access AS a + JOIN target_user AS u ON u.user_id = a.user_id + JOIN resolved_object AS o ON o.object_id = a.object_id + + UNION ALL + + -- Grants to groups the user belongs to + SELECT a.access_type_id + FROM r_user_group AS ug + JOIN target_user AS u ON u.user_id = ug.user_id + JOIN r_objt_access AS a ON a.user_id = ug.group_user_id + JOIN resolved_object AS o ON o.object_id = a.object_id + ) + SELECT access_type_id + FROM grants + ORDER BY access_type_id DESC + LIMIT 1;''') + user = group = coll = None + ses = self.sess + my_specific_query = None + query_alias = None + try: + coll = ses.collections.create('/tempZone/home/public/folder_561') + data = ses.data_objects.create('/tempZone/home/public/folder_561/file') + user = ses.users.create('bob', 'rodsuser') + group = ses.groups.create('lab') + + # Set up test scenario with a new user and group, the group having deliberately higher permission + # so as to be able to account for the effect of group membership in the query results. + USER_PERM = 'modify_metadata' + GROUP_PERM = 'modify_object' + test_perms = {user.name: USER_PERM, group.name: GROUP_PERM} + for obj in (coll, data): + ses.acls.set(iRODSAccess(USER_PERM, obj.path, user.name)) + ses.acls.set(iRODSAccess(GROUP_PERM, obj.path, group.name)) + + sql_arg = {} + try: + SpecificQuery( + ses, alias='findQueryByAlias', args=(query_alias := alias_for_get_maximum_permission_for_path,) + ).execute() + except CAT_NO_ROWS_FOUND: + query_alias = str(uuid.uuid1()) + # PostGres is truly case insensitive for table names, whereas MySQL prefers them uppercase. + sql_arg = {'sql': SQL.upper()} + + my_specific_query = SpecificQuery(ses, alias=query_alias, **sql_arg) + if sql_arg: + my_specific_query.register() + + logger = logging.getLogger('issue_561_query_type_detection') + logger.setLevel(logging.DEBUG) + for is_member in (False, True): + if is_member: + group.addmember(user.name, user.zone) + for usr in (user, group): + max_user = usr if usr not in group.members else group + expected_permission = test_perms[max_user.name] + for obj_type, obj in ( + ("collection", coll), + ("collection", coll.path), + ("data_object", data), + ("data_object", data.path), + ): + query_options = { + 'GENERAL':{'specific_query':None}, + 'SPECIFIC':({} if not my_specific_query else {'specific_query':my_specific_query}) + } + for query_index in ('SPECIFIC', 'GENERAL'): + with self.subTest(f"Issue 561 subTest: {is_member=} {usr=} {obj=} {query_index=}"): + handler = None + try: + logger.addHandler(handler:=logging.StreamHandler(stream:=io.StringIO())) + permission = ses.acls.get_maximum_permission_for_path( + usr, + **query_options[query_index], + **{obj_type: obj}, + ).as_string + self.assertEqual(permission, expected_permission) + # Check logging output to verify which code path was taken. + self.assertEqual(stream.getvalue().rstrip(), query_index) + finally: + if handler: + logger.removeHandler(handler) + finally: + if coll: + # Removes test data object as well. + coll.remove(force=True, recurse=True) + if user: + user.remove() + if group: + group.remove() + if my_specific_query and (query_alias != alias_for_get_maximum_permission_for_path): + my_specific_query.remove() + if __name__ == "__main__": # let the tests find the parent irods lib From 3fed8da40bfd8e2eb8a8ad96f6add20d8751297f Mon Sep 17 00:00:00 2001 From: d-w-moore Date: Tue, 1 Dec 2026 03:22:19 -0500 Subject: [PATCH 05/11] [_843] disallow construction of iRODSGroup with non-local zone --- irods/manager/user_manager.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/irods/manager/user_manager.py b/irods/manager/user_manager.py index c84658a49..86817d9ac 100644 --- a/irods/manager/user_manager.py +++ b/irods/manager/user_manager.py @@ -28,6 +28,13 @@ logger = logging.getLogger(__name__) +class NonlocalGroupError(ValueError): + """ + Raised if an attempt is made to create an iRODS group non local to the connected zone. + """ + pass + + class UserManager(Manager): def _get_session(self): return self.sess @@ -335,6 +342,10 @@ def create( if callable(user_type): user_type = user_type(self.sess) + if user_zone not in ("", self.sess.zone): + msg = "iRODS Groups are only representable in the context of their local zone." + raise NonlocalGroupError(msg) + if user_zone != "" or auth_str != "" or user_type not in ("", "rodsgroup"): warnings.warn( "Use of non-default value for auth_str, user_type or user_zone in GroupManager.create is deprecated", From 5f3693a07c690d65787a16e02f6b5c73cf00e609 Mon Sep 17 00:00:00 2001 From: d-w-moore Date: Tue, 1 Dec 2026 03:57:41 -0500 Subject: [PATCH 06/11] 843 test --- irods/test/user_group_test.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/irods/test/user_group_test.py b/irods/test/user_group_test.py index 1eed8e842..b66c1cc81 100644 --- a/irods/test/user_group_test.py +++ b/irods/test/user_group_test.py @@ -728,6 +728,23 @@ def test_that_the_in_operator_detects_a_user_among_group_members__issue_847(self if test_group: test_group.remove() + def test_users_distinct_between_zones__issue_843(self): + test_zone = bob1 = bob2 = None + try: + test_zone = self.sess.zones.create('notMyZone', 'remote') + bob1 = self.sess.users.create("bob", user_zone=test_zone.name, user_type='rodsuser' ) + bob2 = self.sess.users.create("bob", user_zone=self.sess.zone, user_type='rodsuser') + + # Prior to fix, this would raise MultipleResultsFound + bob = self.sess.groups.get("bob") + finally: + if bob1: + bob1.remove() + if bob2: + bob2.remove() + if test_zone: + test_zone.remove() + if __name__ == "__main__": # let the tests find the parent irods lib sys.path.insert(0, os.path.abspath("../..")) From 631bfa145ada0052a31e5e2edf5491e8d5091796 Mon Sep 17 00:00:00 2001 From: Daniel Moore Date: Tue, 1 Dec 2026 12:14:34 -0500 Subject: [PATCH 07/11] Update irods/manager/access_manager.py Co-authored-by: Kory Draughn --- irods/manager/access_manager.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/irods/manager/access_manager.py b/irods/manager/access_manager.py index 11f2536f9..b9fd62706 100644 --- a/irods/manager/access_manager.py +++ b/irods/manager/access_manager.py @@ -69,17 +69,17 @@ def get_maximum_permission_for_path( Only one of 'data_object' or 'collection' may be specified. Args: - user: an iRODSUser or iRODSGroup object for whom the permission is to be calculated. - collection: an iRODS logical path or iRODSCollection. - data_object: an iRODS logical path or iRODSDataObject. - specific_query (default ""): a SpecificQuery object or an alias specifying + user: An iRODSUser or iRODSGroup object for whom the permission is to be calculated. + collection: An iRODS logical path or iRODSCollection. + data_object: An iRODS logical path or iRODSDataObject. + specific_query (default ""): A SpecificQuery object or an alias specifying the specific query used for the calculation. The default value of "" will be interpreted to mean the designated specific query preconfigured for this express purpose. If the server does not cache a query under that alias, or if None is given as a value, then the calculation will be done via a general query. Returns: - a named tuple representing the permission results in terms of both the symbolic + A named tuple representing the permission results in terms of both the symbolic string (.as_string) and integer code (.as_integer). If no ACLs exist granting permission for the named user or group, then None is returned. """ From 6ab7fdf6bbfbf49d0d9a5c95f325f58ec0dd3fe6 Mon Sep 17 00:00:00 2001 From: d-w-moore Date: Tue, 1 Dec 2026 12:25:24 -0500 Subject: [PATCH 08/11] revise 843 test --- irods/test/user_group_test.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/irods/test/user_group_test.py b/irods/test/user_group_test.py index b66c1cc81..386aa91bc 100644 --- a/irods/test/user_group_test.py +++ b/irods/test/user_group_test.py @@ -736,7 +736,14 @@ def test_users_distinct_between_zones__issue_843(self): bob2 = self.sess.users.create("bob", user_zone=self.sess.zone, user_type='rodsuser') # Prior to fix, this would raise MultipleResultsFound - bob = self.sess.groups.get("bob") + bob_as_group = self.sess.groups.get("bob", self.sess.zone) + + # Assert the local and remote users + bob_as_local_user = self.sess.users.get("bob", self.sess.zone) + self.assertEqual(bob_as_group, bob_as_local_user) + + bob_remote = self.sess.users.get("bob", test_zone.name) + self.assertNotEqual(bob_remote, bob_as_local_user) finally: if bob1: bob1.remove() From ea467c1b3e7fafeb92cc3864f3775a2b771f8972 Mon Sep 17 00:00:00 2001 From: d-w-moore Date: Tue, 1 Dec 2026 12:28:18 -0500 Subject: [PATCH 09/11] update 843 test comments --- irods/test/user_group_test.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/irods/test/user_group_test.py b/irods/test/user_group_test.py index 386aa91bc..e0aa65203 100644 --- a/irods/test/user_group_test.py +++ b/irods/test/user_group_test.py @@ -738,12 +738,13 @@ def test_users_distinct_between_zones__issue_843(self): # Prior to fix, this would raise MultipleResultsFound bob_as_group = self.sess.groups.get("bob", self.sess.zone) - # Assert the local and remote users + # Assert the local and remote users can be independently identified and are not equal. bob_as_local_user = self.sess.users.get("bob", self.sess.zone) - self.assertEqual(bob_as_group, bob_as_local_user) - bob_remote = self.sess.users.get("bob", test_zone.name) self.assertNotEqual(bob_remote, bob_as_local_user) + + # Assert that bob the group, and bob the user, compare as equal. + self.assertEqual(bob_as_group, bob_as_local_user) finally: if bob1: bob1.remove() From f938f5a489a6b27040d273ba4fb3d931c8bdd051 Mon Sep 17 00:00:00 2001 From: d-w-moore Date: Tue, 1 Dec 2026 13:20:58 -0500 Subject: [PATCH 10/11] [_700] delete test data object --- irods/test/data_obj_test.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/irods/test/data_obj_test.py b/irods/test/data_obj_test.py index 8b0989c32..f63a28496 100644 --- a/irods/test/data_obj_test.py +++ b/irods/test/data_obj_test.py @@ -2961,18 +2961,24 @@ def test_access_time__issue_700(self): prior_ts = datetime.now(timezone.utc) - timedelta(seconds=2) + data = None + + try: # Create a new, uniquely named test data object. - data = self.sess.data_objects.create( - logical_path := f'{helpers.home_collection(self.sess)}/{unique_name(my_function_name(), datetime.now())}' - ) + data = self.sess.data_objects.create( + logical_path := f'{helpers.home_collection(self.sess)}/{unique_name(my_function_name(), datetime.now())}' + ) - with data.open('w') as f: - data = self.sess.data_objects.get(logical_path) - self.assertEqual(data.access_time, data.modify_time) - self.assertGreaterEqual(data.access_time, prior_ts) + with data.open('w') as f: + data = self.sess.data_objects.get(logical_path) + self.assertEqual(data.access_time, data.modify_time) + self.assertGreaterEqual(data.access_time, prior_ts) - # Test that access_time is there, and of the right type. - self.assertIs(type(data.access_time), datetime) + # Test that access_time is there, and of the right type. + self.assertIs(type(data.access_time), datetime) + finally: + if data: + data.unlink(force=True) def test_handling_of_termination_signals_during_multithread_get__issue_722(self): from irods.test.modules.test_signal_handling_in_multithread_get import ( From 5e468e9c69db263f7b106d146f22c077284c39ff Mon Sep 17 00:00:00 2001 From: d-w-moore Date: Tue, 1 Dec 2026 13:21:22 -0500 Subject: [PATCH 11/11] make iRODSUser, iRODSGroup hashable --- irods/user.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/irods/user.py b/irods/user.py index 76b0d4055..9b88a1649 100644 --- a/irods/user.py +++ b/irods/user.py @@ -10,6 +10,8 @@ class Bad_password_change_parameter(Exception): class iRODSUser: + def __hash__(self): return hash((self.name,self.zone)) + def remove_quota(self, resource="total"): self.manager.remove_quota(self.name, resource=resource) @@ -83,6 +85,8 @@ def temp_password(self): class iRODSGroup: type = "rodsgroup" + def __hash__(self): return hash((self.name,self.zone)) + def remove_quota(self, resource="total"): self.set_quota(amount=0, resource=resource)