youngkermit8-coder opened a new pull request, #1512: URL: https://github.com/apache/rocketmq-dashboard/pull/1512
## What is the purpose of the change Fixes #1511. After #1423 correctly blocked loopback data-source URLs, `SettingsServiceTest` still used a real HTTP fixture at `127.0.0.1`. Seven existing tests therefore failed at SSRF validation before reaching their intended request, authentication, locale, and response-body assertions. ## Brief changelog - Keep the public production constructor and its 3-second connect / 5-second read timeout configuration unchanged. - Add a package-private constructor for injecting a prebuilt `RestClient` in unit tests. - Replace the loopback `HttpServer` with `MockRestServiceServer` and the reserved TEST-NET address `192.0.2.1`. - Assert the exact Prometheus query URI, HTTP method, Basic/Bearer headers, successful response mapping, and error response mapping without real network access. This restores the tests without weakening the production SSRF guard or depending on a machine's network interfaces. ## Verifying this change Validated with JDK 21 on top of #1502 in an isolated clean worktree, without adding #1502 to this PR: ```text mvn -B -ntp -Dtest=SettingsServiceTest clean package Compiling 374 main source files Compiling 109 test source files Tests run: 29, Failures: 0, Errors: 0, Skipped: 0 Checkstyle: 0 violations BUILD SUCCESS ``` The pending #1510 adds one more `SettingsServiceTest` case, so the combined expected count is 30. - [x] A GitHub issue is filed for the change. - [x] The change has a single test-reliability responsibility. - [x] Signed-off-by and validation records are included. -- 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]
