插件-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
|
return urlValues(req, appKey), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func verify(notify po.Notify, appKey string) bool {
|
func verify(notify *po.Notify, appKey string) bool {
|
||||||
kvRows := utils.SortStruct(req)
|
kvRows := utils.SortStruct(notify)
|
||||||
var kvStr []string
|
var kvStr []string
|
||||||
|
|
||||||
for _, kv := range kvRows {
|
for _, kv := range kvRows {
|
||||||
|
|
|
@ -87,8 +87,8 @@ func (p *ZLTXService) Notify(_ context.Context, request *proto.NotifyRequest) (*
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !verify(poReq, c.AppKey) {
|
if !verify(&poReq, c.AppKey) {
|
||||||
return nil, errors.New("验签不通过")
|
return nil, fmt.Errorf("验签不通过")
|
||||||
}
|
}
|
||||||
|
|
||||||
return notifyResp(poReq), nil
|
return notifyResp(poReq), nil
|
||||||
|
|
|
@ -84,10 +84,11 @@ func TestNotify(t *testing.T) {
|
||||||
}
|
}
|
||||||
t.Run("TestNotify", func(t *testing.T) {
|
t.Run("TestNotify", func(t *testing.T) {
|
||||||
got, err := zltx.Notify(context.Background(), in)
|
got, err := zltx.Notify(context.Background(), in)
|
||||||
if assert.Nil(t, err) {
|
if !assert.Nil(t, err) {
|
||||||
assert.Equal(t, true, got.Result)
|
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))
|
assert.Equal(t, int(proto.Status_SUCCESS), int(got.Result.Status))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue