qq_test.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. "go-common/app/service/main/passport-sns/model"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDao_QQAuthorize(t *testing.T) {
  10. var (
  11. c = context.Background()
  12. AppID = "101135748"
  13. RedirectUrl = "https://passport.bilibili.com/login/snsback?sns=qq"
  14. Display = "mobile"
  15. // AppID : "1108092926",
  16. // RedirectUrl : "https://passport.bilibili.com/web/sns/bind/callback/qq",
  17. )
  18. convey.Convey("QQAuthorize", t, func(ctx convey.C) {
  19. res := d.QQAuthorize(c, AppID, RedirectUrl, Display)
  20. ctx.Convey("Then res should not be nil.", func(ctx convey.C) {
  21. ctx.So(res, convey.ShouldNotBeNil)
  22. })
  23. fmt.Println(res)
  24. })
  25. }
  26. func TestDao_QQOauth2Info(t *testing.T) {
  27. var (
  28. c = context.Background()
  29. code = "C4946CD493AEEDE67C574DFE2C756D09"
  30. redirectUrl = "https://passport.bilibili.com/web/sns/bind/callback"
  31. app = &model.SnsApps{
  32. AppID: "",
  33. AppSecret: "",
  34. Business: model.BusinessMall,
  35. }
  36. )
  37. convey.Convey("QQSnsInfo", t, func(ctx convey.C) {
  38. res, err := d.QQOauth2Info(c, code, redirectUrl, app)
  39. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  40. ctx.So(err, convey.ShouldNotBeNil)
  41. ctx.So(res, convey.ShouldBeNil)
  42. })
  43. fmt.Printf("(%+v) error(%+v)", res, err)
  44. })
  45. }
  46. func TestDao_qqAccessToken(t *testing.T) {
  47. var (
  48. c = context.Background()
  49. code = "CF8CE1408E8E43E4CD2DC778B5993FBB"
  50. appID = ""
  51. appSecret = ""
  52. redirectUrl = "https://passport.bilibili.com/web/sns/bind/callback"
  53. )
  54. convey.Convey("qqAccessToken", t, func(ctx convey.C) {
  55. res, err := d.qqAccessToken(c, code, appID, appSecret, redirectUrl)
  56. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  57. ctx.So(err, convey.ShouldNotBeNil)
  58. ctx.So(res, convey.ShouldBeNil)
  59. })
  60. fmt.Printf("(%+v) error(%+v)", res, err)
  61. })
  62. }
  63. func TestDao_qqOpenID(t *testing.T) {
  64. var (
  65. c = context.Background()
  66. token = ""
  67. business = model.BusinessMall
  68. )
  69. convey.Convey("qqOpenID", t, func(ctx convey.C) {
  70. res, err := d.qqOpenID(c, token, business)
  71. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  72. ctx.So(err, convey.ShouldNotBeNil)
  73. ctx.So(res, convey.ShouldNotBeEmpty)
  74. })
  75. fmt.Printf("(%+v) error(%+v)", res, err)
  76. })
  77. }