mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 07:50:25 +08:00 
			
		
		
		
	实现WAF统计数据接口
This commit is contained in:
		
							
								
								
									
										13
									
								
								internal/rpc/utils/mock_node_admin.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								internal/rpc/utils/mock_node_admin.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
			
		||||
package rpcutils
 | 
			
		||||
 | 
			
		||||
import "context"
 | 
			
		||||
 | 
			
		||||
type MockAdminNodeContext struct {
 | 
			
		||||
	context.Context
 | 
			
		||||
 | 
			
		||||
	AdminId int64
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewMockAdminNodeContext(adminId int64) context.Context {
 | 
			
		||||
	return &MockAdminNodeContext{AdminId: adminId}
 | 
			
		||||
}
 | 
			
		||||
@@ -57,9 +57,18 @@ func ValidateRequest(ctx context.Context, userTypes ...UserType) (userType UserT
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 是否是模拟测试
 | 
			
		||||
	mockCtx, isMock := ctx.(*MockNodeContext)
 | 
			
		||||
	if isMock {
 | 
			
		||||
		return UserTypeNode, mockCtx.NodeId, nil
 | 
			
		||||
	{
 | 
			
		||||
		mockCtx, isMock := ctx.(*MockNodeContext)
 | 
			
		||||
		if isMock {
 | 
			
		||||
			return UserTypeNode, mockCtx.NodeId, nil
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	{
 | 
			
		||||
		mockCtx, isMock := ctx.(*MockAdminNodeContext)
 | 
			
		||||
		if isMock {
 | 
			
		||||
			return UserTypeAdmin, mockCtx.AdminId, nil
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	md, ok := metadata.FromIncomingContext(ctx)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user