-
Notifications
You must be signed in to change notification settings - Fork 74
fix sticky ADMIN_KW #834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix sticky ADMIN_KW #834
Changes from all commits
2e5f648
c571627
719820e
e48240c
5a84d01
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -798,6 +798,52 @@ | |
| # data.metadata(admin = True) generates a cloned object but for the one change to "admin". | ||
| data.metadata.admin = True | ||
|
|
||
| def test_destickifying_of_admin_option__issue_833(self): | ||
| # Create a rodsuser, and a session for that roduser. | ||
| adm = self.sess | ||
| user = d = None | ||
| try: | ||
| user = adm.users.create("bobby", "rodsuser") | ||
| user.modify("password", "bpass") | ||
| sessions = [] | ||
| for _ in range(2): | ||
| with iRODSSession( | ||
| port=adm.port, | ||
| zone=adm.zone, | ||
| host=adm.host, | ||
| user=user.name, | ||
| password="bpass", | ||
| ) as ses: | ||
| # Get a reference to a data object owned by the rodsuser, creating it if not already there. | ||
| d = ses.data_objects.create("/{adm.zone}/home/{user.name}/testfile".format(**locals())) | ||
|
|
||
| # d.metadata is a different MetadataManager instance (and d, a different session instance) on the | ||
| # second iteration of the loop as compared to the first. Thus, admin flags should not carry over. | ||
| if not sessions: | ||
| d.metadata(admin=True) | ||
| else: | ||
| # Should not be applying ADMIN_KW because INSUFFICIENT_PRIVILEGE_LEVEL exception would result | ||
| d.metadata.set('a','b') | ||
| sessions.append(ses) | ||
|
Comment on lines
+808
to
+827
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we simplify this by dropping the for-loop? |
||
|
|
||
| # Admin option should be false after the second loop iteration. | ||
| self.assertFalse(d.metadata.admin) | ||
|
|
||
| get_call_keywords = lambda metacoll: metacoll._manager._updated_keywords((),) | ||
|
Check failure on line 832 in irods/test/meta_test.py
|
||
|
|
||
| # Applying admin=True should result in API flags containing ADMIN_KW among the lookup keys. | ||
| self.assertIn(kw.ADMIN_KW, get_call_keywords(md_modified:=d.metadata(admin=True))) | ||
|
|
||
| # Admin option should be on in the object options bookkeeping. | ||
| self.assertTrue(md_modified.admin) | ||
|
|
||
| # However, the unmodified source object should not reflect use of an ADMIN_KW. | ||
| self.assertNotIn(kw.ADMIN_KW, get_call_keywords(d.metadata)) # keyword updates not reflected in copied obj. | ||
| finally: | ||
| if d: | ||
| d.unlink(force=True) | ||
| if user: | ||
| user.remove() | ||
|
|
||
| if __name__ == "__main__": | ||
| # let the tests find the parent irods lib | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
sesstill active beyond thewith-block?Wouldn't the cleanup logic run at the end of the
with-block?