Gracefully handle FileNotFoundError exceptions

This commit is contained in:
2022-03-14 15:38:38 +01:00
parent 59cc645b98
commit 798a72cb73
2 changed files with 24 additions and 0 deletions

View File

@ -52,3 +52,19 @@ def test_wrong_method(client, mocker):
headers={"Authorization": "Basic " + valid_credentials})
assert response.status_code == 405
def test_filenotfound(app, mocker):
app.config.update({
"AUTHFILE": '../tests/nonexistent-users-test.txt'
})
client = app.test_client()
valid_credentials = base64.b64encode(b"test.example.com:testpassword").decode("utf-8")
name = 'nonexistent'
response = client.get(f"/flush/{name}",
headers={"Authorization": "Basic " + valid_credentials})
assert response.status_code == 500