TestZc_DctWServer
This commit is contained in:
parent
0823da7786
commit
990030fff3
|
@ -117,8 +117,7 @@ func (c *DctWServer) verify(authorization, path string, body []byte) error {
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("时间戳获取失败")
|
return fmt.Errorf("时间戳获取失败")
|
||||||
}
|
}
|
||||||
calculatedSign := c.Sign(string(body), path, timestamp)
|
if sign == c.Sign(string(body), path, timestamp) {
|
||||||
if sign == calculatedSign {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,8 +143,7 @@ func (c *DctWServer) VerifyDctW(authorization string, body []byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
signStr := fmt.Sprintf("%s%s%s", c.Config.AppId, string(body), c.Config.AppKey)
|
signStr := fmt.Sprintf("%s%s%s", c.Config.AppId, string(body), c.Config.AppKey)
|
||||||
calculatedSign := utils.Md5([]byte(signStr))
|
if sign == utils.Md5([]byte(signStr)) {
|
||||||
if sign == calculatedSign {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestZc_DctWServer(t *testing.T) {
|
func TestZc_DctWServer(t *testing.T) {
|
||||||
server, err := NewDctWServer(&DctWConfig{
|
server, err := NewDctWServer(
|
||||||
AppId: "101",
|
&DctWConfig{
|
||||||
AppKey: "5k8bJV6axIukpkwz5vdte8QCw5etlC+txi+Nu69nIhOMN4VhmcNgf/THdllpt0jO",
|
AppId: "101",
|
||||||
BaseUri: "http://openapi.1688sup.cn",
|
AppKey: "5k8bJV6axIukpkwz5vdte8QCw5etlC+txi+Nu69nIhOMN4VhmcNgf/THdllpt0jO",
|
||||||
})
|
BaseUri: "http://openapi.1688sup.cn",
|
||||||
|
},
|
||||||
|
WithDebug(true),
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue