Skip to content

Commit

Permalink
Merge 765faf9 into 5aa0241
Browse files Browse the repository at this point in the history
  • Loading branch information
blazewicz committed Jun 21, 2018
2 parents 5aa0241 + 765faf9 commit cf0b9d0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion aio_pika/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ async def main():
login = url.user or login
password = url.password or password
virtualhost = url.path[1:] if len(url.path) > 1 else virtualhost
ssl = url.scheme == 'amqps' or ssl

ssl_keys = (
'ca_certs',
Expand All @@ -409,7 +410,8 @@ async def main():

ssl_options[key] = url.query[key]

ssl = bool(ssl_options)
if ssl_options:
ssl = True

connection = connection_class(
host=host, port=port, login=login, password=password,
Expand Down
15 changes: 15 additions & 0 deletions tests/test_amqp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import time
import unittest
from unittest import skipIf
from unittest.mock import MagicMock

from aio_pika.exceptions import ChannelClosed

Expand Down Expand Up @@ -1261,3 +1262,17 @@ def test_message_info(self):
)

self.assertDictEqual(info, msg.info())


@pytest.mark.asyncio
@pytest.mark.parametrize('url,kwargs,exp', [
('amqps://', {}, {'ssl': True}),
('localhost', {'ssl': True}, {'ssl': True}),
('localhost', {'ssl_options': {'ssl_version': '2'}}, {'ssl': True}),
])
async def test_connection_url_params(url, kwargs, exp):
connection_mock = MagicMock()
await connect(url, **kwargs, connection_class=connection_mock)
_, mock_kwargs = connection_mock.call_args
for item in exp.items():
assert item in mock_kwargs.items()

0 comments on commit cf0b9d0

Please sign in to comment.