Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions irods/manager/user_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,26 @@
self._get_session, "set-quota", "user", user_name, resource, "0"
)

@staticmethod
def _parse_user_and_zone(user_param, zone_param):
"""Parse out the uesr name ane zone name from USER and ZONE string parameters.
If the USER string contains # and a non-null-length ZONE spec, ensure that multiply specified zone names agree.

Check failure on line 51 in irods/manager/user_manager.py

View workflow job for this annotation

GitHub Actions / ruff-lint / ruff-check

Ruff E501

E501: Line too long (122 > 120) [pycodestyle:line-too-long]

Check failure on line 51 in irods/manager/user_manager.py

View workflow job for this annotation

GitHub Actions / ruff-lint / ruff-check

Ruff D208

D208: Docstring is over-indented [pydocstyle:over-indentation]
"""

Check failure on line 52 in irods/manager/user_manager.py

View workflow job for this annotation

GitHub Actions / ruff-lint / ruff-check

Ruff DOC501

DOC501: Raised exception `RuntimeError` missing from docstring [pydoclint:docstring-missing-exception]

Check failure on line 52 in irods/manager/user_manager.py

View workflow job for this annotation

GitHub Actions / ruff-lint / ruff-check

Ruff DOC201

DOC201: `return` is not documented in docstring [pydoclint:docstring-missing-returns]

Check failure on line 52 in irods/manager/user_manager.py

View workflow job for this annotation

GitHub Actions / ruff-lint / ruff-check

Ruff D213

D213: Multi-line docstring summary should start at the second line [pydocstyle:multi-line-summary-second-line]

Check failure on line 52 in irods/manager/user_manager.py

View workflow job for this annotation

GitHub Actions / ruff-lint / ruff-check

Ruff D205

D205: 1 blank line required between summary line and description [pydocstyle:missing-blank-line-after-summary]
if '#' in user_param:
u_parsed_user, u_parsed_zone = user_param.split('#',1)
if '#' in u_parsed_zone:
raise RuntimeError(f"{u_parsed_zone = } is wrongly formatted")
elif u_parsed_zone != "":

Check failure on line 57 in irods/manager/user_manager.py

View workflow job for this annotation

GitHub Actions / ruff-lint / ruff-check

Ruff RET506

RET506: Unnecessary `elif` after `raise` statement [flake8-return:superfluous-else-raise]
if zone_param != "" and u_parsed_zone != zone_param:

Check failure on line 58 in irods/manager/user_manager.py

View workflow job for this annotation

GitHub Actions / ruff-lint / ruff-check

Ruff PLR1714

PLR1714: Consider merging multiple comparisons: `zone_param not in ("", u_parsed_zone)`. Use a `set` if the elements are hashable. [Pylint:repeated-equality-comparison]
raise RuntimeError(f"Two nonzero-length zone names ({u_parsed_zone}, {zone_param}) were given and do not agree.")

Check failure on line 59 in irods/manager/user_manager.py

View workflow job for this annotation

GitHub Actions / ruff-lint / ruff-check

Ruff E501

E501: Line too long (133 > 120) [pycodestyle:line-too-long]
else:
raise RuntimeError(f"The compound user#zone specification may not contain a zero-length zone")

Check failure on line 61 in irods/manager/user_manager.py

View workflow job for this annotation

GitHub Actions / ruff-lint / ruff-check

Ruff F541

F541: f-string without any placeholders [Pyflakes:f-string-missing-placeholders]
return u_parsed_user, u_parsed_zone
return user_param, zone_param

Check failure on line 63 in irods/manager/user_manager.py

View workflow job for this annotation

GitHub Actions / ruff-lint / ruff-format

Ruff format

Improper formatting

def get(self, user_name, user_zone=""):
user_name, user_zone = self._parse_user_and_zone(user_name, user_zone)

if not user_zone:
user_zone = self.sess.zone

Expand Down Expand Up @@ -121,15 +140,20 @@
def remove(self, user_name, user_zone="", _object=None):
if _object is None:
_object = self.get(user_name, user_zone)

if _object.type == "rodsgroup":
uz_args = ( f"{_object.name}", )
else:
uz_args = ( f"{_object.name}#{_object.zone}", )

Check failure on line 147 in irods/manager/user_manager.py

View workflow job for this annotation

GitHub Actions / ruff-lint / ruff-format

Ruff format

Improper formatting

message_body = GeneralAdminRequest(
"rm",
(
"user"
if (_object.type != "rodsgroup" or self.sess.server_version < (4, 3, 2))
else "group"
),
user_name,
user_zone,
*uz_args,
)
request = iRODSMessage(
"RODS_API_REQ", msg=message_body, int_info=api_number["GENERAL_ADMIN_AN"]
Expand Down
17 changes: 16 additions & 1 deletion irods/test/admin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import os
import sys
import unittest
from irods.models import User, Group
from irods.column import Like
from irods.models import Collection, Group, User
from irods.exception import (
UserDoesNotExist,
ResourceDoesNotExist,
Expand Down Expand Up @@ -73,6 +74,20 @@
with self.assertRaises(UserDoesNotExist):
self.sess.users.get(self.new_user_name, self.sess.zone)

def testissue_763(self):
remote_zone = remote_user = None
try:
remote_zone = (sess := self.sess).zones.create('other_zone', 'remote')
remote_user = sess.users.create(user_name='myuser',user_type='rodsuser',user_zone=remote_zone.name)

Check failure on line 81 in irods/test/admin_test.py

View workflow job for this annotation

GitHub Actions / ruff-lint / ruff-format

Ruff format

Improper formatting
remote_user.remove()
remaining_collections = list(
sess.query(Collection).filter(Like(Collection.name, f'%/{remote_user}#{remote_zone}'))
)
self.assertEqual(len(remaining_collections), 0)
finally:
if remote_zone:
remote_zone.remove()

def test_create_with_user_options__issue_759(self):
gpadmin_user = remote_zone = None
try:
Expand Down
1 change: 1 addition & 0 deletions irods/test/user_group_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def generator(p=OLDPASS):
shutil.rmtree(ENV_DIR)
ses.users.remove("alice")


def test_modifying_password_at_various_lengths__issue_328(self):
ses = self.sess
try:
Expand Down
Loading