]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/tests/test_ceph_users.py
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / pybind / mgr / dashboard / tests / test_ceph_users.py
CommitLineData
1e59de90
TL
1import unittest.mock as mock
2
3from jsonschema import validate
4
5from ..controllers.ceph_users import CephUser, create_form
6from ..tests import ControllerTestCase
7
8auth_dump_mock = {"auth_dump": [
9 {"entity": "client.admin",
10 "key": "RANDOMFi7NwMARAA7RdGqdav+BEEFDEAD0x00g==",
11 "caps": {"mds": "allow *",
12 "mgr": "allow *",
13 "mon": "allow *",
14 "osd": "allow *"}},
15 {"entity": "client.bootstrap-mds",
16 "key": "2RANDOMi7NwMARAA7RdGqdav+BEEFDEAD0x00g==",
17 "caps": {"mds": "allow *",
18 "osd": "allow *"}}
19]}
20
21
22class CephUsersControllerTestCase(ControllerTestCase):
23 @classmethod
24 def setup_server(cls):
25 cls.setup_crud_controllers(CephUser)
26
27 @mock.patch('dashboard.services.ceph_service.CephService.send_command')
28 def test_get_all(self, send_command):
29 send_command.return_value = auth_dump_mock
30 self._get('/api/cluster/user')
31 self.assertStatus(200)
32 self.assertJsonBody([
33 {"entity": "client.admin",
34 "caps": {"mds": "allow *",
35 "mgr": "allow *",
36 "mon": "allow *",
37 "osd": "allow *"},
38 "key": "***********"
39 },
40 {"entity": "client.bootstrap-mds",
41 "caps": {"mds": "allow *",
42 "osd": "allow *"},
43 "key": "***********"
44 }
45 ])
46
47 def test_create_form(self):
48 form_dict = create_form.to_dict()
49 schema = {'schema': form_dict['control_schema'], 'layout': form_dict['ui_schema']}
50 validate(instance={'user_entity': 'foo',
51 'capabilities': [{"entity": "mgr", "cap": "allow *"}]},
52 schema=schema['schema'])