kefu/tools/jwt_test.go

26 lines
469 B
Go
Raw Permalink Normal View History

2024-12-10 02:50:12 +00:00
package tools
import (
"github.com/golang-jwt/jwt"
"testing"
"time"
)
func TestJwt(t *testing.T) {
tokenCliams := UserClaims{
Id: 1,
Username: "kefu2",
RoleId: 2,
Pid: 1,
CreateTime: time.Now(),
StandardClaims: jwt.StandardClaims{
ExpiresAt: time.Now().Unix() + 24*3600,
},
}
token, err := MakeCliamsToken(tokenCliams)
t.Log(token, err)
orgToken, err := ParseCliamsToken(token, true)
t.Logf("%+v,%+v", orgToken, err)
}