2023-01-11 20:02:48 +00:00
|
|
|
"""Test parsing the RapidBlock JSON format
|
|
|
|
"""
|
2023-01-16 22:04:34 +00:00
|
|
|
from fediblockhole.blocklists import parse_blocklist
|
2023-01-11 20:02:48 +00:00
|
|
|
|
|
|
|
from fediblockhole.const import SeverityLevel
|
|
|
|
|
|
|
|
rapidblockjson = "data-rapidblock.json"
|
|
|
|
|
|
|
|
def test_parse_rapidblock_json():
|
|
|
|
with open(rapidblockjson) as fp:
|
|
|
|
data = fp.read()
|
2023-01-16 22:04:34 +00:00
|
|
|
bl = parse_blocklist(data, 'pytest', 'rapidblock.json')
|
2023-01-11 20:02:48 +00:00
|
|
|
|
2023-01-16 22:04:34 +00:00
|
|
|
assert '101010.pl' in bl
|
|
|
|
assert bl['101010.pl'].severity.level == SeverityLevel.SUSPEND
|
|
|
|
assert bl['101010.pl'].public_comment == ''
|
2023-01-11 20:02:48 +00:00
|
|
|
|
2023-01-16 22:04:34 +00:00
|
|
|
assert 'berserker.town' in bl
|
|
|
|
assert bl['berserker.town'].severity.level == SeverityLevel.SUSPEND
|
|
|
|
assert bl['berserker.town'].public_comment == ''
|
|
|
|
assert bl['berserker.town'].private_comment == ''
|
2023-01-11 20:02:48 +00:00
|
|
|
|
|
|
|
def test_parse_with_comments():
|
|
|
|
with open(rapidblockjson) as fp:
|
|
|
|
data = fp.read()
|
2023-01-16 22:04:34 +00:00
|
|
|
bl = parse_blocklist(data, 'pytest', 'rapidblock.json', ['domain', 'severity', 'public_comment', 'private_comment'])
|
2023-01-11 20:02:48 +00:00
|
|
|
|
2023-01-16 22:04:34 +00:00
|
|
|
assert '101010.pl' in bl
|
|
|
|
assert bl['101010.pl'].severity.level == SeverityLevel.SUSPEND
|
|
|
|
assert bl['101010.pl'].public_comment == 'cryptomining javascript, white supremacy'
|
2023-01-11 20:02:48 +00:00
|
|
|
|
2023-01-16 22:04:34 +00:00
|
|
|
assert 'berserker.town' in bl
|
|
|
|
assert bl['berserker.town'].severity.level == SeverityLevel.SUSPEND
|
|
|
|
assert bl['berserker.town'].public_comment == 'freeze peach'
|