rockstor / rockstor-core

Linux/BTRFS based Network Attached Storage(NAS)
http://rockstor.com/docs/contribute_section.html
GNU General Public License v3.0
558 stars 138 forks source link

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

Closed phillxnet closed 7 months ago

phillxnet commented 8 months ago

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:

Fixes #2807

phillxnet commented 8 months ago

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 commented 8 months ago

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: