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

   ### Which Issue(s) This PR Fixes
   
   - Fixes #6507
   
   ### Brief Description
   
   The cloud catalog entry points accepted a `credentialId` verbatim and never 
resolved it: `TencentCatalogService.listRegions:76-79` checked only that the id 
was non-null and returned the static region list, so a credential id that does 
not exist still produced all 19 Tencent regions, and a credential belonging to 
the other vendor was handed to that vendor's SDK, which reported its own `422 
Cloud credential is invalid` instead of naming the mismatch. 
`InstanceService.importCloudInstances:260-264` — the operation that consumes 
the same pair of parameters — already rejects both cases with `404 Cloud 
credential not found` and `400 Cloud credential vendor does not match 
<vendor>`, so the catalog disagreed with the import path it feeds. Each of the 
six catalog entry points (`TencentCatalogService.listRegions` / 
`listCloudInstances` / `getCloudInstance`, `AliyunCatalogService.listRegions` / 
`listCloudInstances` / `getCloudInstance`) now resolves the credential through 
`CloudCredential
 Repository` first and rejects an unknown id (404) or a credential of the other 
vendor (400) before any cloud call. User-visible change: `GET 
/api/cloud/{tencent,aliyun}/regions|instances` now answer `404`/`400` for a 
credential the server cannot use instead of returning catalog data or an SDK 
authentication error; requests with their own vendor's credential are 
unchanged. Both endpoints are absent from `docs/api-spec.md`, so no documented 
contract needed updating.
   
   ### How Did You Test This Change?
   
   ```
   cd server
   mvn -B -ntp test -DforkCount=1 
-Dtest=TencentCatalogServiceTest,AliyunCatalogServiceTest
   [INFO] Running 
org.apache.rocketmq.studio.provider.tencent.TencentCatalogServiceTest
   [INFO] Tests run: 14, Failures: 0, Errors: 0, Skipped: 0 -- in 
...TencentCatalogServiceTest
   [INFO] Running 
org.apache.rocketmq.studio.provider.alibaba.AliyunCatalogServiceTest
   [INFO] Tests run: 13, Failures: 0, Errors: 0, Skipped: 0 -- in 
...AliyunCatalogServiceTest
   [INFO] Tests run: 27, Failures: 0, Errors: 0, Skipped: 0
   [INFO] You have 0 Checkstyle violations.
   ```
   
   The six new cases fail without the fix 
(`listRegionsShouldRejectAnUnknownCredentialTest` and 
`listRegionsShouldRejectACredentialOfTheOtherVendorTest` / 
`listCloudInstancesShouldRejectACredentialOfTheOtherVendorTest` in both 
classes; each asserts the status code and 
`verifyNoInteractions(clientFactory)`):
   
   ```
   [ERROR] Tests run: 27, Failures: 6, Errors: 0, Skipped: 0
   ...listRegionsShouldRejectAnUnknownCredentialTest -- FAILURE!
   java.lang.AssertionError: Expecting code to raise a throwable.
   ...listRegionsShouldRejectACredentialOfTheOtherVendorTest -- FAILURE!
   java.lang.AssertionError: Expecting code to raise a throwable.
   ...listCloudInstancesShouldRejectACredentialOfTheOtherVendorTest -- FAILURE!
   java.lang.AssertionError: Expecting code to raise a throwable.
   ```
   
   ### 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