Skip to content

Commit 49e28ce

Browse files
authored
Expose config values in root URL (#71)
* Update version numbers * Expose configuration in root URL
1 parent 62b683d commit 49e28ce

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "jira-bugzilla-integration"
3-
version = "0.1.0"
3+
version = "2.0.1"
44
description = "jira-bugzilla-integration"
55
authors = ["@mozilla/jbi-core"]
66
license = "MPL"

src/app/api.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import sentry_sdk
99
import uvicorn # type: ignore
1010
from fastapi import FastAPI, Request
11-
from fastapi.responses import RedirectResponse
1211
from fastapi.staticfiles import StaticFiles
1312
from sentry_sdk.integrations.asgi import SentryAsgiMiddleware
1413

@@ -24,7 +23,7 @@
2423
app = FastAPI(
2524
title="Jira Bugzilla Integration (JBI)",
2625
description="JBI v2 Platform",
27-
version="0.1.0",
26+
version="2.0.1",
2827
)
2928

3029
app.include_router(monitor_router)
@@ -39,8 +38,17 @@
3938

4039
@app.get("/", include_in_schema=False)
4140
def root(request: Request):
42-
"""GET via root redirects to /docs."""
43-
return RedirectResponse(url="./docs")
41+
"""Expose key configuration"""
42+
return {
43+
"title": app.title,
44+
"description": app.description,
45+
"version": app.version,
46+
"documentation": app.docs_url,
47+
"configuration": {
48+
"jira_base_url": settings.jira_base_url,
49+
"bugzilla_base_url": settings.bugzilla_base_url,
50+
},
51+
}
4452

4553

4654
@app.middleware("http")

tests/unit/app/test_api.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@
99

1010

1111
def test_read_root(anon_client):
12-
"""The site root redirects to the Swagger docs"""
12+
"""The root URL provides information"""
1313
resp = anon_client.get("/")
14-
assert resp.status_code == 200
15-
assert len(resp.history) == 1
16-
prev_resp = resp.history[0]
17-
assert prev_resp.status_code == 307 # Temporary Redirect
18-
assert prev_resp.headers["location"] == "./docs"
14+
infos = resp.json()
15+
16+
assert "atlassian.net" in infos["configuration"]["jira_base_url"]
1917

2018

2119
def test_request_summary_is_logged(caplog):

0 commit comments

Comments
 (0)