Debian Codegraph @

magnum_tempest_plugin/tests/api/v1/rbac/test_magnum_service.py

raw
1 # Licensed under the Apache License, Version 2.0 (the "License"); you may
2 # not use this file except in compliance with the License. You may obtain
3 # a copy of the License at
4 #
5 # http://www.apache.org/licenses/LICENSE-2.0
6 #
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 # License for the specific language governing permissions and limitations
11 # under the License.
12
13 import abc
14 from tempest.lib import exceptions
15 import testtools
16
17 from magnum_tempest_plugin.tests.api.v1.rbac import base
18
19
20 class MagnumServiceTest(base.RbacBaseTests, metaclass=abc.ABCMeta):
21
22 """Tests for magnum-service with RBAC."""
23
24 def __init__(self, *args, **kwargs):
25 super(MagnumServiceTest, self).__init__(*args, **kwargs)
26
27 @testtools.testcase.attr('negative')
28 def test_magnum_service_list_needs_admin(self):
29 self.assertRaises(exceptions.Forbidden,
30 self.service_member_client.magnum_service_list)
31
32 @testtools.testcase.attr('positive')
33 def test_magnum_service_list(self):
34 # get json object
35 resp, msvcs = self.service_admin_client.magnum_service_list()
36 self.assertEqual(200, resp.status)
37 mcond_svc = msvcs.mservices[0]
38 self.assertEqual(mcond_svc['id'], 1)
39 self.assertEqual('up', mcond_svc['state'])
40 self.assertEqual('magnum-conductor', mcond_svc['binary'])
41 self.assertGreater(mcond_svc['report_count'], 0)