feat: 提交移动个人中心只读面板
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
package cmnet
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAESKeyParse(t *testing.T) {
|
||||
src := `b=["043A","lyZA","OQGK","043A","6ykk","OQGK","lyZA","6ykk"]`
|
||||
if string(aesKeyFromJS(src)) != fallbackAES {
|
||||
t.Fatalf("key %s", aesKeyFromJS(src))
|
||||
}
|
||||
}
|
||||
|
||||
func TestPhoneTokenMatchesCapture(t *testing.T) {
|
||||
token, err := phoneToken([]byte(fallbackAES), "13800000000")
|
||||
if err != nil || token == "" {
|
||||
t.Fatal(err)
|
||||
}
|
||||
back, err := decryptOutParam([]byte(fallbackAES), token)
|
||||
if err != nil || string(back) != "13800000000" {
|
||||
t.Fatalf("roundtrip %q %v", back, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecryptCapturedPlan(t *testing.T) {
|
||||
z, err := zip.OpenReader("../../cmnet.chlz")
|
||||
if err != nil {
|
||||
t.Skip(err)
|
||||
}
|
||||
defer z.Close()
|
||||
var op string
|
||||
for _, f := range z.File {
|
||||
if f.Name != "156-res.json" {
|
||||
continue
|
||||
}
|
||||
r, err := f.Open()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var wrap struct {
|
||||
Data struct {
|
||||
OutParam string `json:"outParam"`
|
||||
} `json:"data"`
|
||||
}
|
||||
if err := json.NewDecoder(r).Decode(&wrap); err != nil {
|
||||
r.Close()
|
||||
t.Fatal(err)
|
||||
}
|
||||
r.Close()
|
||||
op = wrap.Data.OutParam
|
||||
}
|
||||
if op == "" {
|
||||
t.Fatal("missing plan response")
|
||||
}
|
||||
plain, err := decryptOutParam([]byte(fallbackAES), op)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
snap := BuildSnapshot("13800000000", "广东", nil, plain)
|
||||
if len(snap.Resources) == 0 {
|
||||
t.Fatal("no resources")
|
||||
}
|
||||
if snap.VoiceTotal != "100" || snap.VoiceRemain != "78" {
|
||||
t.Fatalf("voice total %s remain %s", snap.VoiceTotal, snap.VoiceRemain)
|
||||
}
|
||||
if snap.DataTotal != "64.10" || snap.DataUsed != "31.39" || snap.DataRemain != "32.70" {
|
||||
t.Fatalf("data total %s used %s remain %s", snap.DataTotal, snap.DataUsed, snap.DataRemain)
|
||||
}
|
||||
for _, item := range snap.Resources {
|
||||
if item.Unit == "分钟" && item.Total == "1" {
|
||||
t.Fatalf("voice row total was truncated: %+v", item)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user