Skip to content
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

[t] Add Group with custom GID fails with type error #2807 #2815

Conversation

phillxnet
Copy link
Member

@phillxnet phillxnet commented Mar 22, 2024

Add type hints to run_command() to ensure callers are passing the expected argument types, and add some type hints &/or typecasts to run_command callers in:

  • user.py
  • active_directory.py
  • qgourp_ids list to enforce str() members only in qgroup_maxout_limit.py.
  • acl.py to enforce str() members of run_command() args.
  • minor refactor of parameter name in run_command() as it shadowed another context.

Fixes #2807

Add type hints to run_command() to ensure callers are passing
the expected argument types and add some type hints &/or typecasts
to run_command callers in:
- user.py
- active_directory.py
- qgourp_ids list to enforce str() members only in qgroup_maxout_limit.py.
- acl.py to enforce str() members of run_command() args.
@phillxnet
Copy link
Member Author

phillxnet commented Mar 22, 2024

Testing

An rpmbuild resulted in the following single failure:

======================================================================
FAIL: test_post_requests (rockstor.storageadmin.tests.test_user.UserTests.test_post_requests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/rockstor-buildbot/worker/Poetry-Build-on-Leap15-5/rpmbuild/rockstor-core-5.0.8-2815/src/rockstor/storageadmin/tests/test_user.py", line 195, in test_post_requests
    self.assertEqual(
AssertionError: 200 != 500 : {'id': 3, 'groupname': 'users', 'managed_user': True, 'has_pincard': False, 'pincard_allowed': 'no', 'username': 'newUser', 'uid': 3, 'gid': 5, 'public_key': None, 'shell': '/bin/bash', 'homedir': '/home/newUser', 'email': None, 'admin': True, 'user': 5, 'group': 1, 'smb_shares': []}
----------------------------------------------------------------------
Ran 279 tests in 30.602s
FAILED (failures=1)

On another test machine we have the following test results:

lbuildvm:/opt/rockstor/src/rockstor # poetry run django-admin test -v 2
...
----------------------------------------------------------------------
Ran 279 tests in 31.484s

OK

Investigating what system sensitivities we may have on the initial failing machine.


We have the following spin-off issue incidentally related to the test by-hand procedures used during the development of this PR's branch:
Inadvertent host sensitivity re existing user named 'testuser' in UserTests #2816

As a consequent, on the previously failing rpmbuild host, executing userdel testuser resulted in a successful rpm build.

@phillxnet
Copy link
Member Author

Testing 2

Post the proposed changes, an install of an rpm built using the proposed issue/pr branch no longer fails to create legitimate new groups with custom GID:

System - Groups - Add Group (button)

Groupname: PR2815
Put this group under Rockstor management? (unticked)
GID 3333

Custom-group-guid-creation

Resulting in the expected creation of this group with custom GID:

Groupname GID Actions
nobody 65534  
nogroup 65533  
PR2815 3333  

And we have the expected new group on the underlying OS:

rleap15-5:~ # cat /etc/group | grep PR2815
PR2815:x:3333:

@phillxnet phillxnet merged commit 4d690ef into rockstor:testing Mar 25, 2024
@phillxnet phillxnet deleted the 2807-t]-Add-Group-with-custom-GID-fails-with-type-error branch March 25, 2024 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant