138 lines
3.2 KiB
Go
138 lines
3.2 KiB
Go
package jdshopapi
|
|
|
|
import (
|
|
"crypto/aes"
|
|
"encoding/base64"
|
|
"fmt"
|
|
"io/ioutil"
|
|
"net/http"
|
|
"testing"
|
|
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
)
|
|
|
|
func TestCreateShopCategory(t *testing.T) {
|
|
var CreateShopCategoryParams = []*CreateShopCategoryParam{
|
|
&CreateShopCategoryParam{
|
|
HomeShow: "0",
|
|
ID: "0",
|
|
Open: "",
|
|
OrderNo: "0",
|
|
ParentID: "",
|
|
Title: "测试1",
|
|
Type: "3",
|
|
},
|
|
}
|
|
result, _ := api.CreateShopCategory(CreateShopCategoryParams)
|
|
fmt.Println(result)
|
|
}
|
|
|
|
func TestUpdateStoreStatus(t *testing.T) {
|
|
err := api.UpdateStoreStatus(24332466, 1)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func TestNewInfoList(t *testing.T) {
|
|
result, err := api.NewInfoList(1)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(utils.Format4Output(result, false))
|
|
}
|
|
|
|
func Test11(t *testing.T) {
|
|
request, _ := http.NewRequest(http.MethodGet, "https://stores.shop.jd.com/stores/updateStoreStatus?storeId=24339301&storeStatus=1", nil)
|
|
c := &http.Cookie{
|
|
Name: "thor",
|
|
Value: "80FAF09E9A09B6E618A68057BDFCFCB88A0E4CE7743FBEC84F10D992F9C6A4119DF98DA3CAAE9C7F17BEB62884625B4E7BC82422A90F45F02EA293572D951B055EF0B5F603AEA568DFD4234138F841EC1AC1F67B30B48AAC9EAD5FBAE7943E1DCC99E99D8358C82F7832B71A2BCB31624E16BBF561720443DE966BDA3588406233A90224D9089710B102AA98B979B9B3",
|
|
}
|
|
request.AddCookie(c)
|
|
client := &http.Client{}
|
|
fmt.Println("test1", request.URL)
|
|
response, _ := client.Do(request)
|
|
defer response.Body.Close()
|
|
bodyData, _ := ioutil.ReadAll(response.Body)
|
|
fmt.Println("test1", string(bodyData))
|
|
}
|
|
|
|
func TestAllOrders(t *testing.T) {
|
|
result, err := api.AllOrders(&AllOrdersParam{
|
|
Current: 1,
|
|
PageSize: 999,
|
|
OrderCreateDateRange: []string{"2020-06-17 00:00:00", "2020-06-17 23:59:59"},
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(utils.Format4Output(result, false))
|
|
}
|
|
|
|
func TestOrderDetail(t *testing.T) {
|
|
result, err := api.OrderDetail("124350112427")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(utils.Format4Output(result, false))
|
|
}
|
|
|
|
func TestPhoneSensltiveInfo(t *testing.T) {
|
|
result, err := api.PhoneSensltiveInfo("124396047880", "10b1707dc87755373d488a7a4f422f7d")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(utils.Format4Output(result, false))
|
|
}
|
|
|
|
func TestUpdateWaybill(t *testing.T) {
|
|
err := api.UpdateWaybill("123076499052", "1274", "88328977356545 ")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
// t.Log(utils.Format4Output(result, false))
|
|
}
|
|
|
|
func TestTryGetCookie(t *testing.T) {
|
|
result, err := api.TryGetCookie()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(utils.Format4Output(result, false))
|
|
}
|
|
|
|
func TestAAADS(t *testing.T) {
|
|
//c5MSDWxbgDc698slnUlR1w==
|
|
fmt.Println(DecryptDESECB([]byte("Av3VLNsKfmmGw70Wiw7Qdw=="), []byte(JdsMobileKey)))
|
|
}
|
|
|
|
func DecryptDESECB(d, key []byte) string {
|
|
data, err := base64.StdEncoding.DecodeString(string(d))
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
block, err := aes.NewCipher(key)
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
bs := block.BlockSize()
|
|
if len(data)%bs != 0 {
|
|
return ""
|
|
}
|
|
out := make([]byte, len(data))
|
|
dst := out
|
|
for len(data) > 0 {
|
|
block.Decrypt(dst, data[:bs])
|
|
data = data[bs:]
|
|
dst = dst[bs:]
|
|
}
|
|
out = PKCS5UnPadding(out)
|
|
return string(out)
|
|
}
|
|
|
|
func PKCS5UnPadding(origData []byte) []byte {
|
|
length := len(origData)
|
|
unpadding := int(origData[length-1])
|
|
return origData[:(length - unpadding)]
|
|
}
|