Expose env info to API clients

This commit is contained in:
nucleogenic 2022-09-19 17:00:59 +01:00
parent 0e6147e0bb
commit 1a15c4c648
No known key found for this signature in database
GPG Key ID: 04A5E4E319C4271D
2 changed files with 20 additions and 1 deletions

View File

@ -260,6 +260,14 @@ def index():
)
@APP.route("/env")
def env():
"""
Shows information about the app/host environment
"""
return response(**get_env_info())
@APP.route("/drive/list", methods=["GET"])
def drive_list():
"""
@ -325,7 +333,7 @@ def login():
if AUTH_GROUP in groups:
if authenticate(str(username), str(password)):
session["username"] = request.form["username"]
return response()
return response(env=get_env_info())
return response(error=True, status_code=401, message=_(
"You must log in with valid credentials for a user in the '%(group)s' group",

View File

@ -98,6 +98,7 @@ def test_login_with_valid_credentials(pytestconfig, http_client_unauthenticated)
assert response.status_code == 200
assert response_data["status"] == STATUS_SUCCESS
assert "env" in response_data["data"]
# route("/login", methods=["POST"])
@ -737,6 +738,16 @@ def test_index(http_client):
assert "devices" in response_data["data"]
# route("/env")
def test_get_env_info(http_client):
response = http_client.get("/env")
response_data = response.json()
assert response.status_code == 200
assert response_data["status"] == STATUS_SUCCESS
assert "running_env" in response_data["data"]
# route("/pwa/<path:pwa_path>")
def test_pwa_route(http_client):
response = http_client.get("/pwa/favicon.ico")