Fix AtrributeError in update_listener

Items in curr_listener['sni_containers'] have been converted to dicts.

Story: 2001521
Task: 6322

Change-Id: I6cd12e156b8fb1121d182eed3cd9389646a2c9b0
This commit is contained in:
Hunt Xu 2017-11-08 11:56:56 +08:00
parent aa96e16f93
commit 84a9a26ac4
2 changed files with 47 additions and 1 deletions

View File

@ -600,7 +600,7 @@ class LoadBalancerPluginv2(loadbalancerv2.LoadBalancerPluginBaseV2,
curr_listener['default_tls_container_id'])
if 'sni_container_refs' not in listener:
listener['sni_container_ids'] = [
container.tls_container_id for container in (
container['tls_container_id'] for container in (
curr_listener['sni_containers'])]
tls_containers_changed = False

View File

@ -1881,6 +1881,52 @@ class LbaasListenerTests(ListenerTestBase):
)
self.assertEqual('', listener['default_tls_container_ref'])
def test_update_listener_without_sni_container_refs(self):
default_tls_container_ref = uuidutils.generate_uuid()
sni_tls_container_ref_1 = uuidutils.generate_uuid()
sni_tls_container_ref_2 = uuidutils.generate_uuid()
listener_data = {
'protocol': lb_const.PROTOCOL_TERMINATED_HTTPS,
'default_tls_container_ref': default_tls_container_ref,
'sni_container_refs': [sni_tls_container_ref_1,
sni_tls_container_ref_2],
'protocol_port': 443,
'admin_state_up': True,
'tenant_id': self._tenant_id,
'loadbalancer_id': self.lb_id
}
with mock.patch('neutron_lbaas.services.loadbalancer.plugin.'
'cert_parser.validate_cert') as validate_cert_mock,\
mock.patch('neutron_lbaas.services.loadbalancer.plugin.'
'CERT_MANAGER_PLUGIN.CertManager.'
'get_cert') as get_cert_mock:
get_cert_mock.start().return_value = CertMock(
'mock_cert')
validate_cert_mock.start().return_value = True
# Default container and two SNI containers
# Test order and validation behavior.
listener = self.plugin.create_listener(
context.get_admin_context(), {'listener': listener_data})
expected = [sni_tls_container_ref_1, sni_tls_container_ref_2]
self.assertEqual(expected, listener['sni_container_refs'])
# No changes on default container and the containers list
# Only update the listener name
# Test getting info from current and validation behavior.
updated_name = 'Updated Listener'
listener_data = {'name': updated_name}
listener = self.plugin.update_listener(
context.get_admin_context(),
listener['id'],
{'listener': listener_data}
)
self.assertEqual(default_tls_container_ref,
listener['default_tls_container_ref'])
self.assertEqual(expected, listener['sni_container_refs'])
self.assertEqual(updated_name, listener['name'])
def test_delete_listener(self):
with self.listener(no_delete=True,
loadbalancer_id=self.lb_id) as listener: