Skip to content

Commit

Permalink
Merge 1fbb352 into b23ef50
Browse files Browse the repository at this point in the history
  • Loading branch information
hluk committed Dec 5, 2023
2 parents b23ef50 + 1fbb352 commit e998679
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
19 changes: 18 additions & 1 deletion greenwave/app_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
import logging.config

from flask import Flask
from flask import Flask, current_app, jsonify
from greenwave.api_v1 import api
from greenwave.utils import json_error, load_config, mangle_key
from greenwave.policies import load_policies
Expand Down Expand Up @@ -50,6 +50,7 @@ def create_app(config_obj=None):

# register blueprints
app.register_blueprint(api, url_prefix="/api/v1.0")
app.add_url_rule('/', view_func=landing_page)
app.add_url_rule('/healthcheck', view_func=healthcheck)

# Initialize the cache.
Expand All @@ -59,6 +60,22 @@ def create_app(config_obj=None):
return app


def landing_page():
return (
jsonify({
"documentation": current_app.config["DOCUMENTATION_URL"],
"api_v1": current_app.config["GREENWAVE_API_URL"],
"resultsdb_api": current_app.config["RESULTSDB_API_URL"],
"waiverdb_api": current_app.config["WAIVERDB_API_URL"],
"koji_api": current_app.config["KOJI_BASE_URL"],
"outcomes_passed": current_app.config["OUTCOMES_PASSED"],
"outcomes_error": current_app.config["OUTCOMES_ERROR"],
"outcomes_incomplete": current_app.config["OUTCOMES_INCOMPLETE"],
}),
200,
)


def healthcheck():
"""
Request handler for performing an application-level health check. This is
Expand Down
2 changes: 2 additions & 0 deletions greenwave/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ class Config(object):
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_SAMESITE = "Lax"

DOCUMENTATION_URL = "https://gating-greenwave.readthedocs.io"


class ProductionConfig(Config):
DEBUG = False
Expand Down
19 changes: 19 additions & 0 deletions greenwave/tests/test_landing_page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-License-Identifier: GPL-2.0+
from unittest.mock import ANY


def test_landing_page(client):
response = client.get("/")
assert response.status_code == 200, response.text
data = response.json
config = client.application.config
assert data == {
"documentation": config["DOCUMENTATION_URL"],
"api_v1": config["GREENWAVE_API_URL"],
"resultsdb_api": config["RESULTSDB_API_URL"],
"waiverdb_api": config["WAIVERDB_API_URL"],
"koji_api": config["KOJI_BASE_URL"],
"outcomes_passed": list(config["OUTCOMES_PASSED"]),
"outcomes_error": list(config["OUTCOMES_ERROR"]),
"outcomes_incomplete": list(config["OUTCOMES_INCOMPLETE"]),
}

0 comments on commit e998679

Please sign in to comment.