check_test.go 748 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package captcha
  2. import (
  3. "app.yhyue.com/moapp/jybase/go-xweb/httpsession"
  4. "app.yhyue.com/moapp/jybase/redis"
  5. "fmt"
  6. "net/http"
  7. "testing"
  8. "time"
  9. )
  10. func TestCaptcha(t *testing.T) {
  11. redis.InitRedisBySize("other=172.20.45.129:1712", 100, 30, 300)
  12. InitCaptcha()
  13. var (
  14. W http.ResponseWriter
  15. R *http.Request
  16. )
  17. cs := GetCaptcha{
  18. W: W,
  19. R: R,
  20. Sess: &httpsession.Session{},
  21. Phone: "15737190152",
  22. }
  23. cs.Sess.SetId("001")
  24. b, err := cs.GetCaptchaData()
  25. fmt.Println(b, err)
  26. cd := CheckCaptcha{
  27. W: W,
  28. R: R,
  29. Sess: cs.Sess,
  30. Phone: cs.Phone,
  31. Point: fmt.Sprintf("%d,%d", b.TileX, b.TileY),
  32. Key: b.CaptchaKey.(string),
  33. }
  34. err = cd.CheckCaptchaData()
  35. fmt.Println("err:", err)
  36. time.Sleep(10 * time.Second)
  37. }