Merge "Store cells credentials in transport_url properly"
This commit is contained in:
@@ -57,6 +57,7 @@ from __future__ import print_function
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
import urllib
|
||||
|
||||
import decorator
|
||||
import netaddr
|
||||
@@ -1212,7 +1213,7 @@ class CellCommands(object):
|
||||
is_parent = True
|
||||
values = {'name': name,
|
||||
'is_parent': is_parent,
|
||||
'transport_url': str(transport_url),
|
||||
'transport_url': urllib.unquote(str(transport_url)),
|
||||
'weight_offset': float(woffset),
|
||||
'weight_scale': float(wscale)}
|
||||
ctxt = context.get_admin_context()
|
||||
|
@@ -552,6 +552,29 @@ class CellCommandsTestCase(test.TestCase):
|
||||
'weight_scale': 0.0}
|
||||
mock_db_cell_create.assert_called_once_with(ctxt, exp_values)
|
||||
|
||||
@mock.patch.object(context, 'get_admin_context')
|
||||
@mock.patch.object(db, 'cell_create')
|
||||
def test_create_broker_hosts_with_url_decoding_fix(self,
|
||||
mock_db_cell_create,
|
||||
mock_ctxt):
|
||||
"""Test the create function when broker_hosts is
|
||||
passed
|
||||
"""
|
||||
cell_tp_url = "fake://the=user:the=password@127.0.0.1:5432/"
|
||||
ctxt = mock.sentinel
|
||||
mock_ctxt.return_value = mock.sentinel
|
||||
self.commands.create("test",
|
||||
broker_hosts='127.0.0.1:5432',
|
||||
woffset=0, wscale=0,
|
||||
username="the=user",
|
||||
password="the=password")
|
||||
exp_values = {'name': "test",
|
||||
'is_parent': False,
|
||||
'transport_url': cell_tp_url,
|
||||
'weight_offset': 0.0,
|
||||
'weight_scale': 0.0}
|
||||
mock_db_cell_create.assert_called_once_with(ctxt, exp_values)
|
||||
|
||||
@mock.patch.object(context, 'get_admin_context')
|
||||
@mock.patch.object(db, 'cell_create')
|
||||
def test_create_hostname(self, mock_db_cell_create, mock_ctxt):
|
||||
|
Reference in New Issue
Block a user