Compare commits
No commits in common. "4999208fc3d5c9d0e53a511ba81a429b3e6db1b4" and "59ecd48210d3a7cda4ac3aa9090b0092be735a09" have entirely different histories.
4999208fc3
...
59ecd48210
@ -191,8 +191,6 @@ def create_app():
|
|||||||
Show a json parsable error if the value is illegal
|
Show a json parsable error if the value is illegal
|
||||||
'''
|
'''
|
||||||
app.logger.fatal(error)
|
app.logger.fatal(error)
|
||||||
app.logger.fatal('stdout: %s', error.stderr)
|
|
||||||
app.logger.fatal('stderr: %s', error.stderr)
|
|
||||||
return jsonify({'error': str(error)}), 500
|
return jsonify({'error': str(error)}), 500
|
||||||
|
|
||||||
@app.errorhandler(FileNotFoundError)
|
@app.errorhandler(FileNotFoundError)
|
||||||
|
@ -109,32 +109,3 @@ def test_list_nonexistent_table(client, mocker, valid_credentials):
|
|||||||
assert response.status_code == 404
|
assert response.status_code == 404
|
||||||
assert response.json['error'] == "'nonexistent' is not " \
|
assert response.json['error'] == "'nonexistent' is not " \
|
||||||
"a known fail2ban jail"
|
"a known fail2ban jail"
|
||||||
|
|
||||||
def test_list_wrong_table_name(client, mocker, valid_credentials):
|
|
||||||
'''
|
|
||||||
Test for an wrong table name that lets pfctl fail. should result in a 500
|
|
||||||
'''
|
|
||||||
def noop():
|
|
||||||
pass
|
|
||||||
|
|
||||||
run_res = SimpleNamespace()
|
|
||||||
run_res.stdout = b''
|
|
||||||
run_res.stderr = b'No ALTQ support in kernel\nALTQ related functions disabled\n' \
|
|
||||||
b'pfctl: Invalid argument.\n'
|
|
||||||
run_res.returncode = 255
|
|
||||||
run_res.check_returncode = noop
|
|
||||||
|
|
||||||
mocker.patch('jail2ban.pfctl.run',
|
|
||||||
return_value=run_res,
|
|
||||||
side_effect=CalledProcessError(run_res.returncode,
|
|
||||||
'foobar',
|
|
||||||
output=run_res.stdout,
|
|
||||||
stderr=run_res.stderr)
|
|
||||||
)
|
|
||||||
|
|
||||||
response = client.get("/list/notanerrorbuttestneedstofail",
|
|
||||||
headers={"Authorization":
|
|
||||||
"Basic " + valid_credentials})
|
|
||||||
|
|
||||||
assert response.status_code == 500
|
|
||||||
assert response.json['error'] == "Command 'foobar' returned non-zero exit status 255."
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user