コード例 #1
0
def test_email_getinfo():
    rule = {
        'name': 'test alert',
        'email': ['*****@*****.**', '*****@*****.**'],
        'from_addr': '*****@*****.**',
        'type': mock_rule(),
        'timestamp_field': '@timestamp',
        'email_reply_to': '*****@*****.**',
        'owner': 'owner_value',
        'alert_subject': 'Test alert for {0}, owned by {1}',
        'alert_subject_args': ['test_term', 'owner'],
        'snowman': '☃'
    }
    alert = EmailAlerter(rule)

    expected_data = {
        'type': 'email',
        'recipients': ['*****@*****.**', '*****@*****.**']
    }
    actual_data = alert.get_info()
    assert expected_data == actual_data
コード例 #2
0
def test_email_key_error(email, expected_data):
    try:
        rule = {
            'name': 'test alert',
            'from_addr': '*****@*****.**',
            'type': mock_rule(),
            'timestamp_field': '@timestamp',
            'email_reply_to': '*****@*****.**',
            'owner': 'owner_value',
            'alert_subject': 'Test alert for {0}, owned by {1}',
            'alert_subject_args': ['test_term', 'owner'],
            'snowman': '☃'
        }

        if email:
            rule['email'] = email

        alert = EmailAlerter(rule)

        actual_data = alert.get_info()
        assert expected_data == actual_data
    except Exception:
        assert expected_data