diff options
| author | Josh Kearney <josh@jk0.org> | 2012-11-26 13:06:10 -0600 |
|---|---|---|
| committer | Josh Kearney <josh@jk0.org> | 2012-11-26 14:29:37 -0600 |
| commit | eae906f8a84023ff0f0f3af1196d2af112765501 (patch) | |
| tree | 1ff0d760974126dbe87ed2bbb166e593a891d15f /nova/tests | |
| parent | a6d8554fa3a0ab024c3d52696e02fd3db6e21006 (diff) | |
Add SSL support to utils.generate_glance_url().
Since glance now supports SSL, we need to take
this into consideration when generating the URL.
Also updates and adds a test.
A new config option 'glance_protocol' was added
that defaults to 'http' since that's what the
glance options, '*_client_protocol', default to.
Set to 'https' for SSL.
Change-Id: Id231a1fd4c4d8e221ae0cf6541181e5572dff02b
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/test_utils.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/nova/tests/test_utils.py b/nova/tests/test_utils.py index 8bf6df8b5..2ee0bd36f 100644 --- a/nova/tests/test_utils.py +++ b/nova/tests/test_utils.py @@ -34,7 +34,9 @@ from nova import test from nova import utils CONF = cfg.CONF +CONF.import_opt('glance_host', 'nova.config') CONF.import_opt('glance_port', 'nova.config') +CONF.import_opt('glance_protocol', 'nova.config') class ByteConversionTest(test.TestCase): @@ -379,10 +381,16 @@ class GenericUtilsTestCase(test.TestCase): self.assertFalse(utils.bool_from_str(None)) self.assertFalse(utils.bool_from_str('junk')) - def test_generate_glance_url(self): + def test_generate_glance_http_url(self): generated_url = utils.generate_glance_url() - actual_url = "http://%s:%d" % (CONF.glance_host, CONF.glance_port) - self.assertEqual(generated_url, actual_url) + http_url = "http://%s:%d" % (CONF.glance_host, CONF.glance_port) + self.assertEqual(generated_url, http_url) + + def test_generate_glance_https_url(self): + self.flags(glance_protocol="https") + generated_url = utils.generate_glance_url() + https_url = "https://%s:%d" % (CONF.glance_host, CONF.glance_port) + self.assertEqual(generated_url, https_url) def test_read_cached_file(self): self.mox.StubOutWithMock(os.path, "getmtime") |
