Skip to content

Commit

Permalink
Even more review changes...
Browse files Browse the repository at this point in the history
  • Loading branch information
FifthPotato committed Jan 23, 2024
1 parent f5d108d commit 2a17876
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from irods.access import iRODSAccess
from irods.session import iRODSSession
from irods.meta import iRODSMeta, AVUOperation

Expand Down Expand Up @@ -33,6 +34,7 @@ def setUpClass(cls):
# unprivileged user creates test file
with iRODSSession(host='localhost', port=1247, user='alice', password='test', zone='tempZone') as unprivileged_user:
unprivileged_user.data_objects.create(cls.TEST_DATA_OBJECT_PATH)
unprivileged_user.acls.set( iRODSAccess('own', cls.TEST_DATA_OBJECT_PATH, 'rods', 'tempZone'))

coll = local_admin.collections.get("/tempZone")
# add metadata_guard config AVU to collection
Expand All @@ -51,6 +53,7 @@ def setUpClass(cls):
@classmethod
def tearDownClass(cls):
cls.restore_irods_config()

def test_guard_atomic_operations_admin_only(self):
# set metadata_guard config AVU on collection to admin_only and irods:: as protected prefix
with iRODSSession(host='localhost', port=1247, user='rods', password='rods', zone='tempZone') as local_admin:
Expand All @@ -67,6 +70,13 @@ def test_guard_atomic_operations_admin_only(self):
# "irods::" protected, so operation should fail
self.assertRaises(irods.exception.CAT_INSUFFICIENT_PRIVILEGE_LEVEL, lambda: obj.metadata.apply_atomic_operations( AVUOperation(operation='add', avu=iRODSMeta('irods::atr','val'))))

with iRODSSession(host='localhost', port=1247, user='rods', password='rods', zone='tempZone') as local_admin:
obj = local_admin.data_objects.get(self.TEST_DATA_OBJECT_PATH)

# admin should be allowed to modify "irods::"
obj.metadata.apply_atomic_operations( AVUOperation(operation='add', avu=iRODSMeta('irods::atr1','val1')))
self.assertEqual(obj.metadata['irods::atr1'], iRODSMeta('irods::atr1', 'val1'))

def test_guard_atomic_operations_editor_list(self):
# set metadata_guard config AVU on collection to admin_only: false and irods:: as protected prefix
# also, add test user as editor
Expand Down

0 comments on commit 2a17876

Please sign in to comment.