This is an automated email from the ASF dual-hosted git repository.
lizhimins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new d837a807e fix(cluster): reject a blank NameServer address in the mock
probe (#6786)
d837a807e is described below
commit d837a807e8b6a686c9e29b454ec8dc223526e3fc
Author: Apulupie <[email protected]>
AuthorDate: Fri Nov 27 12:46:19 2026 +0800
fix(cluster): reject a blank NameServer address in the mock probe (#6786)
---
web/src/services/clusterService.test.ts | 14 ++++++++++++++
web/src/services/clusterService.ts | 6 ++++++
2 files changed, 20 insertions(+)
diff --git a/web/src/services/clusterService.test.ts
b/web/src/services/clusterService.test.ts
index fd2af0972..cb3c1092f 100644
--- a/web/src/services/clusterService.test.ts
+++ b/web/src/services/clusterService.test.ts
@@ -32,12 +32,26 @@ import {
listClusters,
listK8sCerts,
previewClusterConfig,
+ testClusterConnection,
updateClusterConfig,
updateK8sCert,
updateNameServer,
} from './clusterService';
describe('clusterService mock clusters', () => {
+ it('requires the NameServer address the endpoint requires', async () => {
+ // TestConnectionDTO declares @NotBlank namesrvAddr, so the endpoint
answers 400
+ // "namesrvAddr is required" for a blank address. The connect form's
required rule accepts a
+ // whitespace-only value (async-validator's required rule rejects only the
empty string), so
+ // the service sees blank input and the mock must reject it like
connectionsService does.
+ await expect(testClusterConnection(' ')).rejects.toThrow('namesrvAddr is
required');
+ await expect(testClusterConnection('')).rejects.toThrow('namesrvAddr is
required');
+
+ await expect(testClusterConnection(' 10.101.2.1:9876
')).resolves.toMatchObject({
+ connected: true,
+ namesrvAddr: '10.101.2.1:9876',
+ });
+ });
it('returns defensive copies from cluster detail reads', async () => {
const cluster = await getCluster('cluster-prod');
const originalBrokerStatus = cluster.brokers[0].status;
diff --git a/web/src/services/clusterService.ts
b/web/src/services/clusterService.ts
index 058d28b7a..aa640791f 100644
--- a/web/src/services/clusterService.ts
+++ b/web/src/services/clusterService.ts
@@ -96,6 +96,12 @@ export async function deleteNameserverRegistry(id: number):
Promise<void> {
export async function testClusterConnection(namesrvAddr: string):
Promise<ClusterProbeResult> {
if (isMockMode()) {
const trimmed = namesrvAddr.trim();
+ // TestConnectionDTO declares @NotBlank namesrvAddr, so the endpoint
refuses a blank address with
+ // 400 "namesrvAddr is required". The connect form's required rule accepts
a whitespace-only
+ // value, so the mock must reject it here - connectionsService already
does the same check.
+ if (!trimmed) {
+ throw new Error('namesrvAddr is required');
+ }
const cluster = clusters[0];
const brokerNames = cluster ? cluster.brokers.map((broker) => broker.name)
: [];
return {