mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 01:17:37 -02:30
handle Splunk hostname case from support
This commit is contained in:
@@ -177,8 +177,6 @@ def test_base_logging_handler_emit_system_tracking():
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('host, port, normalized, hostname_only', [
|
@pytest.mark.parametrize('host, port, normalized, hostname_only', [
|
||||||
('localhost', None, 'http://localhost', False),
|
|
||||||
('localhost', 8080, 'http://localhost:8080', False),
|
|
||||||
('http://localhost', None, 'http://localhost', False),
|
('http://localhost', None, 'http://localhost', False),
|
||||||
('http://localhost', 8080, 'http://localhost:8080', False),
|
('http://localhost', 8080, 'http://localhost:8080', False),
|
||||||
('https://localhost', 443, 'https://localhost:443', False),
|
('https://localhost', 443, 'https://localhost:443', False),
|
||||||
@@ -190,6 +188,12 @@ def test_base_logging_handler_emit_system_tracking():
|
|||||||
'http://splunk.server:8088/services/collector/event', False),
|
'http://splunk.server:8088/services/collector/event', False),
|
||||||
('http://splunk.server/services/collector/event', 8088,
|
('http://splunk.server/services/collector/event', 8088,
|
||||||
'http://splunk.server:8088/services/collector/event', False),
|
'http://splunk.server:8088/services/collector/event', False),
|
||||||
|
('splunk.server:8088/services/collector/event', 80,
|
||||||
|
'http://splunk.server:8088/services/collector/event', False),
|
||||||
|
('splunk.server/services/collector/event', 8088,
|
||||||
|
'http://splunk.server:8088/services/collector/event', False),
|
||||||
|
('localhost', None, 'http://localhost', False),
|
||||||
|
('localhost', 8080, 'http://localhost:8080', False),
|
||||||
('localhost', 4399, 'localhost', True),
|
('localhost', 4399, 'localhost', True),
|
||||||
('tcp://localhost:4399/foo/bar', 4399, 'localhost', True),
|
('tcp://localhost:4399/foo/bar', 4399, 'localhost', True),
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -159,7 +159,8 @@ class BaseHandler(logging.Handler):
|
|||||||
"""
|
"""
|
||||||
host = self.host or ''
|
host = self.host or ''
|
||||||
# urlparse requires '//' to be provided if scheme is not specified
|
# urlparse requires '//' to be provided if scheme is not specified
|
||||||
if not urlparse.urlsplit(host).scheme and not host.startswith('//'):
|
original_parsed = urlparse.urlsplit(host)
|
||||||
|
if (not original_parsed.scheme and not host.startswith('//')) or original_parsed.hostname is None:
|
||||||
host = '%s://%s' % (scheme, host) if scheme else '//%s' % host
|
host = '%s://%s' % (scheme, host) if scheme else '//%s' % host
|
||||||
parsed = urlparse.urlsplit(host)
|
parsed = urlparse.urlsplit(host)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user