Skip to content

[#759] scan and apply user_zone properly when igroupadmin creates a user #760

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

d-w-moore
Copy link
Collaborator

No description provided.

@d-w-moore
Copy link
Collaborator Author

need to write a test wherein we create an entry in the catalog for a remote-zone user, then add and remove that user from a group.

_user_name = user_name + ("" if not user_zone else f"#{user_zone}")
else:
_user_name = user_name
user_name, user_zone = user_name.split("#")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two more cases which we might want to consider / test...

  1. What should happen if create_with_password is called like this?
groupadmin.users.create_with_password("newUser#tempZone", "newPassword", user_zone="otherZone")
  1. Or this?
groupadmin.users.create_with_password("newUser#tempZone#otherZone", "newPassword")

For reference, iadmin mkuser returns a USER_INVALID_USERNAME_FORMAT error when doing something like (2). I don't actually know if that's coming from the client or server side.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither of those cases make sense to me. Can you explain what the goal of those are?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the user attempting to create a remote user in the local zone?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think he's just writing a pathological test to check the behavior of the system.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the iRODS server accept case 1?!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. It isn't clear to me how much is client responsibility and how much should rest with the server, though. We could, in the client, test both user and zone for being properly formatted but I have a feeling that should rest more with the server, rather than installing a redundant and possibly incorrect such identifier filtering operation in the client code

That's fair. I'm interested in testing the parameters available in this function to the extent that they are the responsibility of this client. We don't need to test the server's behavior, just that the inputs to the iRODS API call are what we want/expect for any given set of inputs to this function.

We can discuss further offline to reach an understanding and then we can move this along.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some discussion, we decided that create_with_password should reject user_name parameter values which contain the zone name delimited by an octothorpe ("bad"). Here's a complete set of cases to demonstrate the requirements:

# tempZone is local; otherZone is remote; fictionZone does not exist
groupadmin.users.create_with_password("newUser", "newPassword") # 1. okay - use tempZone
groupadmin.users.create_with_password("newUser", "newPassword", user_zone="tempZone") # 2. okay
groupadmin.users.create_with_password("newUser", "newPassword", user_zone="otherZone") # 3. okay
groupadmin.users.create_with_password("newUser", "newPassword", user_zone="fictionZone") # 4. okay - but error from server
groupadmin.users.create_with_password("newUser#tempZone", "newPassword") # 5. bad
groupadmin.users.create_with_password("newUser#otherZone", "newPassword") # 6. bad
groupadmin.users.create_with_password("newUser#fictionZone", "newPassword") # 7. bad
groupadmin.users.create_with_password("newUser#tempZone", "newPassword", user_zone="tempZone") # 8. bad
groupadmin.users.create_with_password("newUser#tempZone", "newPassword", user_zone="otherZone") # 9. bad
groupadmin.users.create_with_password("newUser#tempZone", "newPassword", user_zone="fictionZone") # 10. bad

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm realizing that we kinda changed the requirements a little bit in this comment, so I'm going to update this to reflect that...

# tempZone is local; otherZone is remote; fictionZone does not exist
groupadmin.users.create_with_password("newUser", "newPassword") # 1. okay - use tempZone
groupadmin.users.create_with_password("newUser", "newPassword", user_zone="tempZone") # 2. okay
groupadmin.users.create_with_password("newUser", "newPassword", user_zone="otherZone") # 3. bad
groupadmin.users.create_with_password("newUser", "newPassword", user_zone="fictionZone") # 4. bad
groupadmin.users.create_with_password("newUser#tempZone", "newPassword") # 5. bad
groupadmin.users.create_with_password("newUser#otherZone", "newPassword") # 6. bad
groupadmin.users.create_with_password("newUser#fictionZone", "newPassword") # 7. bad
groupadmin.users.create_with_password("newUser#tempZone", "newPassword", user_zone="tempZone") # 8. bad
groupadmin.users.create_with_password("newUser#tempZone", "newPassword", user_zone="otherZone") # 9. bad
groupadmin.users.create_with_password("newUser#tempZone", "newPassword", user_zone="fictionZone") # 10. bad

Copy link
Collaborator Author

@d-w-moore d-w-moore Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to test all of the above? i.e. that they raise an exception where labelled as bad?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice, but not strictly speaking required. Maybe we can just make an issue for it for later. I think it would be good to at least manually test these cases so that we know things are working as expected.

_user_name = user_name + ("" if not user_zone else f"#{user_zone}")
else:
_user_name = user_name
user_name, user_zone = user_name.split("#")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it can be appended to help form the _user_name parameter in line 72.

Sorry, I should clarify. I was more referring to the fact that the user_zone parameter is not passed to the server directly. If provided, it is grafted to the user_name, but not sent as a separate parameter to the GeneralAdmin API.

Anyway, this conversation was originally about adding some pathological tests around this feature. Perhaps we should open a separate issue for that for later if things are working as intended now. Then, we can address that at another time and get this in for the next release.

Copy link
Contributor

@korydraughn korydraughn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants