Compare commits
7 Commits
36ff86c71e
...
2023.1
Author | SHA1 | Date | |
---|---|---|---|
3e64189f8f
|
|||
45dc173ea7 | |||
9b85bfabdb | |||
969ba0f64c
|
|||
d9b5d36835
|
|||
9f86e143fe | |||
a49da1f3ef
|
@ -1,6 +1,6 @@
|
|||||||
run tests:
|
run tests:
|
||||||
stage: test
|
stage: test
|
||||||
image: python:3.8
|
image: python:3.9
|
||||||
script:
|
script:
|
||||||
- pip install pytest pytest-cov pytest-mock pytest-flask
|
- pip install pytest pytest-cov pytest-mock pytest-flask
|
||||||
- pip install Flask-HTTPAuth
|
- pip install Flask-HTTPAuth
|
||||||
|
3
CHANGELOG
Normal file
3
CHANGELOG
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
- 2023.1
|
||||||
|
|
||||||
|
* Implement #3, a /ping health check endpoint
|
@ -42,6 +42,15 @@ def create_app():
|
|||||||
check_password_hash(users.get(username), password):
|
check_password_hash(users.get(username), password):
|
||||||
return username
|
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'])
|
@app.route("/flush/<name>", methods=['GET'])
|
||||||
@auth.login_required
|
@auth.login_required
|
||||||
def flush(name):
|
def flush(name):
|
||||||
|
10
tests/test_ping.py
Normal file
10
tests/test_ping.py
Normal 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'
|
Reference in New Issue
Block a user