1
|
package domain
|
1
|
package domain
|
2
|
|
2
|
|
3
|
-import "testing"
|
3
|
+import (
|
|
|
4
|
+ "testing"
|
|
|
5
|
+
|
|
|
6
|
+ "github.com/dgrijalva/jwt-go"
|
|
|
7
|
+)
|
4
|
|
8
|
|
5
|
func TestGenerateToken(t *testing.T) {
|
9
|
func TestGenerateToken(t *testing.T) {
|
6
|
ut := UserAuth{
|
10
|
ut := UserAuth{
|
|
@@ -24,5 +28,9 @@ func TestParsetToken2(t *testing.T) { |
|
@@ -24,5 +28,9 @@ func TestParsetToken2(t *testing.T) { |
24
|
ut := UserAuth{}
|
28
|
ut := UserAuth{}
|
25
|
str := `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjM0MjYxMDAxMTcwOTM4ODgsImNvbXBhbnlJZCI6MSwiY29tcGFueU5hbWUiOiLnpo_lt57ntKDlpKnkuIvpo5_lk4HmnInpmZDlhazlj7giLCJwaG9uZSI6IjE1NjU5Mzc1OTQwIiwicGxhdGZvcm1JZCI6MjksIm5hbWUiOiLlurfkvJ_ljY4iLCJhZG1pblR5cGUiOjF9.BwJ2mLdTlFKF322y4GeqPOW6wKroIrPSI8eNyuQEMkQ`
|
29
|
str := `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjM0MjYxMDAxMTcwOTM4ODgsImNvbXBhbnlJZCI6MSwiY29tcGFueU5hbWUiOiLnpo_lt57ntKDlpKnkuIvpo5_lk4HmnInpmZDlhazlj7giLCJwaG9uZSI6IjE1NjU5Mzc1OTQwIiwicGxhdGZvcm1JZCI6MjksIm5hbWUiOiLlurfkvJ_ljY4iLCJhZG1pblR5cGUiOjF9.BwJ2mLdTlFKF322y4GeqPOW6wKroIrPSI8eNyuQEMkQ`
|
26
|
tk, _ := ut.ParseAccessToken(str)
|
30
|
tk, _ := ut.ParseAccessToken(str)
|
27
|
- t.Logf("%+v", tk)
|
31
|
+ t.Logf("===》%+v", tk)
|
|
|
32
|
+ tk.StandardClaims = jwt.StandardClaims{}
|
|
|
33
|
+ tk.PlatformId = 29
|
|
|
34
|
+ tkStr, _ := tk.CreateAccessToken()
|
|
|
35
|
+ t.Logf(" ===》%v", tkStr)
|
28
|
} |
36
|
} |