插件-TestNotify
This commit is contained in:
parent
3c164f1713
commit
d3bbcc6e72
|
@ -41,8 +41,8 @@ func req(req po.Req, appKey string) (url.Values, error) {
|
|||
return urlValues(req, appKey), nil
|
||||
}
|
||||
|
||||
func verify(notify po.Notify, appKey string) bool {
|
||||
kvRows := utils.SortStruct(req)
|
||||
func verify(notify *po.Notify, appKey string) bool {
|
||||
kvRows := utils.SortStruct(notify)
|
||||
var kvStr []string
|
||||
|
||||
for _, kv := range kvRows {
|
||||
|
|
|
@ -87,8 +87,8 @@ func (p *ZLTXService) Notify(_ context.Context, request *proto.NotifyRequest) (*
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !verify(poReq, c.AppKey) {
|
||||
return nil, errors.New("验签不通过")
|
||||
if !verify(&poReq, c.AppKey) {
|
||||
return nil, fmt.Errorf("验签不通过")
|
||||
}
|
||||
|
||||
return notifyResp(poReq), nil
|
||||
|
|
|
@ -84,10 +84,11 @@ func TestNotify(t *testing.T) {
|
|||
}
|
||||
t.Run("TestNotify", func(t *testing.T) {
|
||||
got, err := zltx.Notify(context.Background(), in)
|
||||
if assert.Nil(t, err) {
|
||||
assert.Equal(t, true, got.Result)
|
||||
if !assert.Nil(t, err) {
|
||||
t.Errorf("Notify() error = %v", err)
|
||||
return
|
||||
}
|
||||
fmt.Printf("%+v \n", got)
|
||||
fmt.Printf("%s \n", got.String())
|
||||
assert.Equal(t, int(proto.Status_SUCCESS), int(got.Result.Status))
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue