Add test for flush
This commit is contained in:
parent
af1fef189c
commit
47e8208ce2
22
tests/test_flush.py
Normal file
22
tests/test_flush.py
Normal file
@ -0,0 +1,22 @@
|
||||
import base64
|
||||
from types import SimpleNamespace
|
||||
|
||||
|
||||
def test_flush(client, mocker):
|
||||
def noop():
|
||||
pass
|
||||
run_res = SimpleNamespace()
|
||||
run_res.stdout = b''
|
||||
run_res.stderr = b'1/1 addresses deleted.\n'
|
||||
run_res.returncode = 0
|
||||
run_res.check_returncode = noop
|
||||
|
||||
mocker.patch('jail2ban.pfctl.run', return_value=run_res)
|
||||
|
||||
valid_credentials = base64.b64encode(b"test.example.com:testpassword").decode("utf-8")
|
||||
name = 'sshd'
|
||||
response = client.get(f"/flush/{name}",
|
||||
headers={"Authorization": "Basic " + valid_credentials})
|
||||
|
||||
assert response.json['operation'] == 'delete'
|
||||
|
Loading…
x
Reference in New Issue
Block a user