Files
baseapi/platformapi/jdshopapi/store_page_test.go
苏尹岚 2dc628c221 鼎测试
2020-07-29 14:14:19 +08:00

162 lines
4.8 KiB
Go

package jdshopapi
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"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: 1,
OrderID: "118793082128",
})
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestOrderDetail(t *testing.T) {
result, err := api.OrderDetail("125138699851")
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) {
str := "AASWvkdk5a60bjm3lFqaoCyzJprhJZvabCAbNtGu14Lu/ZBGNYf/MdPCEIcIN9oVbEw="
data, _ := base64.StdEncoding.DecodeString(str)
data2, _ := base64.StdEncoding.DecodeString("XsGNdyDyDHnR79iKU6d5LTSJYaQyWAEssDoD7VM5Kks=")
b := bytes.NewBuffer(data)
b.Next(18)
iv := make([]byte, 16)
b.Read(iv)
main := make([]byte, len(data)-18-16)
b.Read(main)
decryptedData, err := Decrypt(main, data2[:16], iv)
if err != nil {
t.Fatal(err)
}
fmt.Println("data", string(decryptedData))
}
func Decrypt(decryptBytes, key, iv []byte) ([]byte, error) {
block, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
blockMode := cipher.NewCBCDecrypter(block, iv)
blockMode.CryptBlocks(decryptBytes, decryptBytes)
return PKCS5UnPadding(decryptBytes), nil
}
func PKCS5UnPadding(decrypted []byte) []byte {
length := len(decrypted)
unPadding := int(decrypted[length-1])
return decrypted[:(length - unPadding)]
}
func TestAUS(t *testing.T) {
str = `
{
"consigneeInfo": "map[city:丰台区 cityId:2805 county:三环到四环之间 countyId:2855 fullAddress:AASWvkdk5a60bjm3lFqaoCyzGU2pgGw0Mc968Xbceeuuur8Il0tvS5LpWP0iiwxMlnsjuCvooqgcrwXLf/EqIpgmHOyV2n1UApCLdSaPAyt20D4mGqmqIHIQwUSVZm/RxWM= fullname:AASWvkdk5a60bjm3lFqaoCyzDcRkyHzNfI X/q1aFI1yPZP1k3suF6YXD8H KWhuKGo= mobile:AASWvkdk5a60bjm3lFqaoCyzyWkFBtaTbjNTqZc6TzQhYdfQcEOaeHur1JNVg0rPSLA= province:北京 provinceId:1 telephone:AASWvkdk5a60bjm3lFqaoCyz2oKxkxWmBWybvDIbcX4qcGf2tQG7Q0nBIwAkrgVza/c= town: townId:0]",
"freightPrice": "0.00",
"itemInfoList": "[map[giftPoint:0 invoiceContentId: itemExt:{\"skuUuid\":\"30_0_10374877_71027198959_2_0\",\"isVMI\":0,\"newStoreId\":\"0\"} itemTotal:1 jdPrice:40.00 newStoreId:0 outerSkuId:6045739 productNo: skuId:71027198959 skuName:小台农芒果新鲜当季水果 5斤 wareId:14650176651]]",
"orderExt": "{\"road\":\"2\",\"aerfaTime.idSopShipmentType\":\"67\"}",
"orderId": "129337563399",
"orderPayment": "8.40",
"orderRemark": "",
"orderSellerPrice": "8.40",
"orderSource": "移动端订单",
"orderStartTime": "2020-07-29 12:08:39",
"orderState": "WAIT_GOODS_RECEIVE_CONFIRM",
"orderStateRemark": "等待确认收货",
"orderTotalPrice": "40.00",
"orderType": "22",
"payType": "4-在线支付",
"storeId": "0",
"storeOrder": ""
}
`
}