mirror of
https://github.com/lukaszraczylo/graphql-monitoring-proxy.git
synced 2026-10-18 06:17:56 +00:00
feat(deps)!: migrate from fiber v2 to fiber v3
BREAKING CHANGE: upgrades the HTTP framework from gofiber/fiber/v2 to gofiber/fiber/v3, and gofiber/websocket/v2 to gofiber/contrib/v3/websocket. - Handlers now take fiber.Ctx (interface) instead of *fiber.Ctx. - DisableStartupMessage moved from fiber.Config to fiber.ListenConfig on the proxy/api/monitoring Listen calls. - cors AllowOrigins is now []string; c.BodyParser -> c.Bind().Body(). - app.Test takes fiber.TestConfig instead of an int timeout (tests updated). - WebSocket swapped to contrib/v3/websocket (same Conn/New/Config/IsCloseError/IsWebSocketUpgrade API; Conn.Query preserved). - Adopts fasthttp v1.71.0 (pulled by fiber v3), resolving the v1.71 Host-header enforcement that broke the prior pinned-v1.69 workaround. fix(connpool): the background keep-alive goroutine no longer reads the mutable global cfg (captures HostGraphQL/HealthcheckGraphQL at pool creation). Under v3 timing it raced with parseConfig/test cfg reassignment; go test -race ./... is now clean (0 data races). test: make the circuit-breaker cache-fallback and request-coalescing integration tests deterministic (cache TTL outlives the retry loop; coalescing asserts against a measured single-request baseline instead of a hard-coded count); drop the flaky timing-ratio assertion in TestTimingAttackResistance (constant-time guarantee comes from subtle.ConstantTimeCompare, not wall-clock timing). Verified: go build, go vet, golangci-lint (0 issues), go test -race ./... (all packages pass, 0 races), govulncheck (no vulnerabilities). App + dashboard + WebSocket verified live under v3 in single-node and cluster modes.
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
libpack_cache "github.com/lukaszraczylo/graphql-monitoring-proxy/cache"
|
||||
libpack_logger "github.com/lukaszraczylo/graphql-monitoring-proxy/logging"
|
||||
"github.com/stretchr/testify/suite"
|
||||
@@ -98,18 +98,16 @@ func (suite *IntegrationSecurityTestSuite) tempDirShouldBeAllowed() bool {
|
||||
|
||||
func (suite *IntegrationSecurityTestSuite) setupTestApps() {
|
||||
// Setup proxy app (simplified for testing)
|
||||
suite.proxyApp = fiber.New(fiber.Config{
|
||||
DisableStartupMessage: true,
|
||||
})
|
||||
suite.proxyApp = fiber.New(fiber.Config{})
|
||||
|
||||
// Add proxy routes with security middleware
|
||||
suite.proxyApp.Use(func(c *fiber.Ctx) error {
|
||||
suite.proxyApp.Use(func(c fiber.Ctx) error {
|
||||
// Add request UUID for tracking
|
||||
c.Locals("request_uuid", fmt.Sprintf("test-uuid-%d", time.Now().UnixNano()))
|
||||
return c.Next()
|
||||
})
|
||||
|
||||
suite.proxyApp.Post("/graphql", func(c *fiber.Ctx) error {
|
||||
suite.proxyApp.Post("/graphql", func(c fiber.Ctx) error {
|
||||
// Simulate GraphQL proxy behavior with logging
|
||||
if cfg.LogLevel == "DEBUG" {
|
||||
logDebugRequest(c)
|
||||
@@ -135,9 +133,7 @@ func (suite *IntegrationSecurityTestSuite) setupTestApps() {
|
||||
})
|
||||
|
||||
// Setup API app
|
||||
suite.apiApp = fiber.New(fiber.Config{
|
||||
DisableStartupMessage: true,
|
||||
})
|
||||
suite.apiApp = fiber.New(fiber.Config{})
|
||||
|
||||
api := suite.apiApp.Group("/api")
|
||||
api.Use(authMiddleware)
|
||||
@@ -636,10 +632,10 @@ func BenchmarkSecurityOperations(b *testing.B) {
|
||||
os.Setenv("GMP_ADMIN_API_KEY", validAPIKey)
|
||||
defer os.Unsetenv("GMP_ADMIN_API_KEY")
|
||||
|
||||
app := fiber.New(fiber.Config{DisableStartupMessage: true})
|
||||
app := fiber.New()
|
||||
api := app.Group("/api")
|
||||
api.Use(authMiddleware)
|
||||
api.Get("/test", func(c *fiber.Ctx) error {
|
||||
api.Get("/test", func(c fiber.Ctx) error {
|
||||
return c.JSON(fiber.Map{"status": "ok"})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user