package service import ( "crypto/sha1" "encoding/hex" "fmt" "testing" "xiaoniaokuaiyan.com/xiaoniao/entity" "xiaoniaokuaiyan.com/xiaoniao/util" ) func TestLogin(t *testing.T) { m := "18310592480" if !util.IsMobile(m) { t.Fatal("") } return var ( mobile string = "18310412108" password string = "7c4a8d09ca3762af61e59520943dc26494f8941b" ) user, err := userService.Login(map[string]string{ "mobile": mobile, "password": password, }) if err != nil { t.Fatal(err) } t.Log(user) } func TestUpdateUinfo(t *testing.T) { data, err := userService.UpdateUserinfo(&entity.User{ Id: 336, Avatar: "ssdf", }) if err != nil { t.Fatal(err) } fmt.Println(data) } func TestRegist(t *testing.T) { var ( mobile string = "18310412108" password string = "7c4a8d09ca3762af61e59520943dc26494f8941b" vcode string = "123456" ) user, err := userService.Regist(mobile, password, vcode) if err != nil { t.Fatal(err) } t.Log(user) } func TestShaPassword(t *testing.T) { var expectSize = 40 dst := sha1.Sum([]byte("123456")) dstStr := hex.EncodeToString(dst[0:]) fmt.Println(dstStr) if expectSize != len(dstStr) { t.Fatalf("unexpteced size") } } func TestEncryptPassword(t *testing.T) { dst := sha1.Sum([]byte("123456")) dstStr := hex.EncodeToString(dst[0:]) dstStr = encryptPassword(PASSWORD_KEY + dstStr + "807654") /*if dstStr != "C0B90EC7439DA4CE30D555F30DE04CB517D81234" { t.Fatal("w") }*/ fmt.Println(dstStr) } /*func TestGetLoginSession(t *testing.T) { var token = "3sCIzC5fSEm9k-42pHbTE" session, err := userService.GetLoginSession(token) if err != nil { t.Fatal(err) } fmt.Println(session) }*/