-
Notifications
You must be signed in to change notification settings - Fork 18
/
test_check_rbl.py
56 lines (39 loc) · 1.61 KB
/
test_check_rbl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import subprocess
status = {'OK': 0, 'WARNING': 1, 'CRITICAL': 2, 'UNKNOWN': 3}
test_host = 'one.one.one.one'
test_ipv4 = '1.1.1.1'
test_ipv6 = '2606:4700:4700::1111'
crit = 99
warn = 99
def test_no_options():
command = 'python check_rbl.py'
result = subprocess.run(command.split())
assert result.returncode == status['UNKNOWN']
def test_len_options():
command = 'python check_rbl.py -w 99'
result = subprocess.run(command.split())
assert result.returncode == status['UNKNOWN']
def test_host_and_ip():
command = f'python check_rbl.py -a {test_ipv4} -h {test_host}'
result = subprocess.run(command.split())
assert result.returncode == status['UNKNOWN']
def test_ipv4_and_ipv6():
command = f'python check_rbl.py --ipv4 {test_ipv4} --ipv6 {test_ipv6}'
result = subprocess.run(command.split())
assert result.returncode == status['UNKNOWN']
def test_error_resolving():
command = f'python check_rbl.py -h invalid.com'
result = subprocess.run(command.split())
assert result.returncode == status['UNKNOWN']
def test_full_run_host():
command = f'python check_rbl.py -d -w {warn} -c {crit} -h {test_host}'
result = subprocess.run(command.split())
assert result.returncode == status['OK']
def test_full_run_ipv4():
command = f'python check_rbl.py -d -w {warn} -c {crit} -a {test_ipv4}'
result = subprocess.run(command.split())
assert result.returncode == status['OK']
def test_full_run_ipv6():
command = f'python check_rbl.py -d -w {warn} -c {crit} -a {test_ipv6}'
result = subprocess.run(command.split())
assert result.returncode == status['OK']