feat: 移动增加扫码登录并支持换号短信登录
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package cmnet
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestRestorePhone(t *testing.T) {
|
||||
phone, err := restorePhone("138******00", "000000")
|
||||
if err != nil || phone != "13800000000" {
|
||||
t.Fatalf("phone %s %v", phone, err)
|
||||
}
|
||||
if _, err := restorePhone("138****0000", "0000"); err == nil {
|
||||
t.Fatal("short code should fail")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseQRPoll(t *testing.T) {
|
||||
waiting, artifact, err := parseQRPoll(nil)
|
||||
if err != nil || !waiting.Waiting || artifact != "" {
|
||||
t.Fatalf("empty %+v %s %v", waiting, artifact, err)
|
||||
}
|
||||
expired, artifact, err := parseQRPoll([]byte(`{"resultCode":"8020"}`))
|
||||
if err != nil || !expired.Expired {
|
||||
t.Fatalf("expired %+v %v", expired, err)
|
||||
}
|
||||
ok, artifact, err := parseQRPoll([]byte(`{"resultCode":"0000","artifact":"abc","resultDesc":"登录成功"}`))
|
||||
if err != nil || artifact != "abc" || ok.Waiting || ok.Expired {
|
||||
t.Fatalf("ok %+v %s %v", ok, artifact, err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user