123456789101112131415161718192021222324252627282930313233343536373839 |
- package captcha
- import (
- "app.yhyue.com/moapp/jybase/go-xweb/httpsession"
- "app.yhyue.com/moapp/jybase/redis"
- "fmt"
- "net/http"
- "testing"
- "time"
- )
- func TestCaptcha(t *testing.T) {
- redis.InitRedisBySize("other=172.20.45.129:1712", 100, 30, 300)
- InitCaptcha()
- var (
- W http.ResponseWriter
- R *http.Request
- )
- cs := GetCaptcha{
- W: W,
- R: R,
- Sess: &httpsession.Session{},
- Phone: "15737190152",
- }
- cs.Sess.SetId("001")
- b, err := cs.GetCaptchaData()
- fmt.Println(b, err)
- cd := CheckCaptcha{
- W: W,
- R: R,
- Sess: cs.Sess,
- Phone: cs.Phone,
- Point: fmt.Sprintf("%d,%d", b.TileX, b.TileY),
- Key: b.CaptchaKey.(string),
- }
- err = cd.CheckCaptchaData()
- fmt.Println("err:", err)
- time.Sleep(10 * time.Second)
- }
|