Merge "BigSwitch: Fix cfg.Error format in exception"

This commit is contained in:
Jenkins 2014-03-08 23:25:29 +00:00 committed by Gerrit Code Review
commit 44ab9f9448
2 changed files with 18 additions and 2 deletions

View File

@ -356,8 +356,8 @@ class ServerPool(object):
except Exception as e:
raise cfg.Error(_('Could not retrieve initial '
'certificate from controller %(server)s. '
'Error details: %(error)s'),
{'server': server, 'error': e.strerror})
'Error details: %(error)s') %
{'server': server, 'error': str(e)})
LOG.warning(_("Storing to certificate for host %(server)s "
"at %(path)s") % {'server': server,

View File

@ -14,8 +14,10 @@
#
# @author: Kevin Benton, kevin.benton@bigswitch.com
#
import mock
from oslo.config import cfg
from neutron.manager import NeutronManager
from neutron.plugins.bigswitch import servermanager
from neutron.tests.unit.bigswitch import test_restproxy_plugin as test_rp
@ -29,3 +31,17 @@ class ServerManagerTests(test_rp.BigSwitchProxyPluginV2TestCase):
def test_malformed_servers(self):
cfg.CONF.set_override('servers', ['a:b:c'], 'RESTPROXY')
self.assertRaises(cfg.Error, servermanager.ServerPool)
def test_sticky_cert_fetch_fail(self):
pl = NeutronManager.get_plugin()
pl.servers.ssl = True
with mock.patch(
'ssl.get_server_certificate',
side_effect=Exception('There is no more entropy in the universe')
) as sslgetmock:
self.assertRaises(
cfg.Error,
pl.servers._get_combined_cert_for_server,
*('example.org', 443)
)
sslgetmock.assert_has_calls([mock.call(('example.org', 443))])