plugin/dctw/v1/core/core_test.go

32 lines
601 B
Go
Raw Normal View History

2024-11-14 18:33:56 +08:00
package core
import (
"testing"
)
func TestZc_DctWServer(t *testing.T) {
2024-11-15 11:00:16 +08:00
server, err := NewDctWServer(
&DctWConfig{
AppId: "101",
AppKey: "5k8bJV6axIukpkwz5vdte8QCw5etlC+txi+Nu69nIhOMN4VhmcNgf/THdllpt0jO",
BaseUri: "http://openapi.1688sup.cn",
},
WithDebug(true),
)
2024-11-14 18:33:56 +08:00
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("验签成功")
}