Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions graypy/rabbitmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def __init__(
"""
self.url = url
parsed = urlparse(url)
if parsed.scheme != "amqp":
raise ValueError('invalid URL scheme (expected "amqp"): %s' % url)
if parsed.scheme not in ("amqp", "amqps"):
raise ValueError('invalid URL scheme (expected "amqp" or "amqps"): %s' % url)
host = parsed.hostname or "localhost"
port = _ifnone(parsed.port, 5672)
self.virtual_host = (
Expand All @@ -72,6 +72,7 @@ def __init__(
"password": _ifnone(parsed.password, "guest"),
"virtual_host": self.virtual_host,
"insist": False,
"ssl": True if parsed.scheme == "amqps" else False
}
self.exchange = exchange
self.exchange_type = exchange_type
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/test_GELFRabbitHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ def test_valid_url():
assert "amqp://localhost" == handler.url


def test_valid_ssl_url():
"""Test constructing :class:`graypy.rabbitmq.GELFRabbitHandler` with
a valid ssl rabbitmq url"""
handler = GELFRabbitHandler("amqps://localhost")
assert handler
assert "amqps://localhost" == handler.url
assert handler.cn_args["ssl"]


@pytest.mark.xfail(reason="rabbitmq service is not up")
def test_socket_creation_failure():
"""Test attempting to open a socket to a rabbitmq instance when no such
Expand Down