29 lines
922 B
Go
29 lines
922 B
Go
package middleware
|
|
|
|
import "context"
|
|
|
|
// ExportedCachedUserInfo exports CachedUserInfo for testing
|
|
type ExportedCachedUserInfo = CachedUserInfo
|
|
|
|
// GetCachedUserInfo exports the internal getCachedUserInfo method for testing
|
|
func (m *AuthMiddleware) GetCachedUserInfo(ctx context.Context, userID string) (*CachedUserInfo, error) {
|
|
return m.getCachedUserInfo(ctx, userID)
|
|
}
|
|
|
|
// TestExports provides test-only functionality for AuthMiddleware
|
|
type TestExports struct {
|
|
AuthMiddleware *AuthMiddleware
|
|
}
|
|
|
|
// NewTestExports creates a new TestExports instance
|
|
func NewTestExports(auth *AuthMiddleware) *TestExports {
|
|
return &TestExports{
|
|
AuthMiddleware: auth,
|
|
}
|
|
}
|
|
|
|
// HasPermissionFromCache exports the internal hasPermissionFromCache method for testing
|
|
func (t *TestExports) HasPermissionFromCache(userInfo *CachedUserInfo, permission string) bool {
|
|
return t.AuthMiddleware.hasPermissionFromCache(userInfo, permission)
|
|
}
|