]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/tests/test_ssl.py
import quincy beta 17.1.0
[ceph.git] / ceph / src / pybind / mgr / dashboard / tests / test_ssl.py
1 import errno
2 import unittest
3
4 from ..tests import CLICommandTestMixin, CmdException
5
6
7 class SslTest(unittest.TestCase, CLICommandTestMixin):
8
9 def test_ssl_certificate_and_key(self):
10 with self.assertRaises(CmdException) as ctx:
11 self.exec_cmd('set-ssl-certificate', inbuf='', mgr_id='x')
12 self.assertEqual(ctx.exception.retcode, -errno.EINVAL)
13 self.assertEqual(str(ctx.exception), 'Please specify the certificate with "-i" option')
14
15 result = self.exec_cmd('set-ssl-certificate', inbuf='content', mgr_id='x')
16 self.assertEqual(result, 'SSL certificate updated')
17
18 with self.assertRaises(CmdException) as ctx:
19 self.exec_cmd('set-ssl-certificate-key', inbuf='', mgr_id='x')
20 self.assertEqual(ctx.exception.retcode, -errno.EINVAL)
21 self.assertEqual(str(ctx.exception), 'Please specify the certificate key with "-i" option')
22
23 result = self.exec_cmd('set-ssl-certificate-key', inbuf='content', mgr_id='x')
24 self.assertEqual(result, 'SSL certificate key updated')
25
26 def test_set_mgr_created_self_signed_cert(self):
27 result = self.exec_cmd('create-self-signed-cert')
28 self.assertEqual(result, 'Self-signed certificate created')