| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
from ssl import CertificateError |
| 17 |
from unittest import mock |
| 18 |
|
| 19 |
from fixtures import MonkeyPatch |
| 20 |
|
| 21 |
from config_tempest.services import horizon |
| 22 |
from config_tempest.tests.base import BaseConfigTempestTest |
| 23 |
|
| 24 |
|
| 25 |
class TestConfigTempest(BaseConfigTempestTest): |
| 26 |
|
| 27 |
def setUp(self): |
| 28 |
super(TestConfigTempest, self).setUp() |
| 29 |
self.conf = self._get_conf("v2.0", "v3") |
| 30 |
|
| 31 |
def test_configure_horizon_overridden(self): |
| 32 |
mock_function = mock.Mock(return_value=True) |
| 33 |
self.useFixture(MonkeyPatch('six.moves.urllib.request.urlopen', |
| 34 |
mock_function)) |
| 35 |
self.conf.set("dashboard", "dashboard_url", "http://172.16.52.151") |
| 36 |
horizon.configure_horizon(self.conf) |
| 37 |
self.assertEqual(self.conf.get('service_available', 'horizon'), "True") |
| 38 |
self.assertEqual(self.conf.get('dashboard', 'dashboard_url'), |
| 39 |
"http://172.16.52.151/") |
| 40 |
self.assertEqual(self.conf.get('dashboard', 'login_url'), |
| 41 |
"http://172.16.52.151/auth/login/") |
| 42 |
|
| 43 |
def test_configure_horizon_ipv4(self): |
| 44 |
mock_function = mock.Mock(return_value=True) |
| 45 |
self.useFixture(MonkeyPatch('six.moves.urllib.request.urlopen', |
| 46 |
mock_function)) |
| 47 |
horizon.configure_horizon(self.conf) |
| 48 |
self.assertEqual(self.conf.get('service_available', 'horizon'), "True") |
| 49 |
self.assertEqual(self.conf.get('dashboard', 'dashboard_url'), |
| 50 |
"http://172.16.52.151/dashboard/") |
| 51 |
self.assertEqual(self.conf.get('dashboard', 'login_url'), |
| 52 |
"http://172.16.52.151/dashboard/auth/login/") |
| 53 |
|
| 54 |
def test_configure_horizon_ipv6(self): |
| 55 |
mock_function = mock.Mock(return_value=True) |
| 56 |
self.useFixture(MonkeyPatch('six.moves.urllib.request.urlopen', |
| 57 |
mock_function)) |
| 58 |
self.conf.set('identity', 'uri', 'http://[::1]:5000/v3', priority=True) |
| 59 |
horizon.configure_horizon(self.conf) |
| 60 |
self.assertEqual(self.conf.get('service_available', 'horizon'), "True") |
| 61 |
self.assertEqual(self.conf.get('dashboard', 'dashboard_url'), |
| 62 |
"http://[::1]/dashboard/") |
| 63 |
self.assertEqual(self.conf.get('dashboard', 'login_url'), |
| 64 |
"http://[::1]/dashboard/auth/login/") |
| 65 |
|
| 66 |
def test_configure_horizon_certificate_error(self): |
| 67 |
mock_function = mock.Mock(return_value=True) |
| 68 |
mock_function.side_effect = CertificateError |
| 69 |
self.useFixture(MonkeyPatch('six.moves.urllib.request.urlopen', |
| 70 |
mock_function)) |
| 71 |
horizon.configure_horizon(self.conf) |
| 72 |
self.assertEqual(self.conf.get('service_available', 'horizon'), |
| 73 |
"False") |
| 74 |
self.assertFalse(self.conf.has_section('dashboard')) |