fix: 发短信前按页面完成预检查和回调计数

This commit is contained in:
Nixevol
2026-10-16 18:16:25 +08:00
parent ef33ed166c
commit d17d8c9778
3 changed files with 202 additions and 25 deletions
+27 -5
View File
@@ -2,6 +2,7 @@ package unicom
import (
"net/url"
"strconv"
"strings"
"testing"
)
@@ -13,10 +14,25 @@ func TestPhoneFromPIW(t *testing.T) {
}
}
func TestJSONPCallbackName(t *testing.T) {
name := jsonpCallback()
if !strings.HasPrefix(name, "jQuery") || !strings.Contains(name, "_") {
t.Fatal(name)
func TestCallbackReusedLikePage(t *testing.T) {
c := &Client{spec: loginScript{jqueryVer: "3.5.1"}}
first, under1 := c.takeCallback()
c.recycleCallback(first)
second, under2 := c.takeCallback()
if first != second {
t.Fatalf("callback %s %s", first, second)
}
if !strings.HasPrefix(first, "jQuery351") {
t.Fatal(first)
}
suffix, err := strconv.ParseInt(strings.Split(first, "_")[1], 10, 64)
if err != nil {
t.Fatal(err)
}
u1, _ := strconv.ParseInt(under1, 10, 64)
u2, _ := strconv.ParseInt(under2, 10, 64)
if u1 != suffix+1 || u2 != u1+1 {
t.Fatalf("counter %d %d %d", suffix, u1, u2)
}
}
@@ -41,11 +57,12 @@ func TestParseJSONP(t *testing.T) {
func TestLoginQueryKeepsTicketStar(t *testing.T) {
raw := (&Client{}).loginURL("/portal/Service/SendMSG", url.Values{
"callback": {"jQuery35106785579090009984_1792133693942"},
"req_time": {"1792133860486"},
"mobile": {"10000000000"},
"uvc": {"ab*cd"},
"verifyCode": {"@abc"},
})
}, "1792133693944")
if !strings.Contains(raw, "uvc=ab*cd") || !strings.Contains(raw, "verifyCode=%40abc") {
t.Fatal(raw)
}
@@ -71,6 +88,8 @@ func TestParseLoginBundle(t *testing.T) {
setCookie("piw", data.piw);
CommonConstants.PWD_TYPE_RND = "02";
CommonConstants.USER_TYPE_MOBILE = "01";
jquery:"3.5.1"
CommonConstants.CHECK_SHOW_VERIFY_URL = UacPrefix.PRXFIX + "/portal/Service/CheckNeedVerify?callback=?";
`
got, err := parseLoginBundle(js)
if err != nil {
@@ -88,6 +107,9 @@ func TestParseLoginBundle(t *testing.T) {
if got.secCookie != "unisecid" || got.piwCookie != "piw" || got.pwdType != "02" || got.userType != "01" {
t.Fatalf("names %#v", got)
}
if got.jqueryVer != "3.5.1" || got.needPath != "/portal/Service/CheckNeedVerify" {
t.Fatalf("jquery %#v", got)
}
html := `<input type="hidden" id="loginFrom" name="loginFrom" value='01' />
<script src="https://turing.captcha.qcloud.com/TJCaptcha.js"></script>`
if parseLoginFrom(html) != "01" {