MCPcopy
hub / github.com/gofiber/fiber / Test_Ctx_IsFromUnixSocket_RemoteAddr

Function Test_Ctx_IsFromUnixSocket_RemoteAddr

ctx_test.go:9007–9029  ·  view source on GitHub ↗

go test -run Test_Ctx_IsFromUnixSocket_RemoteAddr

(t *testing.T)

Source from the content-addressed store, hash-verified

9005
9006// go test -run Test_Ctx_IsFromUnixSocket_RemoteAddr
9007func Test_Ctx_IsFromUnixSocket_RemoteAddr(t *testing.T) {
9008 t.Parallel()
9009
9010 {
9011 app := New()
9012 fastCtx := &fasthttp.RequestCtx{}
9013 fastCtx.SetRemoteAddr(&net.TCPAddr{IP: net.ParseIP("127.0.0.1")})
9014 c := app.AcquireCtx(fastCtx)
9015 defer app.ReleaseCtx(c)
9016 require.False(t, c.IsFromUnixSocket())
9017 require.False(t, c.Req().IsFromUnixSocket())
9018 }
9019
9020 {
9021 app := New()
9022 fastCtx := &fasthttp.RequestCtx{}
9023 fastCtx.SetRemoteAddr(&net.UnixAddr{Name: "/tmp/fiber.sock", Net: "unix"})
9024 c := app.AcquireCtx(fastCtx)
9025 defer app.ReleaseCtx(c)
9026 require.True(t, c.IsFromUnixSocket())
9027 require.True(t, c.Req().IsFromUnixSocket())
9028 }
9029}
9030
9031// go test -run Test_Ctx_extractIPsFromHeader -v
9032func Test_Ctx_extractIPsFromHeader(t *testing.T) {

Callers

nothing calls this directly

Calls 5

AcquireCtxMethod · 0.80
ReleaseCtxMethod · 0.80
NewFunction · 0.70
IsFromUnixSocketMethod · 0.65
ReqMethod · 0.65

Tested by

no test coverage detected