Merge "Improve os_transport_url ssl support"
This commit is contained in:
commit
80981a4cc6
@ -129,10 +129,15 @@ EOS
|
||||
# support previous ssl option on the function. Setting ssl will
|
||||
# override ssl if passed in via the query parameters
|
||||
if v.include?('ssl')
|
||||
# ssl can be passed in as a query paramter but should be 0/1. See
|
||||
# http://docs.celeryproject.org/projects/kombu/en/latest/userguide/connections.html#urls
|
||||
# so we rely on the stdlib str2bool and bool2num to ensure it's in the
|
||||
# format
|
||||
ssl_val = function_bool2num([function_str2bool([v['ssl']])])
|
||||
if v.include?('query')
|
||||
v['query'].merge!({ 'ssl' => v['ssl'] })
|
||||
v['query'].merge!({ 'ssl' => ssl_val })
|
||||
else
|
||||
v['query'] = { 'ssl' => v['ssl'] }
|
||||
v['query'] = { 'ssl' => ssl_val }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -208,7 +208,7 @@ describe 'os_transport_url' do
|
||||
}).and_return('rabbit://guest@127.0.0.1:5672/virt?read_timeout=60')
|
||||
end
|
||||
|
||||
it 'with ssl overrides ssl in querty hash' do
|
||||
it 'with ssl overrides ssl in quert hash' do
|
||||
is_expected.to run.with_params({
|
||||
'transport' => 'rabbit',
|
||||
'host' => '127.0.0.1',
|
||||
@ -221,5 +221,50 @@ describe 'os_transport_url' do
|
||||
}).and_return('rabbit://guest@127.0.0.1:5672/virt?read_timeout=60&ssl=1')
|
||||
end
|
||||
|
||||
it 'with ssl as boolean string' do
|
||||
is_expected.to run.with_params({
|
||||
'transport' => 'rabbit',
|
||||
'host' => '127.0.0.1',
|
||||
'port' => '5672',
|
||||
'username' => 'guest',
|
||||
'password' => '',
|
||||
'virtual_host' => 'virt',
|
||||
'ssl' => 'true',
|
||||
'query' => { 'read_timeout' => '60' },
|
||||
}).and_return('rabbit://guest@127.0.0.1:5672/virt?read_timeout=60&ssl=1')
|
||||
is_expected.to run.with_params({
|
||||
'transport' => 'rabbit',
|
||||
'host' => '127.0.0.1',
|
||||
'port' => '5672',
|
||||
'username' => 'guest',
|
||||
'password' => '',
|
||||
'virtual_host' => 'virt',
|
||||
'ssl' => 'false',
|
||||
'query' => { 'read_timeout' => '60' },
|
||||
}).and_return('rabbit://guest@127.0.0.1:5672/virt?read_timeout=60&ssl=0')
|
||||
is_expected.to run.with_params({
|
||||
'transport' => 'rabbit',
|
||||
'host' => '127.0.0.1',
|
||||
'port' => '5672',
|
||||
'username' => 'guest',
|
||||
'password' => '',
|
||||
'virtual_host' => 'virt',
|
||||
'ssl' => 'True',
|
||||
'query' => { 'read_timeout' => '60' },
|
||||
}).and_return('rabbit://guest@127.0.0.1:5672/virt?read_timeout=60&ssl=1')
|
||||
is_expected.to run.with_params({
|
||||
'transport' => 'rabbit',
|
||||
'host' => '127.0.0.1',
|
||||
'port' => '5672',
|
||||
'username' => 'guest',
|
||||
'password' => '',
|
||||
'virtual_host' => 'virt',
|
||||
'ssl' => 'False',
|
||||
'query' => { 'read_timeout' => '60' },
|
||||
}).and_return('rabbit://guest@127.0.0.1:5672/virt?read_timeout=60&ssl=0')
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user