fix(jira): report which admin config field is actually missing
Aegis CI / lint-and-test (push) Has been cancelled
Snyk Security Scan / Python vulnerabilities (backend) (push) Has been cancelled
Snyk Security Scan / npm vulnerabilities (frontend) (push) Has been cancelled
Snyk Security Scan / Docker image vulnerabilities (backend) (push) Has been cancelled
Aegis CI / lint-and-test (push) Has been cancelled
Snyk Security Scan / Python vulnerabilities (backend) (push) Has been cancelled
Snyk Security Scan / npm vulnerabilities (frontend) (push) Has been cancelled
Snyk Security Scan / Docker image vulnerabilities (backend) (push) Has been cancelled
POST /system/jira-test bundled 4 independent checks (enabled, url, admin_email, admin_api_token) behind has_admin_jira_configured() but always blamed "Admin Email and Admin API Token" regardless of which one failed. Found via live QA: URL/email/token were all correctly saved, but the "Enable Jira Integration" toggle was never switched on — the error message pointed at the wrong fields, making it look like the already-set credentials were missing.
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
"""Tests for POST /system/jira-test's diagnostic message.
|
||||
|
||||
Regression coverage for a real QA-reported bug: has_admin_jira_configured()
|
||||
bundles four independent checks (enabled, url, admin_email, admin_api_token)
|
||||
into one bool, but the error message always blamed "Admin Email and Admin
|
||||
API Token" regardless of which check actually failed. An admin who had set
|
||||
url/email/token correctly but never flipped the "Enable Jira Integration"
|
||||
toggle saw a misleading message pointing at the wrong fields.
|
||||
"""
|
||||
|
||||
from app.models.system_config import SystemConfig
|
||||
|
||||
|
||||
def _set_config(db, key, value):
|
||||
db.add(SystemConfig(key=key, value=value))
|
||||
|
||||
|
||||
def test_jira_test_reports_disabled_toggle_specifically(client, db, auth_headers):
|
||||
"""url/email/token all set, but jira.enabled is missing entirely —
|
||||
the message must call out the toggle, not email/token."""
|
||||
_set_config(db, "jira.url", "https://example.atlassian.net")
|
||||
_set_config(db, "jira.admin_email", "admin@example.com")
|
||||
_set_config(db, "jira.admin_api_token", "some-real-token")
|
||||
db.commit()
|
||||
|
||||
resp = client.post("/api/v1/system/jira-test", headers=auth_headers)
|
||||
assert resp.status_code == 200
|
||||
body = resp.json()
|
||||
assert body["status"] == "error"
|
||||
assert "not enabled" in body["message"]
|
||||
assert "Admin Email" not in body["message"]
|
||||
assert "Admin API Token" not in body["message"]
|
||||
|
||||
|
||||
def test_jira_test_reports_missing_email_and_token_when_actually_missing(client, db, auth_headers):
|
||||
_set_config(db, "jira.url", "https://example.atlassian.net")
|
||||
_set_config(db, "jira.enabled", "true")
|
||||
db.commit()
|
||||
|
||||
resp = client.post("/api/v1/system/jira-test", headers=auth_headers)
|
||||
assert resp.status_code == 200
|
||||
body = resp.json()
|
||||
assert body["status"] == "error"
|
||||
assert "Admin Email is not set" in body["message"]
|
||||
assert "Admin API Token is not set" in body["message"]
|
||||
assert "not enabled" not in body["message"]
|
||||
|
||||
|
||||
def test_jira_test_missing_url_reports_url_specifically(client, db, auth_headers):
|
||||
resp = client.post("/api/v1/system/jira-test", headers=auth_headers)
|
||||
assert resp.status_code == 200
|
||||
body = resp.json()
|
||||
assert body["status"] == "error"
|
||||
assert "Jira URL is not configured" in body["message"]
|
||||
Reference in New Issue
Block a user