refactor: reorganize modules and add Linux build tooling
This commit is contained in:
56
module/base/sender/test/grpc/mail_test.go
Normal file
56
module/base/sender/test/grpc/mail_test.go
Normal file
@@ -0,0 +1,56 @@
|
||||
//go:build integration
|
||||
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
pb "bsm/full/module/base/sender/pb"
|
||||
"git.apinb.com/bsm-sdk/core/utils"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
func TestMail(t *testing.T) {
|
||||
conn, err := grpc.NewClient("api.apinb.com:10020",
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
log.Fatalf("连接失败: %v", err)
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
client := pb.NewMailClient(conn)
|
||||
|
||||
ctx, cancel := createContext()
|
||||
defer cancel()
|
||||
|
||||
req := &pb.SendMailRequest{
|
||||
TemplateKey: "default",
|
||||
To: "271055687@qq.com",
|
||||
Paramters: map[string]string{
|
||||
"code": "123456",
|
||||
},
|
||||
Provider: "gmail",
|
||||
}
|
||||
res, err := client.Send(ctx, req)
|
||||
if err != nil {
|
||||
log.Fatalf("RPC调用失败: %v", err)
|
||||
}
|
||||
|
||||
log.Printf("响应结果: %v", res.String())
|
||||
}
|
||||
|
||||
// 创建上下文和元数据
|
||||
func createContext() (context.Context, context.CancelFunc) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
|
||||
newMetaData := metadata.New(nil)
|
||||
newMetaData.Set("request_id", utils.UUID())
|
||||
outCtx := metadata.NewOutgoingContext(ctx, newMetaData)
|
||||
|
||||
return outCtx, cancel
|
||||
}
|
||||
44
module/base/sender/test/grpc/sms_test.go
Normal file
44
module/base/sender/test/grpc/sms_test.go
Normal file
@@ -0,0 +1,44 @@
|
||||
//go:build integration
|
||||
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
pb "bsm/full/module/base/sender/pb"
|
||||
"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())
|
||||
}
|
||||
12
module/base/sender/test/http/mail_send.http
Normal file
12
module/base/sender/test/http/mail_send.http
Normal file
@@ -0,0 +1,12 @@
|
||||
POST http://api.apinb.com/sender.Mail/Send
|
||||
content-type: application/json
|
||||
|
||||
{
|
||||
"provider": "qq",
|
||||
"template_key": "verify_code",
|
||||
"to": "2481286@qq.com",
|
||||
"is_gen_code": true,
|
||||
"paramters": {
|
||||
"product": "深圳市泰达维科技"
|
||||
}
|
||||
}
|
||||
13
module/base/sender/test/http/sms_send.http
Normal file
13
module/base/sender/test/http/sms_send.http
Normal file
@@ -0,0 +1,13 @@
|
||||
POST http://api.apinb.com/sender.Sms/Send
|
||||
content-type: application/json
|
||||
|
||||
{
|
||||
"provider": "aliyun",
|
||||
"sign_name": "深圳市泰达维科技",
|
||||
"template_code": "SMS_69155561",
|
||||
"phone": "18610192292",
|
||||
"is_gen_code": true,
|
||||
"paramters": {
|
||||
"product": "深圳市泰达维科技"
|
||||
}
|
||||
}
|
||||
7
module/base/sender/test/http/sms_verify.http
Normal file
7
module/base/sender/test/http/sms_verify.http
Normal file
@@ -0,0 +1,7 @@
|
||||
POST http://api.apinb.com/sender.Sms/Verify
|
||||
content-type: application/json
|
||||
|
||||
{
|
||||
"phone": "18610192292",
|
||||
"code": "123456"
|
||||
}
|
||||
Reference in New Issue
Block a user