Frun1na opened a new pull request, #6108:
URL: https://github.com/apache/rocketmq-dashboard/pull/6108

   ### Which Issue(s) This PR Fixes
   
   - Fixes #6107
   
   ### Brief Description
   
   A data source saved from the console stores its authentication mode as 
`Basic Auth` / `Bearer Token`;
   `SettingsService.normalizeAuth` canonicalizes that to `basic auth` / `bearer 
token` (`AUTH_BASIC` /
   `AUTH_BEARER`) and its connection test accepts those values. The query path
   (`AbstractPrometheusCompatibleMetricsSource.applyAuthentication`,
   `cluster/metrics/AbstractPrometheusCompatibleMetricsSource.java:203`) 
switched on the legacy
   `studio.prometheus` vocabulary (`basic` / `bearer`) only, so every 
authenticated data source fell into the
   `default` branch and answered `503 Unsupported Prometheus authentication 
mode: basic auth` for every query —
   while its connection test kept passing. The Metrics Explorer, the dashboards 
and the instance-bound tool query
   all build their source from the stored configuration, so none of them could 
read such a source.
   
   The configured mode is now resolved to the canonical token the switch uses, 
accepting both vocabularies
   (`Basic Auth` / `basic auth` / `basic` and the bearer equivalents). An 
unrecognized mode is still rejected with
   the message naming what was configured, and `none` still sends no 
credentials.
   
   User-visible change: a data source with basic or bearer authentication now 
carries its credentials and returns
   series instead of answering `503` on every query.
   
   ### How Did You Test This Change?
   
   ```
   cd server && mvn -B -ntp test -DforkCount=1 
-Dsurefire.failIfNoSpecifiedTests=false -Dtest=MultiBackendMetricsSourceTest
   [INFO] --- checkstyle:3.6.0:check (validate) @ rocketmq-studio ---
   [INFO] Tests run: 17, Failures: 0, Errors: 0, Skipped: 0
   [INFO] BUILD SUCCESS
   ```
   
   The three new cases fail without the fix, with only the product file 
reverted:
   
   ```
   [ERROR] Tests run: 17, Failures: 0, Errors: 3, Skipped: 0
   storedBasicAuthModeShouldSendTheCredentialsTest -- <<< ERROR!
   org.apache.rocketmq.studio.cluster.metrics.PrometheusException: Unsupported 
Prometheus authentication mode: basic auth
        at 
...AbstractPrometheusCompatibleMetricsSource.applyAuthentication(AbstractPrometheusCompatibleMetricsSource.java:224)
   storedBearerAuthModeShouldSendTheTokenTest -- <<< ERROR!
   org.apache.rocketmq.studio.cluster.metrics.PrometheusException: Unsupported 
Prometheus authentication mode: bearer token
   consoleAuthModeShouldBeAcceptedBeforeCanonicalizationTest -- <<< ERROR!
   org.apache.rocketmq.studio.cluster.metrics.PrometheusException: Unsupported 
Prometheus authentication mode: Basic Auth
   ```
   
   The existing cases pin the rest of the contract: an unrecognized mode 
(`digest`) is still rejected with a
   `503` naming it, and `none` still sends no credentials.
   
   ### Checklist
   
   - [x] One coherent change; unrelated modifications are not bundled in
   - [x] Commit subject follows Conventional Commits (`feat:` / `fix:` / 
`refactor:` / `chore:` / `docs:` / `perf:`)
   - [x] Tests added or updated for non-trivial changes, test methods named 
`...Test`
   - [ ] New UI text has both Chinese and English entries under `web/src/i18n/`
   - [ ] Architecture constraints stay green (`mvn test` runs the ArchUnit 
checks)
   - [ ] New source files carry the ASF license header
   - [ ] Documentation touched where behaviour changed (README / `docs/` / 
in-app help)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to