fix: 退出后不保留登录状态,调试输出改为总开关
This commit is contained in:
@@ -269,21 +269,46 @@ func TestDropAccountSession(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
shop, err := url.Parse("https://shop.10086.cn/i/")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c.jar.SetCookies(u, []*http.Cookie{
|
||||
{Name: "cmccssotoken", Value: "tok", Domain: "10086.cn", Path: "/"},
|
||||
{Name: "cmccssotoken", Value: "old", Domain: "10086.cn", Path: "/"},
|
||||
{Name: "is_login", Value: "true", Domain: "10086.cn", Path: "/"},
|
||||
{Name: "CaptchaCode", Value: "ab", Path: "/"},
|
||||
})
|
||||
c.dropAccountSession()
|
||||
var left []string
|
||||
c.jar.SetCookies(u, []*http.Cookie{
|
||||
{Name: "cmccssotoken", Value: "new", Domain: "10086.cn", Path: "/"},
|
||||
{Name: "ssologinprovince", Value: "200", Domain: "10086.cn", Path: "/"},
|
||||
})
|
||||
var names []string
|
||||
for _, ck := range c.jar.Cookies(shop) {
|
||||
names = append(names, ck.Name+"="+ck.Value)
|
||||
}
|
||||
joined := strings.Join(names, ",")
|
||||
if !strings.Contains(joined, "cmccssotoken=new") || !strings.Contains(joined, "ssologinprovince=200") {
|
||||
t.Fatalf("shop cookies %s", joined)
|
||||
}
|
||||
var loginNames []string
|
||||
for _, ck := range c.jar.Cookies(u) {
|
||||
left = append(left, ck.Name)
|
||||
loginNames = append(loginNames, ck.Name)
|
||||
}
|
||||
if len(left) != 1 || left[0] != "CaptchaCode" {
|
||||
t.Fatalf("cookies %v", left)
|
||||
if !containsName(loginNames, "CaptchaCode") {
|
||||
t.Fatalf("captcha cookie missing %v", loginNames)
|
||||
}
|
||||
}
|
||||
|
||||
func containsName(list []string, name string) bool {
|
||||
for _, item := range list {
|
||||
if item == name || strings.HasPrefix(item, name+"=") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func TestSubmitChannel(t *testing.T) {
|
||||
src := `$.ajax({url:'https://login.10086.cn/submitqr.htm',data:{'UID':uid,'lgToken':q,'channelID':'12008'}})`
|
||||
if submitChannel(src) != "12008" {
|
||||
|
||||
Reference in New Issue
Block a user