You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
637 B
24 lines
637 B
package tokenverify
|
|
|
|
import (
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
|
"github.com/golang-jwt/jwt/v4"
|
|
"testing"
|
|
)
|
|
|
|
func Test_ParseToken(t *testing.T) {
|
|
config.Config.TokenPolicy.AccessSecret = "OpenIM_server"
|
|
claims1 := BuildClaims("123456", constant.AndroidPlatformStr, 10)
|
|
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims1)
|
|
tokenString, err := token.SignedString([]byte(config.Config.TokenPolicy.AccessSecret))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
claim2, err := GetClaimFromToken(tokenString)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(claim2)
|
|
}
|