Repository: robustmq/robustmq (language: rust)

Issue:
MINOR: Add validation to the get_share_sub_leader method in GrpcMqttService and fill in the test case
### What type of enhancement is this?

Refactor

### What does the enhancement do?

Add validation to the get_share_sub_leader method in GrpcPlacementService and fill in the test case.

Tips:
you can implement the `ValidateExt` trait on `GetShareSubLeaderRequest`, then invoke ` validate_ext ` function to achieve the validation functionality.

- you can locate the ValidateExt trait in the file: src\placement-center\src\server\grpc\validate. rs
- you need to add validation to the node_list method in this file:  src\placement-center\src\server\grpc\service_mqtt.rs
- you need to fill in the test case in this file: src\grpc-clients\tests\mqtt\mqtt_share_sub_test.rs

References 

- https://github.com/robustmq/robustmq/pull/548)https://github.com/robustmq/robustmq/pull/548

### Implementation challenges

_No response_


Discussion / hints:
I'm on it.

Fix patch:
diff --git a/.gitignore b/.gitignore
index 309a2f0b1..4c38f64c8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,6 +10,7 @@ src/rlog/log/server.log
 .idea/modules.xml
 .idea/robustmq.iml
 .idea/vcs.xml
+.idea/workspace.xml
 logs
 nohup.out
 .idea/checkstyle-idea.xml
diff --git a/src/placement-center/src/server/grpc/service_mqtt.rs b/src/placement-center/src/server/grpc/service_mqtt.rs
index 6aba6edfa..faf463711 100644
--- a/src/placement-center/src/server/grpc/service_mqtt.rs
+++ b/src/placement-center/src/server/grpc/service_mqtt.rs
@@ -38,6 +38,7 @@ use crate::mqtt::services::share_sub::ShareSubLeader;
 use crate::mqtt::services::topic::{create_topic_req, set_topic_retain_message_req};
 use crate::route::apply::RaftMachineApply;
 use crate::route::data::{StorageData, StorageDataType};
+use crate::server::grpc::validate::ValidateExt;
 use crate::storage::mqtt::acl::AclStorage;
 use crate::storage::mqtt::blacklist::MqttBlackListStorage;
 use crate::storage::mqtt::session::MqttSessionStorage;
@@ -72,6 +73,7 @@ impl MqttService for GrpcMqttService {
         request: Request<GetShareSubLeaderRequest>,
     ) -> Result<Response<GetShareSubLeaderReply>, Status> {
         let req = request.into_inner();
+        let _ = req.validate_ext()?;
         let cluster_name = req.cluster_name;
         let group_name = req.group_name;
         let mut reply = GetShareSubLeaderReply::default();
diff --git a/src/placement-center/src/server/grpc/validate.rs b/src/placement-center/src/server/grpc/validate.rs
index a8c777b13..49a5c25b5 100644
--- a/src/placement-center/src/server/grpc/validate.rs
+++ b/src/placement-center/src/server/grpc/validate.rs
@@ -19,6 +19,7 @@ use protocol::placement_center::placement_center_inner::{
     ClusterType, DeleteIdempotentDataRequest, GetResourceConfigRequest, RegisterNodeRequest,
     SetIdempotentDataRequest, SetResourceConfigRequest, UnRegisterNodeRequest,
 };
+use protocol::placement_center::placement_center_mqtt::GetShareSubLeaderRequest;
 use tonic::Status;
 
 pub trait ValidateExt {
@@ -148,6 +149,15 @@ impl ValidateExt for SetIdempotentDataRequest {
     }
 }
 
+impl ValidateExt for GetShareSubLeaderRequest {
+    fn validate_ext(&self) -> Result<(), Status> {
+        ensure_param_not_empty("group_name", &self.group_name)?;
+        ensure_param_not_empty("cluster_name", &self.cluster_name)?;
+
+        Ok(())
+    }
+}
+
 #[cfg(test)]
 mod validate_test {
     use super::*;


Test patch:
diff --git a/src/grpc-clients/tests/placement/mqtt/mqtt_share_sub_test.rs b/src/grpc-clients/tests/placement/mqtt/mqtt_share_sub_test.rs
index 4075d4801..09ff7b6a3 100644
--- a/src/grpc-clients/tests/placement/mqtt/mqtt_share_sub_test.rs
+++ b/src/grpc-clients/tests/placement/mqtt/mqtt_share_sub_test.rs
@@ -68,5 +68,25 @@ mod tests {
                 panic!("{:?}", e);
             }
         }
+
+        let request = GetShareSubLeaderRequest {
+            group_name: group_name.clone(),
+            cluster_name: "".to_string(),
+        };
+        assert!(
+            placement_get_share_sub_leader(client_pool.clone(), &addrs, request)
+                .await
+                .is_err()
+        );
+
+        let request = GetShareSubLeaderRequest {
+            group_name: "".to_string(),
+            cluster_name: cluster_name.clone(),
+        };
+        assert!(
+            placement_get_share_sub_leader(client_pool.clone(), &addrs, request)
+                .await
+                .is_err()
+        );
     }
 }