- TestSimulateSendNewOrderMsg added.
This commit is contained in:
@@ -62,11 +62,7 @@ func (a *API) CheckCallbackValidation(values url.Values) (callbackResponse *Call
|
|||||||
sign := a.signParams(mapData)
|
sign := a.signParams(mapData)
|
||||||
if sign != values.Get(signKey) {
|
if sign != values.Get(signKey) {
|
||||||
baseapi.SugarLogger.Infof("Signature is not ok, mine:%v, get:%v", sign, values.Get(signKey))
|
baseapi.SugarLogger.Infof("Signature is not ok, mine:%v, get:%v", sign, values.Get(signKey))
|
||||||
return &CallbackResponse{
|
return FormatErrorResponse
|
||||||
Code: ResponseCodeInvalidSign,
|
|
||||||
Msg: platformapi.ErrStrCallbackSignatureIsWrong,
|
|
||||||
Data: string(utils.MustMarshal(mapData)),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package jdapi
|
package jdapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi"
|
"git.rosy.net.cn/baseapi"
|
||||||
@@ -147,3 +149,29 @@ func TestGetOrderApplyCancelCallbackMsg(t *testing.T) {
|
|||||||
}
|
}
|
||||||
sugarLogger.Debug(result)
|
sugarLogger.Debug(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSimulateSendNewOrderMsg(t *testing.T) {
|
||||||
|
orderInfo := &CallbackOrderMsg{
|
||||||
|
BillID: "813452298000322",
|
||||||
|
StatusID: OrderStatusNew,
|
||||||
|
Timestamp: utils.GetCurTimeStr(),
|
||||||
|
}
|
||||||
|
params := make(url.Values)
|
||||||
|
params.Set("token", jdapi.token)
|
||||||
|
params.Set("app_key", jdapi.appKey)
|
||||||
|
params.Set("timestamp", utils.GetCurTimeStr())
|
||||||
|
params.Set("v", "1.0")
|
||||||
|
params.Set("format", "json")
|
||||||
|
params.Set(paramJson, string(utils.MustMarshal(orderInfo)))
|
||||||
|
|
||||||
|
mapData := utils.URLValues2Map(params)
|
||||||
|
mapData["app_secret"] = jdapi.appSecret
|
||||||
|
params.Set(signKey, jdapi.signParams(mapData))
|
||||||
|
|
||||||
|
response, err := http.PostForm("http://callback.test.jxc4.com/djsw/newOrder", params)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
bodyData, _ := ioutil.ReadAll(response.Body)
|
||||||
|
sugarLogger.Debug(string(bodyData))
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user