Compare commits

16 Commits

Author SHA1 Message Date
59ecd48210 Make sure we set the error message in the json as defined in the test 2023-01-15 18:57:26 +01:00
dd66bf3dc9 Try the pfctl_table_op and set http code accordingly 2023-01-15 18:45:28 +01:00
d43a574579 Raise CalledProcessError as side effect 2023-01-15 18:10:48 +01:00
32032de81d WIP: Mention that we should raise a CalledProcessError here 2023-01-14 19:52:32 +01:00
d969ce5242 Add missing mock content from real pfctl run 2023-01-14 19:43:56 +01:00
8f0dfc9d63 Fix test by looking at the right data 2023-01-14 19:42:55 +01:00
ee38b9d5e8 Need to decode the subprocess.run bytes to ascii 2023-01-14 19:41:43 +01:00
ea325b0686 #6 Implement /list/<name> for #4 2023-01-14 17:26:00 +01:00
62d92d3c91 Pylint fixes 2023-01-14 16:29:39 +01:00
4bf881f03b Move _PFCTL_TABLE_PAT out of the pfctl module. it is not interpreted there 2023-01-14 16:14:15 +01:00
610ccec47a Please linters 2023-01-14 16:12:34 +01:00
5f7a0a4abd Write tests #5 2023-01-14 16:03:19 +01:00
87252b6c5d Ignore vim swapfiles 2023-01-14 16:03:03 +01:00
e39ffc14e1 Store this ginourmous regex I made up 2023-01-13 22:25:32 +01:00
a64d17b2e8 Merge branch 'release/2023.1' 2023-01-13 10:33:45 +01:00
9c6208f5c0 Merge branch 'release/2022.1' 2022-03-14 16:43:26 +01:00
2 changed files with 0 additions and 31 deletions

View File

@ -191,8 +191,6 @@ def create_app():
Show a json parsable error if the value is illegal
'''
app.logger.fatal(error)
app.logger.fatal('stdout: %s', error.stderr)
app.logger.fatal('stderr: %s', error.stderr)
return jsonify({'error': str(error)}), 500
@app.errorhandler(FileNotFoundError)

View File

@ -109,32 +109,3 @@ def test_list_nonexistent_table(client, mocker, valid_credentials):
assert response.status_code == 404
assert response.json['error'] == "'nonexistent' is not " \
"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."