Skip to content

Commit 7554302

Browse files
committed
official test
1 parent 806ef94 commit 7554302

3 files changed

Lines changed: 47 additions & 11 deletions

File tree

irods/access.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def __hash__(self):
107107
(self.access_name, iRODSPath(self.path), self.user_name, self.user_zone)
108108
)
109109

110-
def copy(self, decanonicalize=False):
110+
def copy(self, decanonicalize=False, ref_zone=''):
111111
other = copy.deepcopy(self)
112112
if decanonicalize:
113113
replacement_string = {
@@ -121,6 +121,9 @@ def copy(self, decanonicalize=False):
121121
if replacement_string is not None
122122
else self.access_name
123123
)
124+
if '' != ref_zone == other.user_zone:
125+
other.user_zone = ''
126+
124127
return other
125128

126129
def __repr__(self):

irods/manager/access_manager.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,13 @@ def users_by_ids(session, ids=()):
5050
class AccessManager(Manager):
5151

5252
def _ACL_operation(self, op_input: iRODSAccess):
53-
access = op_input.access_name
54-
entity = op_input.user_name
55-
zone = op_input.user_zone
56-
try:
57-
if self.sess.users.get(entity, zone).type == "rodsgroup":
58-
zone = ""
59-
except ex.UserDoesNotExist:
60-
return {}
6153
return {
62-
**{"acl": access, "entity_name": entity},
63-
**({} if not zone else {"zone":zone})
54+
"acl": op_input.access_name,
55+
"entity_name": op_input.user_name,
56+
**(
57+
{} if not (z := op_input.user_zone)
58+
else {"zone": z}
59+
)
6460
}
6561

6662
def _call_atomic_acl_api(self, logical_path : str, *operations, admin=False):

irods/test/access_test.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,43 @@ def test_iRODSAccess_cannot_be_constructed_using_unsupported_type__issue_558(sel
542542
self.sess,
543543
)
544544

545+
def test_atomic_acls_505(self):
546+
#import pdb;pdb.set_trace()
547+
ses = self.sess
548+
zone = user1 = user2 = group = None
549+
try:
550+
zone = ses.zones.create("twilight","remote")
551+
user1 = ses.users.create("test_user_505", "rodsuser")
552+
user2 = ses.users.create("rod_serling_505#twilight", "rodsuser")
553+
group = ses.groups.create("test_group_505")
554+
ses.acls._call_atomic_acl_api(
555+
self.coll_path,
556+
a1:=iRODSAccess("write", "", user1.name, user1.zone),
557+
a2:=iRODSAccess("read", "", user2.name, user2.zone),
558+
a3:=iRODSAccess("read", "", group.name),
559+
)
560+
561+
accesses = ses.acls.get(self.coll)
562+
563+
# For purposes of equality tests, assign the path name of interest into each ACL.
564+
for p in (a1, a2, a3):
565+
p.path = self.coll_path
566+
567+
# Assert that the ACLs we added are among those listed for the object in the catalog.
568+
normalize = lambda access: access.copy(decanonicalize=True, ref_zone=ses.zone)
569+
self.assertLess(
570+
set(normalize(_) for _ in (a1,a2,a3)),
571+
set(normalize(_) for _ in accesses)
572+
)
573+
finally:
574+
if user1:
575+
user1.remove()
576+
if user2:
577+
user2.remove()
578+
if group:
579+
group.remove()
580+
if zone:
581+
zone.remove()
545582

546583
if __name__ == "__main__":
547584
# let the tests find the parent irods lib

0 commit comments

Comments
 (0)