Compare commits

...

4 Commits

3 changed files with 22 additions and 0 deletions

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'