go17/vblog/apps/token/impl_test.go

37 lines
942 B
Go
Raw Normal View History

2024-12-08 11:59:36 +08:00
package token_test
import (
"context"
"testing"
"gitlab.com/go-course-project/go17/vblog/apps/token"
)
var (
ctx = context.Background()
)
// 我要测试的对象是什么?, 这个服务的具体实现
// Service的具体实现现在还没实现
// $2a$10$yHVSVuyIpTrQxwiuZUwSMuaJFsnd4YBd6hgA.31xNzuyTu4voD/QW
// $2a$10$fe0lsMhM15i4cjHmWudroOOIIBR27Nb7vwrigwK.9PhWdFld44Yze
// $2a$10$RoR0qK37vfc7pddPV0mpU.nN15Lv8745A40MkCJLe47Q00Ag83Qru
// https://gitee.com/infraboard/go-course/blob/master/day09/go-hash.md#bcrypt
func TestIssueToken(t *testing.T) {
req := token.NewIssueTokenRequest("admin", "123456")
2024-12-15 11:36:22 +08:00
ins, err := token.GetService().IssueToken(ctx, req)
2024-12-08 11:59:36 +08:00
if err != nil {
t.Fatal(err)
}
t.Log(ins)
}
func TestValidateToken(t *testing.T) {
req := token.NewValidateTokenRequest("51bf49f5-12a2-406a-baf8-3f99d985b41a")
2024-12-15 11:36:22 +08:00
ins, err := token.GetService().ValidateToken(ctx, req)
2024-12-08 11:59:36 +08:00
if err != nil {
t.Fatal(err)
}
t.Log(ins)
}