重构迁移核心数据结构到认证模块;完善中间件初始化逻辑以及 logger 记录过程

This commit is contained in:
2025-05-08 13:18:54 +08:00
parent c93d0bf467
commit e2cc318560
24 changed files with 353 additions and 215 deletions

View File

@@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"platform/pkg/testutil"
"platform/web/auth"
"platform/web/core"
g "platform/web/globals"
"platform/web/models"
@@ -276,7 +277,7 @@ func Test_channelService_CreateChannel(t *testing.T) {
type args struct {
ctx context.Context
auth *AuthContext
auth *auth.Context
resourceId int32
protocol ChannelProtocol
authType ChannelAuthType
@@ -286,8 +287,8 @@ func Test_channelService_CreateChannel(t *testing.T) {
// 准备测试数据
ctx := context.WithValue(context.Background(), requestid.ConfigDefault.ContextKey, "test-request-id")
var adminAuth = &AuthContext{Payload: Payload{Id: 100, Type: PayloadAdmin}}
var userAuth = &AuthContext{Payload: Payload{Id: 101, Type: PayloadUser}}
var adminAuth = &auth.Context{Payload: auth.Payload{Id: 100, Type: auth.PayloadAdmin}}
var userAuth = &auth.Context{Payload: auth.Payload{Id: 101, Type: auth.PayloadUser}}
mc.AutoQueryMock = func() (g.CloudConnectResp, error) {
return g.CloudConnectResp{
"test-proxy": []g.AutoConfig{
@@ -967,7 +968,7 @@ func Test_channelService_RemoveChannels(t *testing.T) {
type args struct {
ctx context.Context
auth *AuthContext
auth *auth.Context
id []int32
}
@@ -989,8 +990,8 @@ func Test_channelService_RemoveChannels(t *testing.T) {
md.Create(adminUser)
// 认证上下文
var adminAuth = &AuthContext{Payload: Payload{Id: 100, Type: PayloadAdmin}}
var userAuth = &AuthContext{Payload: Payload{Id: 101, Type: PayloadUser}}
var adminAuth = &auth.Context{Payload: auth.Payload{Id: 100, Type: auth.PayloadAdmin}}
var userAuth = &auth.Context{Payload: auth.Payload{Id: 101, Type: auth.PayloadUser}}
// 创建代理
var proxy = &models.Proxy{