53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
package robot
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/modules/user"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/utils"
|
|
"log"
|
|
"time"
|
|
|
|
jsoniter "github.com/json-iterator/go"
|
|
"github.com/nacos-group/nacos-sdk-go/util"
|
|
)
|
|
|
|
type LoginParam struct {
|
|
Account string `json:"account"`
|
|
ServerId int32 `json:"serverId"`
|
|
TimeStamp int64 `json:"timestamp"`
|
|
}
|
|
|
|
func (r *Robot) BuildSecStr() string {
|
|
jsonByte, _ := jsoniter.Marshal(&LoginParam{
|
|
Account: r.opts.Account,
|
|
ServerId: r.opts.ServerId,
|
|
TimeStamp: time.Now().Unix(),
|
|
})
|
|
jsonBase64 := utils.Base64Encode(jsonByte)
|
|
// log.Printf("client base64:%s", jsonBase64)
|
|
clientMd5key := util.Md5(jsonBase64)
|
|
// log.Printf("client md5:%s", clientMd5key)
|
|
return fmt.Sprintf("CE:%s%s", clientMd5key, jsonBase64)
|
|
}
|
|
|
|
//处理登录请求
|
|
func (r *Robot) AccountLogin() {
|
|
log.Printf("区服:[%d] 账号:[%s] login...", r.opts.ServerId, r.opts.Account)
|
|
builders := []*TestCase{
|
|
{
|
|
mainType: string(comm.ModuleUser),
|
|
subType: user.UserSubTypeLogin,
|
|
req: &pb.UserLoginReq{
|
|
Account: r.opts.Account,
|
|
Sid: r.opts.ServerId,
|
|
},
|
|
rsp: &pb.UserLoginResp{},
|
|
enabled: true,
|
|
},
|
|
}
|
|
r.addBuilders(builders)
|
|
r.batchHandleReq()
|
|
}
|