weibo_test.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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_WeiboAuthorize(t *testing.T) {
  10. var (
  11. c = context.Background()
  12. AppID = "101135748"
  13. RedirectUrl = "https://passport.bilibili.com/login/snsback?sns=weibo"
  14. Display = "mobile"
  15. // AppID : "1108092926",
  16. // RedirectUrl : "https://passport.bilibili.com/web/sns/bind/callback/weibo",
  17. )
  18. convey.Convey("WeiboAuthorize", t, func(ctx convey.C) {
  19. res := d.WeiboAuthorize(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_WeiboOauth2Info(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("WeiboOauth2Info", t, func(ctx convey.C) {
  38. res, err := d.WeiboOauth2Info(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_weiboAccessToken(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("weiboAccessToken", t, func(ctx convey.C) {
  55. res, err := d.weiboAccessToken(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. }