2026-08-09 10:43:45 +08:00
|
|
|
//go:build integration
|
|
|
|
|
|
|
|
|
|
package test
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"log"
|
|
|
|
|
"testing"
|
|
|
|
|
"time"
|
|
|
|
|
|
2026-08-09 12:41:08 +08:00
|
|
|
pb "bsm/full/module/base/sender/pb"
|
2026-08-09 10:43:45 +08:00
|
|
|
"google.golang.org/grpc"
|
|
|
|
|
"google.golang.org/grpc/credentials/insecure"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestSms(t *testing.T) {
|
|
|
|
|
conn, err := grpc.NewClient("192.168.31.148:12208",
|
|
|
|
|
grpc.WithTransportCredentials(insecure.NewCredentials()))
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatalf("连接失败: %v", err)
|
|
|
|
|
}
|
|
|
|
|
defer conn.Close()
|
|
|
|
|
|
|
|
|
|
client := pb.NewSmsClient(conn)
|
|
|
|
|
|
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
req := &pb.SmsSendRequest{
|
|
|
|
|
Phone: "18610192292",
|
|
|
|
|
TemplateCode: "SMS_101025114",
|
|
|
|
|
Paramters: map[string]string{
|
|
|
|
|
"code": "123456",
|
|
|
|
|
},
|
|
|
|
|
SignName: "身份验证",
|
|
|
|
|
Provider: "aliyun",
|
|
|
|
|
}
|
|
|
|
|
res, err := client.Send(ctx, req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatalf("RPC调用失败: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.Printf("响应结果: %v", res.GetReply())
|
|
|
|
|
}
|