-
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
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,59 @@ | |
| # data.metadata(admin = True) generates a cloned object but for the one change to "admin". | ||
| data.metadata.admin = True | ||
|
|
||
| def test_admin_mode_and_keyword_exhibit_no_stickyness__issue_833(self): | ||
| # Create a rodsuser, and a session for that roduser. | ||
| adm = self.sess | ||
| user = d = None | ||
| try: | ||
| # Create a test user. | ||
| user = adm.users.create("bobby", "rodsuser") | ||
| user.modify("password", "bpass") | ||
|
|
||
| # This is a convenience function to (re)instantiate the test iRODSSessions: | ||
| def new_session(): | ||
| return iRODSSession( | ||
| port=adm.port, | ||
| zone=adm.zone, | ||
| host=adm.host, | ||
| user=user.name, | ||
| password="bpass", | ||
| ) | ||
|
|
||
| with new_session() as ses1: | ||
| d = ses1.data_objects.create(data_name:="/{adm.zone}/home/{user.name}/testfile".format(**locals())) | ||
| d.metadata(admin=True) | ||
|
|
||
| with new_session() as ses2: | ||
| # Repeat the fetch of the data object using the new session, so we are clean of old references. | ||
| d = ses2.data_objects.get(data_name) | ||
|
|
||
| # In this use of set(), we expect not to end up applying ADMIN_KW in the underlying API call. | ||
| # (Doing so as a rodsuser would raise INSUFFICIENT_PRIVILEGE_LEVEL and the test would fail.) | ||
| d.metadata.set('a','b') | ||
|
|
||
| # Check that the option flag for use of ADMIN_KW is not set. | ||
| self.assertFalse(d.metadata.admin) | ||
|
|
||
| # This function duplicates the way in which the client API endpoint calculates iRODS option keywords | ||
| # for the underlying API call: | ||
| get_call_keywords = lambda metacoll: metacoll._manager._updated_keywords((),) | ||
|
Check failure on line 837 in irods/test/meta_test.py
|
||
|
|
||
| # Applying admin=True should result in API flags containing ADMIN_KW among the lookup keys. | ||
| md_modified=d.metadata(admin=True) | ||
| self.assertIn(kw.ADMIN_KW, get_call_keywords(md_modified)) | ||
|
|
||
| # The modified admin setting should be reflected when reading it back from the object's | ||
| # internal options # bookkeeping. | ||
|
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. Is the trailing
Collaborator
Author
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. no , the extra # was to be deleted if I was editing better. But I can leave the word out if it makes more sense.
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. Yeah, let's remove that word. |
||
| self.assertTrue(md_modified.admin) | ||
|
|
||
| # But the original (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. | ||
|
Check failure on line 848 in irods/test/meta_test.py
|
||
| 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 this saying it duplicates the key-value pairs stored in the manager?
I'm struggling to understand what this does?
Uh oh!
There was an error while loading. Please reload this page.
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.
It emulates the internal calculation of api keywords given to the iRODS api, based on the input metacoll.
So for two different such objects:
and
is what you would expect.
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.
By "iRODS api", I take it you're referring to the PRC's interface and NOT the iRODS RPC interface, correct?
So, that lambda is using code that is private to the implementation to prove correctness?
Is there no way to do this without reaching behind the public API of the library?