Skip to content

Commit

Permalink
fix ci check error
Browse files Browse the repository at this point in the history
  • Loading branch information
ozline committed Dec 17, 2024
1 parent e94ef00 commit c3c1bc1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions api/mw/token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ import (
"github.com/bytedance/mockey"
"github.com/golang-jwt/jwt"
"github.com/stretchr/testify/assert"

"github.com/west2-online/fzuhelper-server/pkg/constants"
)

// TestCreateExpiredToken 是一个特殊测试,旨在生成一个过期的 Token
func TestCreateExpiredToken(t *testing.T) {
// 默认生成时间是一年一个月七天前的
var curTime = time.Now().AddDate(-1, -1, -7)
var expiredTime = curTime.Add(constants.AccessTokenTTL)
curTime := time.Now().AddDate(-1, -1, -7)
expiredTime := curTime.Add(constants.AccessTokenTTL)
var token string
var err error

Expand All @@ -48,15 +49,15 @@ func TestCreateExpiredToken(t *testing.T) {
"此处需要修改为私钥",
"-----END PRIVATE KEY-----")))
if err != nil {
t.Error(fmt.Sprintf("parse private key failed, err: %v", err))
t.Errorf("parse private key failed, err: %v", err)
}

token, err = tokenStruct.SignedString(key)
if err != nil {
t.Error(fmt.Sprintf("sign token failed, err: %v", err))
t.Errorf("sign token failed, err: %v", err)
}

fmt.Println(fmt.Sprintf("Access-Token: %s", token))
fmt.Printf("Access-Token: %s", token)
}

func TestCreateAllToken(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions pkg/errno/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ var (
Success = NewErrNo(SuccessCode, "ok")
CustomLaunchScreenSuccess = NewErrNo(consts.StatusOK, "ok") // 兼容处理

AuthError = NewErrNo(AuthErrorCode, "鉴权失败") // 鉴权失败,通常是内部错误,如解析失败
AuthInvalid = NewErrNo(AuthInvalidCode, "鉴权无效") // 鉴权无效,如令牌颁发者不是 west2-online
AuthError = NewErrNo(AuthErrorCode, "鉴权失败") // 鉴权失败,通常是内部错误,如解析失败
AuthInvalid = NewErrNo(AuthInvalidCode, "鉴权无效") // 鉴权无效,如令牌颁发者不是 west2-online
AuthAccessExpired = NewErrNo(AuthAccessExpiredCode, "访问令牌过期") // 访问令牌过期
AuthRefreshExpired = NewErrNo(AuthRefreshExpiredCode, "刷新令牌过期") // 刷新令牌过期
AuthMissing = NewErrNo(AuthMissingCode, "鉴权缺失") // 鉴权缺失,如访问令牌缺失
AuthMissing = NewErrNo(AuthMissingCode, "鉴权缺失") // 鉴权缺失,如访问令牌缺失

ParamError = NewErrNo(ParamErrorCode, "参数错误") // 参数校验失败,可能是参数为空、参数类型错误等
ParamMissingHeader = NewErrNo(ParamMissingHeaderCode, "缺失合法学生请求头数据")
Expand Down

0 comments on commit c3c1bc1

Please sign in to comment.