Пример #1
0
def test_splunk_auth():
    mock_settings, _ = _mock_logging_defaults()
    # Set test settings
    logging_defaults = getattr(settings, 'LOGGING')
    setattr(mock_settings, 'LOGGING', logging_defaults)
    setattr(mock_settings, 'LOG_AGGREGATOR_ENABLED', True)
    setattr(mock_settings, 'LOG_AGGREGATOR_TYPE', 'splunk')
    setattr(mock_settings, 'LOG_AGGREGATOR_HOST', 'example.org')
    setattr(mock_settings, 'LOG_AGGREGATOR_PASSWORD', 'SECRET-TOKEN')

    tmpl = construct_rsyslog_conf_template(mock_settings)
    assert 'httpheaderkey="Authorization" httpheadervalue="Splunk SECRET-TOKEN"' in tmpl
Пример #2
0
def test_rsyslog_conf_template(enabled, type, host, port, protocol, expected_config):
    
    mock_settings, _ = _mock_logging_defaults()
    
    # Set test settings
    logging_defaults = getattr(settings, 'LOGGING')
    setattr(mock_settings, 'LOGGING', logging_defaults)
    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_TYPE', type)
    setattr(mock_settings, 'LOG_AGGREGATOR_HOST', host)
    if port:
        setattr(mock_settings, 'LOG_AGGREGATOR_PORT', port)
    if protocol:
        setattr(mock_settings, 'LOG_AGGREGATOR_PROTOCOL', protocol)

    # create rsyslog conf template 
    tmpl = construct_rsyslog_conf_template(mock_settings)
    
    # check validity of created template
    assert expected_config in tmpl