feat 排队

This commit is contained in:
2026-01-06 18:36:15 +08:00
parent 8289e2b4d9
commit 46839cd11b
20 changed files with 482 additions and 96 deletions

View File

@@ -10,7 +10,7 @@ import (
"common/utils"
"context"
"fmt"
"gateway/config"
"gateway/internal/global"
"gateway/internal/testutil"
"github.com/gin-gonic/gin"
"github.com/golang/mock/gomock"
@@ -30,9 +30,9 @@ func (ts *LoginTestSuite) TestGenToken() {
at, rt, err := genToken(context.Background(), int64(usn))
ts.Assert().NoError(err)
redisAt := redis.GetClient().Get(context.Background(), fmt.Sprintf(config.KeyUserAccessToken, usn)).Val()
redisAt := redis.GetClient().Get(context.Background(), fmt.Sprintf(global.KeyGatewayAccessToken, usn)).Val()
ts.Assert().Equal(at, redisAt)
redisRt := redis.GetClient().Get(context.Background(), fmt.Sprintf(config.KeyUserRefreshToken, usn)).Val()
redisRt := redis.GetClient().Get(context.Background(), fmt.Sprintf(global.KeyGatewayRefreshToken, usn)).Val()
ts.Assert().Equal(rt, redisRt)
}
@@ -138,7 +138,7 @@ func (ts *LoginTestSuite) TestRefreshToken() {
})
defer monkey.Unpatch(utils.ParseToken)
redis.GetClient().Set(context.Background(), fmt.Sprintf(config.KeyUserRefreshToken, 1), "ab", redis2.KeepTTL)
redis.GetClient().Set(context.Background(), fmt.Sprintf(global.KeyGatewayRefreshToken, 1), "ab", redis2.KeepTTL)
w, c := utils.CreateTestContext("POST", "/", &RefreshTokenReq{
RefreshToken: "abc",
@@ -156,7 +156,7 @@ func (ts *LoginTestSuite) TestRefreshToken() {
})
defer monkey.Unpatch(utils.ParseToken)
redis.GetClient().Set(context.Background(), fmt.Sprintf(config.KeyUserRefreshToken, 1), "abc", redis2.KeepTTL)
redis.GetClient().Set(context.Background(), fmt.Sprintf(global.KeyGatewayRefreshToken, 1), "abc", redis2.KeepTTL)
w, c := utils.CreateTestContext("POST", "/", &RefreshTokenReq{
RefreshToken: "abc",