add step list for server creation
This commit is contained in:
@@ -8,26 +8,20 @@ import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// MockAuthMiddleware provides a test implementation of AuthMiddleware
|
||||
// that can be used as a drop-in replacement for the real AuthMiddleware
|
||||
type MockAuthMiddleware struct{}
|
||||
|
||||
// NewMockAuthMiddleware creates a new MockAuthMiddleware
|
||||
func NewMockAuthMiddleware() *MockAuthMiddleware {
|
||||
return &MockAuthMiddleware{}
|
||||
}
|
||||
|
||||
// Authenticate is a middleware that allows all requests without authentication for testing
|
||||
func (m *MockAuthMiddleware) Authenticate(ctx *fiber.Ctx) error {
|
||||
// Set a mock user ID in context
|
||||
mockUserID := uuid.New().String()
|
||||
ctx.Locals("userID", mockUserID)
|
||||
|
||||
// Set mock user info
|
||||
mockUserInfo := &middleware.CachedUserInfo{
|
||||
UserID: mockUserID,
|
||||
Username: "test_user",
|
||||
RoleName: "Admin", // Admin role to bypass permission checks
|
||||
RoleName: "Admin",
|
||||
Permissions: map[string]bool{"*": true},
|
||||
CachedAt: time.Now(),
|
||||
}
|
||||
@@ -38,21 +32,18 @@ func (m *MockAuthMiddleware) Authenticate(ctx *fiber.Ctx) error {
|
||||
return ctx.Next()
|
||||
}
|
||||
|
||||
// HasPermission is a middleware that allows all permission checks to pass for testing
|
||||
func (m *MockAuthMiddleware) HasPermission(requiredPermission string) fiber.Handler {
|
||||
return func(ctx *fiber.Ctx) error {
|
||||
return ctx.Next()
|
||||
}
|
||||
}
|
||||
|
||||
// AuthRateLimit is a test implementation that allows all requests
|
||||
func (m *MockAuthMiddleware) AuthRateLimit() fiber.Handler {
|
||||
return func(ctx *fiber.Ctx) error {
|
||||
return ctx.Next()
|
||||
}
|
||||
}
|
||||
|
||||
// RequireHTTPS is a test implementation that allows all HTTP requests
|
||||
func (m *MockAuthMiddleware) RequireHTTPS() fiber.Handler {
|
||||
return func(ctx *fiber.Ctx) error {
|
||||
return ctx.Next()
|
||||
|
||||
Reference in New Issue
Block a user