]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: python unit tests refactoring
authorAlfonso Martínez <almartin@redhat.com>
Wed, 3 Nov 2021 09:17:21 +0000 (10:17 +0100)
committerAlfonso Martínez <almartin@redhat.com>
Wed, 3 Nov 2021 09:36:47 +0000 (10:36 +0100)
* Controller tests: cherrypy config: authentication disabled by default; ability to pass custom config (e.g. enable authentication).
* Auth controller: add tests; test that unauthorized request fails when authentication is enabled.
* DocsTest: clear ENDPOINT_MAP so the test_gen_tags test becomes deterministic.
* pylint: disable=no-name-in-module: fix imports in tests.

Fixes: https://tracker.ceph.com/issues/53083
Signed-off-by: Alfonso Martínez <almartin@redhat.com>
28 files changed:
doc/dev/developer_guide/dash-devel.rst
src/pybind/mgr/dashboard/tests/__init__.py
src/pybind/mgr/dashboard/tests/test_access_control.py
src/pybind/mgr/dashboard/tests/test_api_auditing.py
src/pybind/mgr/dashboard/tests/test_auth.py
src/pybind/mgr/dashboard/tests/test_cephfs.py
src/pybind/mgr/dashboard/tests/test_controllers.py
src/pybind/mgr/dashboard/tests/test_docs.py
src/pybind/mgr/dashboard/tests/test_erasure_code_profile.py
src/pybind/mgr/dashboard/tests/test_exceptions.py
src/pybind/mgr/dashboard/tests/test_feature_toggles.py
src/pybind/mgr/dashboard/tests/test_grafana.py
src/pybind/mgr/dashboard/tests/test_home.py
src/pybind/mgr/dashboard/tests/test_host.py
src/pybind/mgr/dashboard/tests/test_iscsi.py
src/pybind/mgr/dashboard/tests/test_orchestrator.py
src/pybind/mgr/dashboard/tests/test_osd.py
src/pybind/mgr/dashboard/tests/test_plugin_debug.py
src/pybind/mgr/dashboard/tests/test_pool.py
src/pybind/mgr/dashboard/tests/test_prometheus.py
src/pybind/mgr/dashboard/tests/test_rbd_mirroring.py
src/pybind/mgr/dashboard/tests/test_rest_tasks.py
src/pybind/mgr/dashboard/tests/test_rgw.py
src/pybind/mgr/dashboard/tests/test_rgw_client.py
src/pybind/mgr/dashboard/tests/test_settings.py
src/pybind/mgr/dashboard/tests/test_sso.py
src/pybind/mgr/dashboard/tests/test_tools.py
src/pybind/mgr/dashboard/tests/test_versioning.py

index a5ffaa32c17634f8cc0cce7738d63b9e4940cec2..de6f90c34740271b784f1bd4f788daa867bafc0d 100644 (file)
@@ -1736,8 +1736,8 @@ If we want to write a unit test for the above ``Ping`` controller, create a
   class PingTest(ControllerTestCase):
       @classmethod
       def setup_test(cls):
-          Ping._cp_config['tools.authenticate.on'] = False
-          cls.setup_controllers([Ping])
+          cp_config = {'tools.authenticate.on': True}
+          cls.setup_controllers([Ping], cp_config=cp_config)
 
       def test_ping(self):
           self._get("/api/ping")
@@ -1747,8 +1747,8 @@ If we want to write a unit test for the above ``Ping`` controller, create a
 The ``ControllerTestCase`` class starts by initializing a CherryPy webserver.
 Then it will call the ``setup_test()`` class method where we can explicitly
 load the controllers that we want to test. In the above example we are only
-loading the ``Ping`` controller. We can also disable authentication of a
-controller at this stage, as depicted in the example.
+loading the ``Ping`` controller. We can also provide ``cp_config`` in order to
+update the controller's cherrypy config (e.g. enable authentication as shown in the example).
 
 How to update or create new dashboards in grafana?
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
index 9e73b85d608b9cf5561af09de7b63b3db86e328d..6ae01cca172767115e49da05f74ecf9260d7dd5a 100644 (file)
@@ -5,6 +5,7 @@ import json
 import logging
 import threading
 import time
+from typing import Any, Dict
 from unittest.mock import Mock
 
 import cherrypy
@@ -101,12 +102,18 @@ class ControllerTestCase(helper.CPWebCase):
     _endpoints_cache = {}
 
     @classmethod
-    def setup_controllers(cls, ctrl_classes, base_url=''):
+    def setup_controllers(cls, ctrl_classes, base_url='', cp_config: Dict[str, Any] = None):
         if not isinstance(ctrl_classes, list):
             ctrl_classes = [ctrl_classes]
         mapper = cherrypy.dispatch.RoutesDispatcher()
         endpoint_list = []
         for ctrl in ctrl_classes:
+            ctrl._cp_config = {
+                'tools.dashboard_exception_handler.on': True,
+                'tools.authenticate.on': False
+            }
+            if cp_config:
+                ctrl._cp_config.update(cp_config)
             inst = ctrl()
 
             # We need to cache the controller endpoints because
index 3a435eb97399dc3361845fa6df73c429c95b1222..b97082cbd47dfdcdb2a39b033880667ce5a09a61 100644 (file)
@@ -15,7 +15,7 @@ from ..security import Permission, Scope
 from ..services.access_control import SYSTEM_ROLES, AccessControlDB, \
     PasswordPolicy, load_access_control_db, password_hash
 from ..settings import Settings
-from . import CLICommandTestMixin, CmdException  # pylint: disable=no-name-in-module
+from ..tests import CLICommandTestMixin, CmdException
 
 
 class AccessControlTest(unittest.TestCase, CLICommandTestMixin):
index de6e7cdc5f784e3edcdb7a599528d645b51ad5ce..dd47b26c4e832e87a8132e38f23db42ecdc0cca7 100644 (file)
@@ -10,7 +10,7 @@ except ImportError:
 
 from .. import mgr
 from ..controllers import RESTController, Router
-from . import ControllerTestCase, KVStoreMockMixin  # pylint: disable=no-name-in-module
+from ..tests import ControllerTestCase, KVStoreMockMixin
 
 
 # pylint: disable=W0613
index 6f1d2a084ec461741c4bb270e5c70f8069d12b7a..698db40e1e5ef5df0f7c8aad2c919ba554775274 100644 (file)
@@ -1,7 +1,15 @@
 import unittest
+from unittest.mock import Mock, patch
 
 from .. import mgr
+from ..controllers.auth import Auth
 from ..services.auth import JwtManager
+from ..tests import ControllerTestCase
+
+mgr.get_module_option.return_value = JwtManager.JWT_TOKEN_TTL
+mgr.get_store.return_value = 'jwt_secret'
+mgr.ACCESS_CTRL_DB = Mock()
+mgr.ACCESS_CTRL_DB.get_attempt.return_value = 1
 
 
 class JwtManagerTest(unittest.TestCase):
@@ -18,3 +26,41 @@ class JwtManagerTest(unittest.TestCase):
         self.assertIsInstance(decoded_token, dict)
         self.assertEqual(decoded_token['iss'], 'ceph-dashboard')
         self.assertEqual(decoded_token['username'], 'my-username')
+
+
+class AuthTest(ControllerTestCase):
+
+    @classmethod
+    def setup_server(cls):
+        cls.setup_controllers([Auth])
+
+    def test_request_not_authorized(self):
+        self.setup_controllers([Auth], cp_config={'tools.authenticate.on': True})
+        self._post('/api/auth/logout')
+        self.assertStatus(401)
+
+    @patch('dashboard.controllers.auth.JwtManager.gen_token', Mock(return_value='my-token'))
+    @patch('dashboard.controllers.auth.AuthManager.authenticate', Mock(return_value={
+        'permissions': {'read-only': ['read']},
+        'pwdExpirationDate': 1000000,
+        'pwdUpdateRequired': False
+    }))
+    def test_login(self):
+        self._post('/api/auth', {'username': 'my-user', 'password': 'my-pass'})
+        self.assertStatus(201)
+        self.assertJsonBody({
+            'token': 'my-token',
+            'username': 'my-user',
+            'permissions': {'read-only': ['read']},
+            'pwdExpirationDate': 1000000,
+            'sso': False,
+            'pwdUpdateRequired': False
+        })
+
+    @patch('dashboard.controllers.auth.JwtManager', Mock())
+    def test_logout(self):
+        self._post('/api/auth/logout')
+        self.assertStatus(200)
+        self.assertJsonBody({
+            'redirect_url': '#/login'
+        })
index 5c35cab329cd6e980b120c6973ef70d07972cb55..ae4253543841d122d0b69ea97f2eed5d2e5804a9 100644 (file)
@@ -7,7 +7,7 @@ except ImportError:
     from unittest.mock import patch, Mock
 
 from ..controllers.cephfs import CephFS
-from . import ControllerTestCase  # pylint: disable=no-name-in-module
+from ..tests import ControllerTestCase
 
 
 class MetaDataMock(object):
index 8daa2dd0ea51d7c10083b00b96dcd723d5ceadd7..0f1662ebd0a241281c7d42f80216a537c6f86955 100644 (file)
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 
 from ..controllers import APIRouter, BaseController, Endpoint, RESTController, Router
-from . import ControllerTestCase  # pylint: disable=no-name-in-module
+from ..tests import ControllerTestCase
 
 
 @Router("/btest/{key}", base_url="/ui", secure=False)
index 3610144b2cc3e0944c7e401a4d47d74864b0febe..ded0c140e6704b351b77743bc2522526ddfde2c7 100644 (file)
@@ -3,10 +3,10 @@
 import unittest
 
 from ..api.doc import SchemaType
-from ..controllers import APIDoc, APIRouter, Endpoint, EndpointDoc, RESTController
+from ..controllers import ENDPOINT_MAP, APIDoc, APIRouter, Endpoint, EndpointDoc, RESTController
 from ..controllers._version import APIVersion
 from ..controllers.docs import Docs
-from . import ControllerTestCase  # pylint: disable=no-name-in-module
+from ..tests import ControllerTestCase
 
 
 # Dummy controller and endpoint that can be assigned with @EndpointDoc and @GroupDoc
@@ -67,6 +67,7 @@ class DocDecoratorsTest(ControllerTestCase):
 class DocsTest(ControllerTestCase):
     @classmethod
     def setup_server(cls):
+        ENDPOINT_MAP.clear()
         cls.setup_controllers([DecoratedController, Docs], "/test")
 
     def test_type_to_str(self):
@@ -121,8 +122,8 @@ class DocsTest(ControllerTestCase):
             self.assertTrue(any(base in key.split('/')[1] for base in ['api', 'ui-api']))
 
     def test_gen_tags(self):
-        outcome = Docs()._gen_tags(False)[0]
-        self.assertEqual({'description': 'Group description', 'name': 'FooGroup'}, outcome)
+        outcome = Docs._gen_tags(False)
+        self.assertEqual([{'description': 'Group description', 'name': 'FooGroup'}], outcome)
 
 
 class TestEndpointDocWrapper(unittest.TestCase):
index 8ff1490708ff0e0e4c01a41dd331670b1f369282..d1b032a514f30cdd33b773803d6b241495705214 100644 (file)
@@ -2,7 +2,7 @@
 
 from .. import mgr
 from ..controllers.erasure_code_profile import ErasureCodeProfile
-from . import ControllerTestCase  # pylint: disable=no-name-in-module
+from ..tests import ControllerTestCase
 
 
 class ErasureCodeProfileTest(ControllerTestCase):
@@ -21,8 +21,6 @@ class ErasureCodeProfileTest(ControllerTestCase):
             'fs_map': {'filesystems': []},
 
         }[key]
-        # pylint: disable=protected-access
-        ErasureCodeProfile._cp_config['tools.authenticate.on'] = False
         cls.setup_controllers([ErasureCodeProfile])
 
     def test_list(self):
index 8e20bfb2373634685e2c329a57dacc797bbcc851..ff4edabddc504069275b636030959aded54777ba 100644 (file)
@@ -8,8 +8,8 @@ from ..controllers import Endpoint, RESTController, Router, Task
 from ..services.ceph_service import SendCommandError
 from ..services.exception import handle_rados_error, \
     handle_send_command_error, serialize_dashboard_exception
+from ..tests import ControllerTestCase
 from ..tools import NotificationQueue, TaskManager, ViewCache
-from . import ControllerTestCase  # pylint: disable=no-name-in-module
 
 
 # pylint: disable=W0613
index fce7c60720ea5cc6b1001db27e1c6285d4951f68..3ba434dee87c0d8937a59562a93a163e876a03c5 100644 (file)
@@ -8,7 +8,7 @@ except ImportError:
     from unittest.mock import Mock, patch
 
 from ..plugins.feature_toggles import Actions, Features, FeatureToggles
-from . import KVStoreMockMixin  # pylint: disable=no-name-in-module
+from ..tests import KVStoreMockMixin
 
 
 class SettingsTest(unittest.TestCase, KVStoreMockMixin):
index d9b15e8231e5b0006b9b91c0ce6b5b201ef22fda..f54219c9f132c0cc6a5bde185b70a8ab9e7129d0 100644 (file)
@@ -11,14 +11,12 @@ from requests import RequestException
 from ..controllers.grafana import Grafana
 from ..grafana import GrafanaRestClient
 from ..settings import Settings
-from . import ControllerTestCase, KVStoreMockMixin  # pylint: disable=no-name-in-module
+from ..tests import ControllerTestCase, KVStoreMockMixin
 
 
 class GrafanaTest(ControllerTestCase, KVStoreMockMixin):
     @classmethod
     def setup_server(cls):
-        # pylint: disable=protected-access
-        Grafana._cp_config['tools.authenticate.on'] = False
         cls.setup_controllers([Grafana])
 
     def setUp(self):
index b0641f068f30ea483427f2b853f57143448cfd9c..883c6cc6a5f2949556dd1ee89109a408d0c77c07 100644 (file)
@@ -9,7 +9,7 @@ except ImportError:
 
 from .. import mgr
 from ..controllers.home import HomeController, LanguageMixin
-from . import ControllerTestCase, FakeFsMixin  # pylint: disable=no-name-in-module
+from ..tests import ControllerTestCase, FakeFsMixin
 
 logger = logging.getLogger()
 
index e15885a56951a9eefd1cf282508f5396e3133395..07915aee29b21fd8e767db594a41e81bde45eacc 100644 (file)
@@ -8,8 +8,8 @@ from orchestrator import HostSpec, InventoryHost
 from .. import mgr
 from ..controllers._version import APIVersion
 from ..controllers.host import Host, HostUi, get_device_osd_map, get_hosts, get_inventories
+from ..tests import ControllerTestCase
 from ..tools import NotificationQueue, TaskManager
-from . import ControllerTestCase  # pylint: disable=no-name-in-module
 
 
 @contextlib.contextmanager
@@ -44,8 +44,6 @@ class HostControllerTest(ControllerTestCase):
     def setup_server(cls):
         NotificationQueue.start_queue()
         TaskManager.init()
-        # pylint: disable=protected-access
-        Host._cp_config['tools.authenticate.on'] = False
         cls.setup_controllers([Host])
 
     @classmethod
@@ -340,8 +338,6 @@ class HostUiControllerTest(ControllerTestCase):
 
     @classmethod
     def setup_server(cls):
-        # pylint: disable=protected-access
-        HostUi._cp_config['tools.authenticate.on'] = False
         cls.setup_controllers([HostUi])
 
     def test_labels(self):
index addcc09a1c485ba30895724db225c1215c16f73b..f3f786c2928e0de66133e753b847bf564bcf5f68 100644 (file)
@@ -19,11 +19,8 @@ from ..rest_client import RequestException
 from ..services.exception import handle_request_error
 from ..services.iscsi_client import IscsiClient
 from ..services.orchestrator import OrchClient
+from ..tests import CLICommandTestMixin, CmdException, ControllerTestCase, KVStoreMockMixin
 from ..tools import NotificationQueue, TaskManager
-from . import CLICommandTestMixin  # pylint: disable=no-name-in-module
-from . import CmdException  # pylint: disable=no-name-in-module
-from . import ControllerTestCase  # pylint: disable=no-name-in-module
-from . import KVStoreMockMixin  # pylint: disable=no-name-in-module
 
 
 class IscsiTestCli(unittest.TestCase, CLICommandTestMixin):
@@ -86,9 +83,6 @@ class IscsiTestController(ControllerTestCase, KVStoreMockMixin):
         TaskManager.init()
         OrchClient.instance().available = lambda: False
         mgr.rados.side_effect = None
-        # pylint: disable=protected-access
-        Iscsi._cp_config['tools.authenticate.on'] = False
-        IscsiTarget._cp_config['tools.authenticate.on'] = False
         cls.setup_controllers([Iscsi, IscsiTarget])
 
     @classmethod
@@ -752,8 +746,6 @@ class IscsiTestController(ControllerTestCase, KVStoreMockMixin):
 class TestIscsiUi(ControllerTestCase):
     @classmethod
     def setup_server(cls):
-        # pylint: disable=protected-access
-        IscsiUi._cp_config['tools.authenticate.on'] = False
         cls.setup_controllers([IscsiUi])
 
     @mock.patch('dashboard.services.tcmu_service.TcmuService.get_image_info')
index d9ee85cf3053fd79891537eba7b1db852047d48e..ded06ba50e49327ee8b743429acb4323b6307604 100644 (file)
@@ -6,7 +6,7 @@ from orchestrator import Orchestrator as OrchestratorBase
 
 from ..controllers.orchestrator import Orchestrator
 from ..services.orchestrator import OrchFeature
-from . import ControllerTestCase  # pylint: disable=no-name-in-module
+from ..tests import ControllerTestCase
 
 
 class OrchestratorControllerTest(ControllerTestCase):
@@ -15,8 +15,6 @@ class OrchestratorControllerTest(ControllerTestCase):
 
     @classmethod
     def setup_server(cls):
-        # pylint: disable=protected-access
-        Orchestrator._cp_config['tools.authenticate.on'] = False
         cls.setup_controllers([Orchestrator])
 
     @mock.patch('dashboard.controllers.orchestrator.OrchClient.instance')
index 669dd63bbf8b64f941e6897e530c594e7c09dd18..790c9b359262cab34c0bea42fd5707e2aef68a6b 100644 (file)
@@ -9,8 +9,8 @@ from ceph.deployment.service_spec import PlacementSpec  # type: ignore
 
 from .. import mgr
 from ..controllers.osd import Osd
+from ..tests import ControllerTestCase
 from ..tools import NotificationQueue, TaskManager
-from . import ControllerTestCase  # pylint: disable=no-name-in-module
 from .helper import update_dict  # pylint: disable=import-error
 
 
@@ -191,7 +191,6 @@ class OsdHelper(object):
 class OsdTest(ControllerTestCase):
     @classmethod
     def setup_server(cls):
-        Osd._cp_config['tools.authenticate.on'] = False  # pylint: disable=protected-access
         cls.setup_controllers([Osd])
         NotificationQueue.start_queue()
         TaskManager.init()
index 5010d9768ffeafe58a500c6a65318542d1f8d318..6f8075e4f4e36ded93f30de4d853361738df82ef 100644 (file)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-from . import CLICommandTestMixin, ControllerTestCase  # pylint: disable=no-name-in-module
+from ..tests import CLICommandTestMixin, ControllerTestCase
 
 
 class TestPluginDebug(ControllerTestCase, CLICommandTestMixin):
index d5cdb63e0e5c03e1be3745590d090085d03759a1..02e2b641ca470d5f1a253a90751553289bcba5d6 100644 (file)
@@ -9,8 +9,8 @@ except ImportError:
 
 from ..controllers.pool import Pool
 from ..controllers.task import Task
+from ..tests import ControllerTestCase
 from ..tools import NotificationQueue, TaskManager
-from . import ControllerTestCase  # pylint: disable=no-name-in-module
 
 
 class MockTask(object):
@@ -23,8 +23,6 @@ class MockTask(object):
 class PoolControllerTest(ControllerTestCase):
     @classmethod
     def setup_server(cls):
-        Task._cp_config['tools.authenticate.on'] = False
-        Pool._cp_config['tools.authenticate.on'] = False
         cls.setup_controllers([Pool, Task])
 
     @mock.patch('dashboard.services.progress.get_progress_tasks')
index 14b2dca9ba2521e2c8bbe5b52c36fb518b300423..cd2fb3e8dd3994ce6a5430b7c70b90d959a18018 100644 (file)
@@ -7,7 +7,7 @@ except ImportError:
 
 from .. import mgr
 from ..controllers.prometheus import Prometheus, PrometheusNotifications, PrometheusReceiver
-from . import ControllerTestCase  # pylint: disable=no-name-in-module
+from ..tests import ControllerTestCase
 
 
 class PrometheusControllerTest(ControllerTestCase):
@@ -24,8 +24,6 @@ class PrometheusControllerTest(ControllerTestCase):
             'PROMETHEUS_API_HOST': cls.prometheus_host
         }
         mgr.get_module_option.side_effect = settings.get
-        Prometheus._cp_config['tools.authenticate.on'] = False
-        PrometheusNotifications._cp_config['tools.authenticate.on'] = False
         cls.setup_controllers([Prometheus, PrometheusNotifications, PrometheusReceiver])
 
     def test_rules(self):
index 490a8a6e2992aba427f2293ea1a1ed13d4751d53..a7660475d48f7daae92d58ac6c50bce04b18ddd9 100644 (file)
@@ -14,7 +14,7 @@ from ..controllers.rbd_mirroring import RbdMirroring, \
     RbdMirroringPoolBootstrap, RbdMirroringSummary, get_daemons, get_pools
 from ..controllers.summary import Summary
 from ..services import progress
-from . import ControllerTestCase  # pylint: disable=no-name-in-module
+from ..tests import ControllerTestCase
 
 mock_list_servers = [{
     'hostname': 'ceph-host',
@@ -161,10 +161,6 @@ class RbdMirroringControllerTest(ControllerTestCase):
 
     @classmethod
     def setup_server(cls):
-        # pylint: disable=protected-access
-        RbdMirroring._cp_config['tools.authenticate.on'] = False
-        # pylint: enable=protected-access
-
         cls.setup_controllers([RbdMirroring])
 
     @mock.patch('dashboard.controllers.rbd_mirroring.rbd.RBD')
@@ -192,10 +188,6 @@ class RbdMirroringPoolBootstrapControllerTest(ControllerTestCase):
 
     @classmethod
     def setup_server(cls):
-        # pylint: disable=protected-access
-        RbdMirroringPoolBootstrap._cp_config['tools.authenticate.on'] = False
-        # pylint: enable=protected-access
-
         cls.setup_controllers([RbdMirroringPoolBootstrap])
 
     @mock.patch('dashboard.controllers.rbd_mirroring.rbd.RBD')
@@ -259,11 +251,6 @@ class RbdMirroringSummaryControllerTest(ControllerTestCase):
         progress.get_progress_tasks = mock.MagicMock()
         progress.get_progress_tasks.return_value = ([], [])
 
-        # pylint: disable=protected-access
-        RbdMirroringSummary._cp_config['tools.authenticate.on'] = False
-        Summary._cp_config['tools.authenticate.on'] = False
-        # pylint: enable=protected-access
-
         cls.setup_controllers([RbdMirroringSummary, Summary], '/test')
 
     @mock.patch('dashboard.controllers.rbd_mirroring.rbd.RBD')
index b2bf7091f87b3c3185435f7b493df0562e949073..b320298515ac5f426eb986a686e9d319761baf78 100644 (file)
@@ -10,8 +10,8 @@ except ImportError:
 from ..controllers import RESTController, Router, Task
 from ..controllers.task import Task as TaskController
 from ..services import progress
+from ..tests import ControllerTestCase
 from ..tools import NotificationQueue, TaskManager
-from . import ControllerTestCase  # pylint: disable=no-name-in-module
 
 
 @Router('/test/task', secure=False)
@@ -58,8 +58,6 @@ class TaskControllerTest(ControllerTestCase):
 
         NotificationQueue.start_queue()
         TaskManager.init()
-        TaskTest._cp_config['tools.authenticate.on'] = False
-        TaskController._cp_config['tools.authenticate.on'] = False
         cls.setup_controllers([TaskTest, TaskController])
 
     @classmethod
index c5fb94af3d1f629f1b6885cc2115dfe3f61ac803..0f500a6545cdaa5ded8dce6c62ef8de66b91307f 100644 (file)
@@ -4,13 +4,12 @@ from .. import mgr
 from ..controllers.rgw import Rgw, RgwDaemon, RgwUser
 from ..rest_client import RequestException
 from ..services.rgw_client import RgwClient
-from . import ControllerTestCase, RgwStub  # pylint: disable=no-name-in-module
+from ..tests import ControllerTestCase, RgwStub
 
 
 class RgwControllerTestCase(ControllerTestCase):
     @classmethod
     def setup_server(cls):
-        Rgw._cp_config['tools.authenticate.on'] = False  # pylint: disable=protected-access
         cls.setup_controllers([Rgw], '/test')
 
     def setUp(self) -> None:
@@ -61,7 +60,6 @@ class RgwControllerTestCase(ControllerTestCase):
 class RgwDaemonControllerTestCase(ControllerTestCase):
     @classmethod
     def setup_server(cls):
-        RgwDaemon._cp_config['tools.authenticate.on'] = False  # pylint: disable=protected-access
         cls.setup_controllers([RgwDaemon], '/test')
 
     @patch('dashboard.services.rgw_client.RgwClient._get_user_id', Mock(
@@ -120,7 +118,6 @@ class RgwDaemonControllerTestCase(ControllerTestCase):
 class RgwUserControllerTestCase(ControllerTestCase):
     @classmethod
     def setup_server(cls):
-        RgwUser._cp_config['tools.authenticate.on'] = False  # pylint: disable=protected-access
         cls.setup_controllers([RgwUser], '/test')
 
     @patch('dashboard.controllers.rgw.RgwRESTController.proxy')
index f8a8f2f689d2ebab6e274700561015d9b9f01bfe..d23bdec2ca5133927dee6432cd3205a7b802bf50 100644 (file)
@@ -9,7 +9,7 @@ from ..exceptions import DashboardException
 from ..services.rgw_client import NoCredentialsException, \
     NoRgwDaemonsException, RgwClient, _parse_frontend_config
 from ..settings import Settings
-from . import CLICommandTestMixin, RgwStub  # pylint: disable=no-name-in-module
+from ..tests import CLICommandTestMixin, RgwStub
 
 
 @patch('dashboard.services.rgw_client.RgwClient._get_user_id', Mock(
index 049475bbf48bc3f72845079f0037a4c80d266037..d6c94b6b0b8ba9956018aa3e44f405ce615c838c 100644 (file)
@@ -8,7 +8,7 @@ from mgr_module import ERROR_MSG_EMPTY_INPUT_FILE
 from .. import settings
 from ..controllers.settings import Settings as SettingsController
 from ..settings import Settings, handle_option_command
-from . import ControllerTestCase, KVStoreMockMixin  # pylint: disable=no-name-in-module
+from ..tests import ControllerTestCase, KVStoreMockMixin
 
 
 class SettingsTest(unittest.TestCase, KVStoreMockMixin):
@@ -129,9 +129,6 @@ class SettingsTest(unittest.TestCase, KVStoreMockMixin):
 class SettingsControllerTest(ControllerTestCase, KVStoreMockMixin):
     @classmethod
     def setup_server(cls):
-        # pylint: disable=protected-access
-
-        SettingsController._cp_config['tools.authenticate.on'] = False
         cls.setup_controllers([SettingsController])
 
     @classmethod
index 0aaa0e87478aad7f15c73168635f710e14831d54..e077dde19e18a65cb7a541c71aace5f81fefefef 100644 (file)
@@ -6,7 +6,7 @@ import tempfile
 import unittest
 
 from ..services.sso import load_sso_db
-from . import CLICommandTestMixin, CmdException  # pylint: disable=no-name-in-module
+from ..tests import CLICommandTestMixin, CmdException
 
 
 class AccessControlTest(unittest.TestCase, CLICommandTestMixin):
index fa14195e71e3f3a833c557e5fc4cf0a36e964be2..29f6123f327208ebfaabba4385cdbda2317b64f8 100644 (file)
@@ -13,9 +13,9 @@ except ImportError:
 from ..controllers import APIRouter, BaseController, Proxy, RESTController, Router
 from ..controllers._version import APIVersion
 from ..services.exception import handle_rados_error
+from ..tests import ControllerTestCase
 from ..tools import dict_contains_path, dict_get, json_str_to_object, \
     merge_list_of_dicts_by_key, partial_dict
-from . import ControllerTestCase  # pylint: disable=no-name-in-module
 
 
 # pylint: disable=W0613
index 85804b00ba21ba976b89cc53efc7ae2520245e7a..0fc4b9336b0a6f44e844abfcadcf562c517aaf74 100644 (file)
@@ -5,7 +5,7 @@ import unittest
 from ..controllers._api_router import APIRouter
 from ..controllers._rest_controller import RESTController
 from ..controllers._version import APIVersion
-from . import ControllerTestCase  # pylint: disable=no-name-in-module
+from ..tests import ControllerTestCase
 
 
 @APIRouter("/vtest", secure=False)