Add case for detecing invalid input
This commit is contained in:
parent
a20145b447
commit
ffe144f6b5
@ -19,7 +19,7 @@ def test_request_unauth(client):
|
||||
assert response.json['error'] == 'Access Denied'
|
||||
|
||||
|
||||
def test_request_example(client, mocker):
|
||||
def test_request_valid(client, mocker):
|
||||
def noop():
|
||||
pass
|
||||
run_res = SimpleNamespace()
|
||||
@ -38,3 +38,24 @@ def test_request_example(client, mocker):
|
||||
headers={"Authorization": "Basic " + valid_credentials})
|
||||
|
||||
assert response.json['remote_user'] == 'test.example.com'
|
||||
|
||||
|
||||
def test_request_invalid(client, mocker):
|
||||
def noop():
|
||||
pass
|
||||
run_res = SimpleNamespace()
|
||||
run_res.stdout = pfctl_stdout_lines
|
||||
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")
|
||||
json_payload = {"port":
|
||||
"not a pf statement",
|
||||
"name": "dovecot", "protocol": "tcp"}
|
||||
|
||||
response = client.put("/register",
|
||||
json=json_payload,
|
||||
headers={"Authorization": "Basic " + valid_credentials})
|
||||
|
||||
assert response.json['error'] == '"not a pf statement" is tainted'
|
||||
|
Loading…
x
Reference in New Issue
Block a user