mirror of
https://github.com/ansible/awx.git
synced 2026-02-18 11:40:05 -03:30
Correctly parse sumologic url paths
- Sumologic includes a token with a '==' at the end of it's host path. This adds rsyslog conf parsing tests and does not escape equals signs.
This commit is contained in:
@@ -35,7 +35,7 @@ data_loggly = {
|
|||||||
# Test reconfigure logging settings function
|
# Test reconfigure logging settings function
|
||||||
# name this whatever you want
|
# name this whatever you want
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'enabled, type, host, port, protocol, expected_config', [
|
'enabled, log_type, host, port, protocol, expected_config', [
|
||||||
(
|
(
|
||||||
True,
|
True,
|
||||||
'loggly',
|
'loggly',
|
||||||
@@ -135,9 +135,20 @@ data_loggly = {
|
|||||||
'action(type="omhttp" server="yoursplunk.org" serverport="8088" usehttps="off" allowunsignedcerts="off" skipverifyhost="off" action.resumeRetryCount="-1" template="awx" errorfile="/var/log/tower/rsyslog.err" action.resumeInterval="5" restpath="services/collector/event")', # noqa
|
'action(type="omhttp" server="yoursplunk.org" serverport="8088" usehttps="off" allowunsignedcerts="off" skipverifyhost="off" action.resumeRetryCount="-1" template="awx" errorfile="/var/log/tower/rsyslog.err" action.resumeInterval="5" restpath="services/collector/event")', # noqa
|
||||||
])
|
])
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
True, # valid sumologic config
|
||||||
|
'sumologic',
|
||||||
|
'https://endpoint5.collection.us2.sumologic.com/receiver/v1/http/ZaVnC4dhaV0qoiETY0MrM3wwLoDgO1jFgjOxE6-39qokkj3LGtOroZ8wNaN2M6DtgYrJZsmSi4-36_Up5TbbN_8hosYonLKHSSOSKY845LuLZBCBwStrHQ==', # noqa
|
||||||
|
None,
|
||||||
|
'https',
|
||||||
|
'\n'.join([
|
||||||
|
'template(name="awx" type="string" string="%rawmsg-after-pri%")\nmodule(load="omhttp")',
|
||||||
|
'action(type="omhttp" server="endpoint5.collection.us2.sumologic.com" serverport="443" usehttps="on" allowunsignedcerts="off" skipverifyhost="off" action.resumeRetryCount="-1" template="awx" errorfile="/var/log/tower/rsyslog.err" action.resumeInterval="5" restpath="receiver/v1/http/ZaVnC4dhaV0qoiETY0MrM3wwLoDgO1jFgjOxE6-39qokkj3LGtOroZ8wNaN2M6DtgYrJZsmSi4-36_Up5TbbN_8hosYonLKHSSOSKY845LuLZBCBwStrHQ==")', # noqa
|
||||||
|
])
|
||||||
|
),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
def test_rsyslog_conf_template(enabled, type, host, port, protocol, expected_config):
|
def test_rsyslog_conf_template(enabled, log_type, host, port, protocol, expected_config):
|
||||||
|
|
||||||
mock_settings, _ = _mock_logging_defaults()
|
mock_settings, _ = _mock_logging_defaults()
|
||||||
|
|
||||||
@@ -146,7 +157,7 @@ def test_rsyslog_conf_template(enabled, type, host, port, protocol, expected_con
|
|||||||
setattr(mock_settings, 'LOGGING', logging_defaults)
|
setattr(mock_settings, 'LOGGING', logging_defaults)
|
||||||
setattr(mock_settings, 'LOGGING["handlers"]["external_logger"]["address"]', '/var/run/awx-rsyslog/rsyslog.sock')
|
setattr(mock_settings, 'LOGGING["handlers"]["external_logger"]["address"]', '/var/run/awx-rsyslog/rsyslog.sock')
|
||||||
setattr(mock_settings, 'LOG_AGGREGATOR_ENABLED', enabled)
|
setattr(mock_settings, 'LOG_AGGREGATOR_ENABLED', enabled)
|
||||||
setattr(mock_settings, 'LOG_AGGREGATOR_TYPE', type)
|
setattr(mock_settings, 'LOG_AGGREGATOR_TYPE', log_type)
|
||||||
setattr(mock_settings, 'LOG_AGGREGATOR_HOST', host)
|
setattr(mock_settings, 'LOG_AGGREGATOR_HOST', host)
|
||||||
if port:
|
if port:
|
||||||
setattr(mock_settings, 'LOG_AGGREGATOR_PORT', port)
|
setattr(mock_settings, 'LOG_AGGREGATOR_PORT', port)
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ def construct_rsyslog_conf_template(settings=settings):
|
|||||||
f'action.resumeInterval="{timeout}"'
|
f'action.resumeInterval="{timeout}"'
|
||||||
]
|
]
|
||||||
if parsed.path:
|
if parsed.path:
|
||||||
path = urlparse.quote(parsed.path[1:])
|
path = urlparse.quote(parsed.path[1:], safe='/=')
|
||||||
if parsed.query:
|
if parsed.query:
|
||||||
path = f'{path}?{urlparse.quote(parsed.query)}'
|
path = f'{path}?{urlparse.quote(parsed.query)}'
|
||||||
params.append(f'restpath="{path}"')
|
params.append(f'restpath="{path}"')
|
||||||
|
|||||||
Reference in New Issue
Block a user