]> git.apps.os.sepia.ceph.com Git - ceph.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>
Thu, 4 Nov 2021 16:22:48 +0000 (17:22 +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>
(cherry picked from commit a6aeded5141ec3a959a86aa4002ccf5ac8d0a523)

 Conflicts:
src/pybind/mgr/dashboard/tests/test_docs.py
    - Resolved conflicts.
src/pybind/mgr/dashboard/tests/test_iscsi.py
    - Resolved conflicts.

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 94e877e03d2abd3d95e433c44d86de9656aaa003..5b449e099b9640f07034295f73215d3b7cdb9fe4 100644 (file)
@@ -1659,8 +1659,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")
@@ -1670,8 +1670,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 cda76600939772517269ab8d50e3cf44bff4355a..ba005c480d52ae8eea2d9094da0d96d88f1a9e83 100644 (file)
@@ -6,6 +6,7 @@ import json
 import logging
 import threading
 import time
+from typing import Any, Dict
 from unittest.mock import Mock
 
 import cherrypy
@@ -102,12 +103,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 f64664caa4000993ec2d0be6f1f8fa9745361ed4..7a75bda6dd35937794b47905d19fe764b165858a 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 d54e33ee02cd169f1a18da819605c48a7fdc3b44..854d76468c21fe17185968be01105568a27811eb 100644 (file)
@@ -11,7 +11,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 4fde5452a6bd280d231b5863458eae0b482524aa..4b91b110391e15477eb8f4045ef9beb542338c9d 100644 (file)
@@ -2,7 +2,7 @@
 from __future__ import absolute_import
 
 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 d0529ab8d82333ecc357ea9477aa6b9283052378..5291edb3bb77f6ef1ecebf351ea3503b091f5a52 100644 (file)
@@ -2,10 +2,10 @@
 from __future__ import absolute_import
 
 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
@@ -66,6 +66,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):
@@ -120,5 +121,5 @@ 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)
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 0805e8c7bd1a5bf448db967da1ce82a9aa82cd80..2a9e840b8987b5f9cc5e8d9720bb4dd716c0e8cd 100644 (file)
@@ -9,8 +9,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 d908c0e577da47a976e66ed7e039c052fc3997d0..dcc41b25eb1023295931a16ee1a7b89f83629827 100644 (file)
@@ -9,7 +9,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 1b1b6b7063902f04a571bdc715e7320bf6e63dd5..0b788626048df87c8f4a001370de49b17b1a70c7 100644 (file)
@@ -10,7 +10,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 4060c6c4a044cc4c752e7fa60e417b1e47445c02..7728a496b9ebbf14cbf879f1e2b50a041042f8c9 100644 (file)
@@ -17,11 +17,8 @@ from ..controllers.iscsi import Iscsi, IscsiTarget
 from ..rest_client import RequestException
 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):
@@ -84,9 +81,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
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 cb4d1afc21844f53c1c80d081bdba5b3250779b7..572f82a416187df4476cb196b9e95f1b9638c910 100644 (file)
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 from __future__ import absolute_import
 
-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 9f83bad83e1236ed0601d85cb488bf000ed89100..e064089706a644a1cde5ae5f7bbbd0193d55310b 100644 (file)
@@ -11,7 +11,7 @@ from .. import mgr
 from ..controllers.rbd_mirroring import RbdMirroring, RbdMirroringPoolBootstrap, RbdMirroringSummary
 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',
@@ -51,10 +51,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')
@@ -82,10 +78,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')
@@ -149,11 +141,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 6e382b9d40f7d1ccd0c9297fa793da43b84eff4c..e204b566ab50043b83e5c1209cd7d72dc83ddc71 100644 (file)
@@ -9,7 +9,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):
@@ -130,9 +130,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 ab565137a18f98759b7992f719b9689f3935baa1..5594738d173b4d6c08d6807da32bf8cd7441f32e 100644 (file)
@@ -6,7 +6,7 @@ import errno
 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 b30ab0c90b4fca3cd56a6fd076f82d996e918ec8..eaae3e2959e0c7374b3c38c8f9b3113c9dad0248 100644 (file)
@@ -14,9 +14,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 48e6394c2cf0466849da500697e9d8d3acb84eb8..0a77a299e98d53b1b5c8ffb9fe7e3d97db2d0623 100644 (file)
@@ -6,7 +6,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)