class TestDefaultRootController(trove_testtools.TestCase): def setUp(self): super(TestDefaultRootController, self).setUp() self.controller = DefaultRootController() @patch.object(models.Root, "load") def test_root_index(self, root_load): context = Mock() req = Mock() req.environ = Mock() req.environ.__getitem__ = Mock(return_value=context) tenant_id = Mock() uuid = utils.generate_uuid() is_cluster = False self.controller.root_index(req, tenant_id, uuid, is_cluster) root_load.assert_called_with(context, uuid) def test_root_index_with_cluster(self): req = Mock() tenant_id = Mock() uuid = utils.generate_uuid() is_cluster = True self.assertRaises( exception.ClusterOperationNotSupported, self.controller.root_index, req, tenant_id, uuid, is_cluster) @patch.object(models.Root, "create") def test_root_create(self, root_create): user = Mock() context = Mock() context.user = Mock() context.user.__getitem__ = Mock(return_value=user) req = Mock() req.environ = Mock() req.environ.__getitem__ = Mock(return_value=context) tenant_id = Mock() uuid = utils.generate_uuid() is_cluster = False password = Mock() body = {'password': password} self.controller.root_create(req, body, tenant_id, uuid, is_cluster) root_create.assert_called_with(context, uuid, context.user, password) def test_root_create_with_cluster(self): req = Mock() tenant_id = Mock() uuid = utils.generate_uuid() is_cluster = True password = Mock() body = {'password': password} self.assertRaises( exception.ClusterOperationNotSupported, self.controller.root_create, req, body, tenant_id, uuid, is_cluster)
class TestDefaultRootController(trove_testtools.TestCase): def setUp(self): super(TestDefaultRootController, self).setUp() self.controller = DefaultRootController() @patch.object(models.Root, "load") def test_root_index(self, root_load): context = Mock() req = Mock() req.environ = Mock() req.environ.__getitem__ = Mock(return_value=context) tenant_id = Mock() uuid = utils.generate_uuid() is_cluster = False self.controller.root_index(req, tenant_id, uuid, is_cluster) root_load.assert_called_with(context, uuid) def test_root_index_with_cluster(self): req = Mock() tenant_id = Mock() uuid = utils.generate_uuid() is_cluster = True self.assertRaises( exception.ClusterOperationNotSupported, self.controller.root_index, req, tenant_id, uuid, is_cluster) @patch.object(models.Root, "create") def test_root_create(self, root_create): user = Mock() context = Mock() context.user = Mock() context.user.__getitem__ = Mock(return_value=user) req = Mock() req.environ = Mock() req.environ.__getitem__ = Mock(return_value=context) tenant_id = Mock() uuid = utils.generate_uuid() is_cluster = False password = Mock() body = {'password': password} self.controller.root_create(req, body, tenant_id, uuid, is_cluster) root_create.assert_called_with(context, uuid, context.user, password) def test_root_create_with_cluster(self): req = Mock() tenant_id = Mock() uuid = utils.generate_uuid() is_cluster = True password = Mock() body = {'password': password} self.assertRaises( exception.ClusterOperationNotSupported, self.controller.root_create, req, body, tenant_id, uuid, is_cluster)
def root_create(self, req, body, tenant_id, instance_id, is_cluster): """Enable authentication for a redis instance and its replicas if any """ self._validate_can_perform_action(tenant_id, instance_id, is_cluster, "enable_root") password = DefaultRootController._get_password_from_body(body) slave_instances = self._get_slaves(tenant_id, instance_id) return self._instance_root_create(req, instance_id, password, slave_instances)
def setUp(self): super(TestDefaultRootController, self).setUp() self.controller = DefaultRootController()
def setUp(self): super(TestDefaultRootController, self).setUp() self.controller = DefaultRootController()