Beispiel #1
0
def test_mattermost_getinfo():
    rule = {
        'name': 'Test Mattermost Rule',
        'type': 'any',
        'alert_text_type': 'alert_text_only',
        'mattermost_webhook_url': 'http://xxxxx',
        'alert': [],
        'alert_subject': 'Test Mattermost'
    }
    rules_loader = FileRulesLoader({})
    rules_loader.load_modules(rule)
    alert = MattermostAlerter(rule)

    expected_data = {
        'type': 'mattermost',
        'mattermost_username_override': 'elastalert',
        'mattermost_webhook_url': ['http://xxxxx']
    }
    actual_data = alert.get_info()
    assert expected_data == actual_data
Beispiel #2
0
def test_mattermost_required_error(mattermost_webhook_url, expected_data):
    try:
        rule = {
            'name': 'Test Mattermost Rule',
            'type': 'any',
            'alert_text_type': 'alert_text_only',
            'alert': [],
            'alert_subject': 'Test Mattermost'
        }

        if mattermost_webhook_url:
            rule['mattermost_webhook_url'] = mattermost_webhook_url

        rules_loader = FileRulesLoader({})
        rules_loader.load_modules(rule)
        alert = MattermostAlerter(rule)

        actual_data = alert.get_info()
        assert expected_data == actual_data
    except Exception as ea:
        assert expected_data in str(ea)