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.
Open-IM-Server/pkg/common/tokenverify/jwt_token_test.go

24 lines
637 B

2 years ago
package tokenverify
2 years ago
import (
1 year ago
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/golang-jwt/jwt/v4"
2 years ago
"testing"
)
func Test_ParseToken(t *testing.T) {
1 year ago
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)
2 years ago
}