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

   <!-- Base branch: `rocketmq-studio`, the RocketMQ Studio trunk. -->
   
   ### Which Issue(s) This PR Fixes
   
   - Fixes #4223
   
   ### Brief Description
   
   `AuthService.listUsers` bound the `search` request parameter straight into a 
MyBatis-Plus `LIKE`
   predicate, so `%` and `_` in a username search were interpreted as wildcards:
   
   - searching `_` matched every user, and `100%` matched any username starting 
with `100`;
   - a username that really contains `%` or `_` could not be searched for at 
all.
   
   The term is now escaped (`\` to `\\`, `%` to `\%`, `_` to `\_`) before it is 
bound, which is the
   same pattern `QueryHistoryService.escapeLike` already uses for the 
message-query history search.
   The escape character is MySQL's default for `LIKE`, and the Studio schema 
runs on MySQL.
   
   ### How Did You Test This Change?
   
   New test: 
`AuthServiceDatabaseTest#listUsersEscapesLikeWildcardsInTheSearchTerm`, which 
captures the
   `QueryWrapper` handed to the mapper and asserts the bound value.
   
   Before the fix (red):
   
   ```
   $ cd server && mvn -B -ntp test 
-Dtest='AuthServiceDatabaseTest#listUsersEscapesLikeWildcardsInTheSearchTerm'
   [ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
   Expecting Values:
     ["%100%_off%"]
   to contain:
     ["%100\%\_off%"]
   ```
   
   After the fix (green) — the whole class, so the neighbouring 
search/pagination tests are covered too:
   
   ```
   $ cd server && mvn -B -ntp test -Dtest=AuthServiceDatabaseTest
   [INFO] Tests run: 28, Failures: 0, Errors: 0, Skipped: 0
   [INFO] BUILD SUCCESS
   ```
   
   `mvn test` runs checkstyle in the `validate` phase: `You have 0 Checkstyle 
violations.`
   
   Note on the full suite: on a clean `rocketmq-studio` checkout `mvn -B -ntp 
test` already reports
   `Tests run: 3051, Failures: 6, Errors: 25, Skipped: 4`. The 11 red classes 
are the MySQL 8 backed
   Spring integration tests (`AuthServiceBootstrapIntegrationTest`,
   `AuthServiceConcurrencyIntegrationTest`, 
`AuthServiceSessionOverviewIntegrationTest`,
   `HealthProbeIntegrationTest`, `QueryHistoryServiceIntegrationTest`,
   `NativeAlertEvaluationTransactionTest`, 
`NotificationOutboxMapperIntegrationTest`,
   `RmqAlertStateMapperIntegrationTest`, `StudioApplicationTest`) plus the 
external-CLI ones
   (`CliAgentProviderTest`, `ClaudeCodeAgentProviderTest`). None of them are 
touched by this change.
   
   ### Checklist
   
   - [x] One coherent change; unrelated modifications are not bundled in
   - [x] Commit subject follows Conventional Commits (`fix:`)
   - [x] Tests added or updated for non-trivial changes, test methods named 
`...Test`
   - [x] New UI text has both Chinese and English entries under `web/src/i18n/` 
(no UI text in this change)
   - [x] Architecture constraints stay green (`mvn test` runs the ArchUnit 
checks)
   - [x] New source files carry the ASF license header (no new files)
   - [x] Documentation touched where behaviour changed (no user-visible 
contract change: the search box already promised a literal username match)
   


-- 
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