diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /src/pybind/mgr/dashboard/tests/test_ceph_users.py | |
parent | Initial commit. (diff) | |
download | ceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/pybind/mgr/dashboard/tests/test_ceph_users.py')
-rw-r--r-- | src/pybind/mgr/dashboard/tests/test_ceph_users.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/pybind/mgr/dashboard/tests/test_ceph_users.py b/src/pybind/mgr/dashboard/tests/test_ceph_users.py new file mode 100644 index 000000000..9e0ee525b --- /dev/null +++ b/src/pybind/mgr/dashboard/tests/test_ceph_users.py @@ -0,0 +1,52 @@ +import unittest.mock as mock + +from jsonschema import validate + +from ..controllers.ceph_users import CephUser, create_form +from ..tests import ControllerTestCase + +auth_dump_mock = {"auth_dump": [ + {"entity": "client.admin", + "key": "RANDOMFi7NwMARAA7RdGqdav+BEEFDEAD0x00g==", + "caps": {"mds": "allow *", + "mgr": "allow *", + "mon": "allow *", + "osd": "allow *"}}, + {"entity": "client.bootstrap-mds", + "key": "2RANDOMi7NwMARAA7RdGqdav+BEEFDEAD0x00g==", + "caps": {"mds": "allow *", + "osd": "allow *"}} +]} + + +class CephUsersControllerTestCase(ControllerTestCase): + @classmethod + def setup_server(cls): + cls.setup_crud_controllers(CephUser) + + @mock.patch('dashboard.services.ceph_service.CephService.send_command') + def test_get_all(self, send_command): + send_command.return_value = auth_dump_mock + self._get('/api/cluster/user') + self.assertStatus(200) + self.assertJsonBody([ + {"entity": "client.admin", + "caps": {"mds": "allow *", + "mgr": "allow *", + "mon": "allow *", + "osd": "allow *"}, + "key": "***********" + }, + {"entity": "client.bootstrap-mds", + "caps": {"mds": "allow *", + "osd": "allow *"}, + "key": "***********" + } + ]) + + def test_create_form(self): + form_dict = create_form.to_dict() + schema = {'schema': form_dict['control_schema'], 'layout': form_dict['ui_schema']} + validate(instance={'user_entity': 'foo', + 'capabilities': [{"entity": "mgr", "cap": "allow *"}]}, + schema=schema['schema']) |