passport_util_test.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package service
  2. import (
  3. "fmt"
  4. "testing"
  5. "go-common/app/job/main/passport-encrypt/model"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestService_EncryptAccount(t *testing.T) {
  9. Convey("Encrypt a right account", t, func() {
  10. account := &model.OriginAccount{
  11. Mid: 12047569,
  12. UserID: "bili_1710676855",
  13. Uname: "Bili_12047569",
  14. Pwd: "3686c9d96ae6896fe117319ba6c07087",
  15. Salt: "pdMXF856",
  16. Email: "",
  17. Tel: "13122110209",
  18. CountryID: 1,
  19. MobileVerified: 1,
  20. Isleak: 0,
  21. }
  22. enAcc := EncryptAccount(account)
  23. fmt.Printf("right (+%v)", enAcc)
  24. })
  25. Convey("Encrypt a empty tel account", t, func() {
  26. account := &model.OriginAccount{
  27. Mid: 12047569,
  28. UserID: "bili_1710676855",
  29. Uname: "Bili_12047569",
  30. Pwd: "3686c9d96ae6896fe117319ba6c07087",
  31. Salt: "pdMXF856",
  32. Email: "",
  33. Tel: "",
  34. CountryID: 1,
  35. MobileVerified: 1,
  36. Isleak: 0,
  37. }
  38. enAcc := EncryptAccount(account)
  39. fmt.Printf("empty tel (+%v)", enAcc)
  40. })
  41. }
  42. func TestService_DecryptAccount(t *testing.T) {
  43. Convey("Decrypt right account", t, func() {
  44. account := &model.EncryptAccount{
  45. Mid: 12047569,
  46. UserID: "bili_1710676855",
  47. Uname: "Bili_12047569",
  48. Pwd: "3686c9d96ae6896fe117319ba6c07087",
  49. Salt: "pdMXF856",
  50. Email: "",
  51. Tel: []byte{216, 28, 241, 48, 17, 243, 198, 234, 205, 33, 216, 25, 75, 146, 97, 203},
  52. CountryID: 1,
  53. MobileVerified: 1,
  54. Isleak: 0,
  55. }
  56. enAcc := DecryptAccount(account)
  57. fmt.Printf("(+%v)", enAcc)
  58. })
  59. Convey("Decrypt empty tel account", t, func() {
  60. account := &model.EncryptAccount{
  61. Mid: 12047569,
  62. UserID: "bili_1710676855",
  63. Uname: "Bili_12047569",
  64. Pwd: "3686c9d96ae6896fe117319ba6c07087",
  65. Salt: "pdMXF856",
  66. Email: "",
  67. Tel: []byte{73, 224, 88, 238, 85, 242, 37, 46, 200, 70, 5, 49, 73, 107, 179, 51},
  68. CountryID: 1,
  69. MobileVerified: 1,
  70. Isleak: 0,
  71. }
  72. enAcc := DecryptAccount(account)
  73. fmt.Printf("(+%v)", enAcc)
  74. })
  75. }