2018-02-28 22:14:35 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2018-04-24 16:32:54 +00:00
|
|
|
from .helper import DashboardTestCase
|
2018-02-28 22:14:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
class HostControllerTest(DashboardTestCase):
|
|
|
|
|
2018-04-24 16:32:54 +00:00
|
|
|
AUTH_ROLES = ['read-only']
|
|
|
|
|
|
|
|
@DashboardTestCase.RunAs('test', 'test', ['block-manager'])
|
|
|
|
def test_access_permissions(self):
|
|
|
|
self._get('/api/host')
|
|
|
|
self.assertStatus(403)
|
|
|
|
|
2018-02-28 22:14:35 +00:00
|
|
|
def test_host_list(self):
|
|
|
|
data = self._get('/api/host')
|
|
|
|
self.assertStatus(200)
|
|
|
|
|
|
|
|
for server in data:
|
|
|
|
self.assertIn('services', server)
|
|
|
|
self.assertIn('hostname', server)
|
|
|
|
self.assertIn('ceph_version', server)
|
|
|
|
self.assertIsNotNone(server['hostname'])
|
|
|
|
self.assertIsNotNone(server['ceph_version'])
|
|
|
|
self.assertGreaterEqual(len(server['services']), 1)
|
|
|
|
for service in server['services']:
|
|
|
|
self.assertIn('type', service)
|
|
|
|
self.assertIn('id', service)
|
|
|
|
self.assertIsNotNone(service['type'])
|
|
|
|
self.assertIsNotNone(service['id'])
|