From c3c1bc1e1f026ed1d90ccbfe9aba50396fe08348 Mon Sep 17 00:00:00 2001 From: ozline Date: Tue, 17 Dec 2024 12:22:57 +0800 Subject: [PATCH] fix ci check error --- api/mw/token_test.go | 11 ++++++----- pkg/errno/default.go | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/api/mw/token_test.go b/api/mw/token_test.go index 4ad6484..ca18c28 100644 --- a/api/mw/token_test.go +++ b/api/mw/token_test.go @@ -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 @@ -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) { diff --git a/pkg/errno/default.go b/pkg/errno/default.go index 9648d12..b3f0c88 100644 --- a/pkg/errno/default.go +++ b/pkg/errno/default.go @@ -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, "缺失合法学生请求头数据")