插件-TestNotify

This commit is contained in:
李子铭 2024-08-23 13:41:00 +08:00
parent 3c164f1713
commit d3bbcc6e72
3 changed files with 8 additions and 7 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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))
})
}