[
https://issues.apache.org/jira/browse/KNOX-3296?focusedWorklogId=1014543&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1014543
]
ASF GitHub Bot logged work on KNOX-3296:
----------------------------------------
Author: ASF GitHub Bot
Created on: 10/Apr/26 13:58
Start Date: 10/Apr/26 13:58
Worklog Time Spent: 10m
Work Description: hanicz commented on code in PR #1196:
URL: https://github.com/apache/knox/pull/1196#discussion_r3064713603
##########
.github/workflows/tests/test_health.py:
##########
@@ -53,6 +54,32 @@ def test_health_metrics_returns_json(self):
payload = json.loads(response.text)
self.assertIsInstance(payload, dict)
+ def test_health_metrics_contains_core_fields(self):
+ """Metrics JSON should expose the same top-level keys as the Java
GatewayHealthFuncTest."""
+ url = self.base_url + "gateway/health/v1/metrics?pretty=true"
+ response = knox_get(url)
+ self.assertEqual(response.status_code, 200)
+ payload = json.loads(response.text)
+ expected = {"timers", "histograms", "counters", "gauges", "version",
"meters"}
+ self.assertTrue(expected.issubset(payload.keys()), msg=f"Missing keys:
{expected - set(payload.keys())}")
+
+ def test_health_metrics_without_pretty_returns_json(self):
+ """Metrics without pretty still returns 200 and parseable JSON."""
+ url = self.base_url + "gateway/health/v1/metrics"
+ response = knox_get(url)
+ self.assertEqual(response.status_code, 200)
+ self.assertIn("application/json", response.headers.get("Content-Type",
""))
+ payload = json.loads(response.text)
+ self.assertIsInstance(payload, dict)
+
+ def test_health_ping_content_type_is_plain_text(self):
+ """Ping response declares text/plain Content-Type."""
+ url = self.base_url + "gateway/health/v1/ping"
+ response = knox_get(url)
+ self.assertEqual(response.status_code, 200)
+ content_type = response.headers.get("Content-Type", "")
+ self.assertIn("text/plain", content_type)
Review Comment:
Could you check for the actual content as well? (OK)
##########
.github/workflows/tests/test_health.py:
##########
@@ -53,6 +54,32 @@ def test_health_metrics_returns_json(self):
payload = json.loads(response.text)
self.assertIsInstance(payload, dict)
+ def test_health_metrics_contains_core_fields(self):
+ """Metrics JSON should expose the same top-level keys as the Java
GatewayHealthFuncTest."""
+ url = self.base_url + "gateway/health/v1/metrics?pretty=true"
+ response = knox_get(url)
+ self.assertEqual(response.status_code, 200)
+ payload = json.loads(response.text)
+ expected = {"timers", "histograms", "counters", "gauges", "version",
"meters"}
+ self.assertTrue(expected.issubset(payload.keys()), msg=f"Missing keys:
{expected - set(payload.keys())}")
+
+ def test_health_metrics_without_pretty_returns_json(self):
+ """Metrics without pretty still returns 200 and parseable JSON."""
+ url = self.base_url + "gateway/health/v1/metrics"
+ response = knox_get(url)
+ self.assertEqual(response.status_code, 200)
+ self.assertIn("application/json", response.headers.get("Content-Type",
""))
Review Comment:
It would make sense to check for the same payload keys as you did in the
pretty test.
Issue Time Tracking
-------------------
Worklog Id: (was: 1014543)
Remaining Estimate: 23h 50m (was: 24h)
Time Spent: 20m (was: 10m)
> Expand CI integration tests: health metrics, HSTS, and KnoxLDAP auth paths
> --------------------------------------------------------------------------
>
> Key: KNOX-3296
> URL: https://issues.apache.org/jira/browse/KNOX-3296
> Project: Apache Knox
> Issue Type: Improvement
> Components: KnoxCLI
> Reporter: Raghav Maheshwari
> Priority: Major
> Time Spent: 20m
> Remaining Estimate: 23h 50m
>
> * Health API tests ({{{}test_health.py{}}})
> ** {{/gateway/health/v1/metrics}}: JSON response, alignment with Java
> {{GatewayHealthFuncTest}} top-level keys (timers, histograms, counters,
> gauges, version, meters), with and without {{{}pretty=true{}}}.
> ** {{/gateway/health/v1/ping}}: {{Content-Type}} is plain text; existing
> ping + HSTS checks retained.
> * KnoxLDAP auth tests ({{{}test_knoxauth_preauth_and_paths.py{}}})
> ** Preauth ({{{}/gateway/knoxldap/auth/api/v1/pre{}}}): unauthenticated →
> 401; bad credentials → 401; POST and GET with valid guest credentials → 200
> and {{{}x-knox-actor-username{}}}; admin → 200 and expected group headers
> ({{{}longGroupName1{}}}, {{{}longGroupName2{}}}).
> ** Extauthz path behavior: GET under {{extauthz}} with an extra path segment
> returns 404 (path not ignored), guarding routing/regression for KnoxLDAP.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)