|
@@ -7,6 +7,7 @@ import ( |
|
@@ -7,6 +7,7 @@ import ( |
7
|
)
|
7
|
)
|
8
|
|
8
|
|
9
|
func TestGenerateToken(t *testing.T) {
|
9
|
func TestGenerateToken(t *testing.T) {
|
|
|
10
|
+ JWTExpiresSecond = 2
|
10
|
ut := UserAuth{
|
11
|
ut := UserAuth{
|
11
|
CompanyId: 8,
|
12
|
CompanyId: 8,
|
12
|
UserId: 3422185340122624,
|
13
|
UserId: 3422185340122624,
|
|
@@ -20,8 +21,9 @@ func TestGenerateToken(t *testing.T) { |
|
@@ -20,8 +21,9 @@ func TestGenerateToken(t *testing.T) { |
20
|
|
21
|
|
21
|
func TestParsetToken1(t *testing.T) {
|
22
|
func TestParsetToken1(t *testing.T) {
|
22
|
ut := UserAuth{}
|
23
|
ut := UserAuth{}
|
23
|
- str := `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjM0MjE4NDc3MjcyOTYwMDAsImNvbXBhbnlJZCI6MTAsImNvbXBhbnlOYW1lIjoi5aSp6IGU5L-h5oGv56eR5oqA5pyJ6ZmQ5YWs5Y-4IiwicGhvbmUiOiIxNTY1OTM3NTk0MCIsInBsYXRmb3JtSWQiOjI5LCJuYW1lIjoi5bq35Lyf5Y2OIiwiYWRtaW5UeXBlIjoxfQ.v4qNLvYST03XpBdGnhYTK78A9v_k5IOdZ4r-WmDwfYg`
|
|
|
24
|
- tk, _ := ut.ParseAccessToken(str)
|
24
|
+ str := `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2ODM2MjQ3MTYsImlzcyI6InBlcmZvcm1hbmNlIiwidXNlcklkIjozNDIyMTg1MzQwMTIyNjI0LCJjb21wYW55SWQiOjgsImNvbXBhbnlOYW1lIjoiIiwicGhvbmUiOiIxMzA2NjY2NzcxMCIsInBsYXRmb3JtSWQiOjI5LCJuYW1lIjoiIiwiYWRtaW5UeXBlIjoxfQ.JLvIwDeY6mArmQE7NGs0u01NFArhedA6MphU94z_R04`
|
|
|
25
|
+ tk, err := ut.ParseAccessToken(str)
|
|
|
26
|
+ t.Logf("err:%s", err)
|
25
|
t.Logf("%+v", tk)
|
27
|
t.Logf("%+v", tk)
|
26
|
}
|
28
|
}
|
27
|
func TestParsetToken2(t *testing.T) {
|
29
|
func TestParsetToken2(t *testing.T) {
|