fix(test): correct test expectations and logic

Httptest and similar callers often leave Host unset; fall back to URL
for scheme, host, port, and addr substitution.

jsonstore drops the IsTest load short-circuit and duplicate loadNS map
registration; tests isolate storesPath. Skip MaxMind background updates
when IsTest. Tests restore APISkipOriginCheck, use app-scoped OIDC
state cookies, attach route context in middleware helpers, and use
locked buffers for concurrent log capture.
This commit is contained in:
yusing
2026-04-19 14:40:22 +08:00
parent 61f00516dd
commit b122d42a0b
9 changed files with 72 additions and 18 deletions

View File

@@ -12,6 +12,7 @@ import (
"github.com/bytedance/sonic"
"github.com/yusing/godoxy/internal/common"
nettypes "github.com/yusing/godoxy/internal/net/types"
"github.com/yusing/godoxy/internal/route/routes"
"github.com/yusing/goutils/http/reverseproxy"
)
@@ -161,6 +162,10 @@ func newMiddlewaresTest(middlewares []*Middleware, args *testArgs) (*TestResult,
req := httptest.NewRequest(args.reqMethod, args.reqURL.String(), args.bodyReader())
maps.Copy(req.Header, args.headers)
req = routes.WithRouteContext(req, fakeMiddlewareHTTPRoute{
name: "test-upstream",
targetURL: args.upstreamURL,
})
w := httptest.NewRecorder()