Compare commits
4 Commits
ea325b0686
...
32032de81d
Author | SHA1 | Date | |
---|---|---|---|
32032de81d | |||
d969ce5242 | |||
8f0dfc9d63 | |||
ee38b9d5e8 |
@ -94,7 +94,7 @@ def create_app():
|
|||||||
verbose=True)
|
verbose=True)
|
||||||
result = [entry.groupdict() for entry in
|
result = [entry.groupdict() for entry in
|
||||||
re.finditer(_PFCTL_TABLE_PAT,
|
re.finditer(_PFCTL_TABLE_PAT,
|
||||||
'\n'.join(res),
|
'\n'.join([x.decode('ascii') for x in res]),
|
||||||
re.MULTILINE|re.VERBOSE)]
|
re.MULTILINE|re.VERBOSE)]
|
||||||
|
|
||||||
return jsonify({'anchor': f'f2b-jail/{remote_user}',
|
return jsonify({'anchor': f'f2b-jail/{remote_user}',
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
Tests for /list route
|
Tests for /list route
|
||||||
'''
|
'''
|
||||||
from types import SimpleNamespace
|
from types import SimpleNamespace
|
||||||
|
from subprocess import CalledProcessError
|
||||||
|
|
||||||
|
|
||||||
_PF_TABLE_LIST = b''' 192.0.2.66
|
_PF_TABLE_LIST = b''' 192.0.2.66
|
||||||
@ -75,7 +76,7 @@ def test_list_single_table(client, mocker, valid_credentials):
|
|||||||
headers={"Authorization":
|
headers={"Authorization":
|
||||||
"Basic " + valid_credentials})
|
"Basic " + valid_credentials})
|
||||||
|
|
||||||
assert response.json['anchor'] == 'f2b-sshd/test.example.com'
|
assert response.json['table'] == 'f2b-sshd'
|
||||||
assert response.json['result'] == _LIST_RESULT
|
assert response.json['result'] == _LIST_RESULT
|
||||||
|
|
||||||
|
|
||||||
@ -88,10 +89,13 @@ def test_list_nonexistent_table(client, mocker, valid_credentials):
|
|||||||
|
|
||||||
run_res = SimpleNamespace()
|
run_res = SimpleNamespace()
|
||||||
run_res.stdout = b''
|
run_res.stdout = b''
|
||||||
run_res.stderr = b'No ALTQ support in kernel\nALTQ related functions disabled\n'
|
run_res.stderr = b'No ALTQ support in kernel\nALTQ related functions disabled\n' \
|
||||||
|
b'pfctl: Table does not exist.\n'
|
||||||
run_res.returncode = 255
|
run_res.returncode = 255
|
||||||
run_res.check_returncode = noop
|
run_res.check_returncode = noop
|
||||||
|
|
||||||
|
# XXX raise a CalledProcessError here...
|
||||||
|
|
||||||
mocker.patch('jail2ban.pfctl.run', return_value=run_res)
|
mocker.patch('jail2ban.pfctl.run', return_value=run_res)
|
||||||
|
|
||||||
response = client.get("/list/nonexistent",
|
response = client.get("/list/nonexistent",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user