+
Skip to content

Conversation

phillxnet
Copy link
Member

Update to reflect current OS base (openSUSE), and its users associated with common system services.

Includes

  • incidental string.format (and % use) to fstrings - user.py.

N.B. presented as two commits to assist in review & clarify intended functional changes.

Fixes #2634

phillxnet added 2 commits July 9, 2024 17:04
Update to reflect current OS base (openSUSE), and its users
associated with common system services.
Incidental update from older % string formatter included.
@phillxnet
Copy link
Member Author

Testing

We already have unit tests in place for the guards/fencing around our restricted user list: we have just revised that list.

Leap 15.5 OS Pre PR

cd /opt/rockstor/src/rockstor
poetry run django-admin test -v 2 -p test_user.py
...
Ran 17 tests in 4.413s

OK

We then modify the following test line:

response = self.client.put(f"{self.BASE_URL}/bin", data=data)

To instead reference one of our additional restricted system usernames: i.e. "lp":

    response = self.client.put(f"{self.BASE_URL}/lp", data=data)

and we get our expected failure on this unrestricted system username:

======================================================================
FAIL: test_put_requests (rockstor.storageadmin.tests.test_user.UserTests.test_put_requests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/rockstor/src/rockstor/storageadmin/tests/test_user.py", line 323, in test_put_requests
    self.assertEqual(
AssertionError: 200 != 500 : {'id': None, 'groupname': 'lp', 'managed_user': False, 'has_pincard': False, 'pincard_allowed': 'no', 'username': 'lp', 'uid': 490, 'gid': 487, 'public_key': None, 'shell': '/usr/sbin/nologin', 'homedir': None, 'email': None, 'admin': False, 'user': None, 'group': None, 'smb_shares': []}

----------------------------------------------------------------------
Ran 17 tests in 4.418s

FAILED (failures=1)

I.e. the user modification was allowed (200): AssertionError: 200 != 500

Leap 15.6 OS Post PR (rpm derived install)

Using the same modified test as above: i.e. "bin" to "lp" and we get:

======================================================================
FAIL: test_put_requests (rockstor.storageadmin.tests.test_user.UserTests.test_put_requests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/rockstor/src/rockstor/storageadmin/tests/test_user.py", line 330, in test_put_requests
    self.assertEqual(response.data[0], e_msg)
AssertionError: 'Editing restricted user (lp) is not supported.' != 'Editing restricted user (bin) is not supported.'
- Editing restricted user (lp) is not supported.
?                          ^^
+ Editing restricted user (bin) is not supported.
?                          ^^^


----------------------------------------------------------------------
Ran 17 tests in 4.551s

FAILED (failures=1)

Confirming that our newly added "lp" user is now treated as a restricted user: as "bin" was already.

@phillxnet phillxnet merged commit 1c52870 into rockstor:testing Jul 10, 2024
@phillxnet phillxnet deleted the 2634-revise-restricted-system-usernames branch July 10, 2024 09:04
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

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载