Let's test an method that is not allowed in app.route
This commit is contained in:
parent
e3a71a851d
commit
3f94410716
@ -36,3 +36,19 @@ def test_flush_nonexistent(client, mocker):
|
|||||||
headers={"Authorization": "Basic " + valid_credentials})
|
headers={"Authorization": "Basic " + valid_credentials})
|
||||||
|
|
||||||
assert 'error' in response.json
|
assert 'error' in response.json
|
||||||
|
|
||||||
|
|
||||||
|
def test_wrong_method(client, mocker):
|
||||||
|
|
||||||
|
cmd = ['/usr/local/bin/sudo', '/sbin/pfctl', '-a', 'some/anchor', '-t', 'nonexistent', '-T', 'flush']
|
||||||
|
|
||||||
|
mocker.patch('jail2ban.pfctl.run',
|
||||||
|
side_effect=CalledProcessError(255, cmd, output=b'',
|
||||||
|
stderr=b'pfctl: Table does not exist'))
|
||||||
|
|
||||||
|
valid_credentials = base64.b64encode(b"test.example.com:testpassword").decode("utf-8")
|
||||||
|
name = 'nonexistent'
|
||||||
|
response = client.put(f"/flush/{name}",
|
||||||
|
headers={"Authorization": "Basic " + valid_credentials})
|
||||||
|
|
||||||
|
assert response.status_code == 405
|
||||||
|
Loading…
x
Reference in New Issue
Block a user