Compare commits

7 Commits

Author SHA1 Message Date
3e64189f8f 2023.1 release notes 2023-01-13 10:33:34 +01:00
45dc173ea7 Merge branch 'feature/3-provide-application-health-check' into 'develop'
Implements #3, a /ping endpoint

See merge request ruben/jail2ban-pf!5
2023-01-13 09:30:03 +00:00
9b85bfabdb Implements #3, a /ping endpoint 2023-01-13 09:30:03 +00:00
969ba0f64c Switch to python 3.9 image 2023-01-09 22:58:27 +01:00
d9b5d36835 Not yet 2023-01-09 22:55:21 +01:00
9f86e143fe Oops vim autoindent 2023-01-09 21:51:10 +00:00
a49da1f3ef Enable SAST 2023-01-09 22:47:34 +01:00
4 changed files with 23 additions and 1 deletions

View File

@ -1,6 +1,6 @@
run tests:
stage: test
image: python:3.8
image: python:3.9
script:
- pip install pytest pytest-cov pytest-mock pytest-flask
- pip install Flask-HTTPAuth

3
CHANGELOG Normal file
View File

@ -0,0 +1,3 @@
- 2023.1
* Implement #3, a /ping health check endpoint

View File

@ -42,6 +42,15 @@ def create_app():
check_password_hash(users.get(username), password):
return username
@app.route("/ping", methods=['GET'])
@auth.login_required
def ping():
remote_user = auth.username()
app.logger.info('Received ping for'
f' anchor f2b-jail/{remote_user}')
return jsonify({'anchor': f'f2b-jail/{remote_user}',
'operation': 'ping',
'result': 'pong'})
@app.route("/flush/<name>", methods=['GET'])
@auth.login_required
def flush(name):

10
tests/test_ping.py Normal file
View File

@ -0,0 +1,10 @@
def test_ping(client, mocker, valid_credentials):
'''
Test application health check
'''
response = client.get("/ping",
headers={"Authorization":
"Basic " + valid_credentials})
assert response.json['operation'] == 'ping'