plugin/dctw/v1/core/core_test.go

32 lines
601 B
Go

package core
import (
"testing"
)
func TestZc_DctWServer(t *testing.T) {
server, err := NewDctWServer(
&DctWConfig{
AppId: "101",
AppKey: "5k8bJV6axIukpkwz5vdte8QCw5etlC+txi+Nu69nIhOMN4VhmcNgf/THdllpt0jO",
BaseUri: "http://openapi.1688sup.cn",
},
WithDebug(true),
)
if err != nil {
t.Fatal(err)
}
timestamp := "1731566046566"
body := "xx=1"
path := "/xx/xx"
str := server.Sign(body, path, timestamp)
authorization := server.BuildAuth(str, timestamp)
if err = server.verify(authorization, path, []byte(body)); err != nil {
t.Fatal(err)
}
t.Log("验签成功")
}