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

Function Test_Proxy_Forward_WithClient_TLSConfig

middleware/proxy/proxy_test.go:375–411  ·  view source on GitHub ↗

go test -run Test_Proxy_Forward_WithClient_TLSConfig

(t *testing.T)

Source from the content-addressed store, hash-verified

373
374// go test -run Test_Proxy_Forward_WithClient_TLSConfig
375func Test_Proxy_Forward_WithClient_TLSConfig(t *testing.T) {
376 restoreGlobalProxyClient(t)
377
378 serverTLSConf, _, err := tlstest.GetTLSConfigs()
379 require.NoError(t, err)
380
381 ln, err := net.Listen(fiber.NetworkTCP4, "127.0.0.1:0")
382 require.NoError(t, err)
383
384 ln = tls.NewListener(ln, serverTLSConf)
385
386 app := fiber.New()
387
388 app.Get("/tlsfwd", func(c fiber.Ctx) error {
389 return c.SendString("tls forward")
390 })
391
392 addr := ln.Addr().String()
393 clientTLSConf := &tls.Config{InsecureSkipVerify: true}
394
395 // disable certificate verification
396 WithClient(&fasthttp.Client{
397 TLSConfig: clientTLSConf,
398 })
399 app.Use(Forward("https://" + addr + "/tlsfwd"))
400
401 startServer(app, ln)
402
403 client := clientpkg.New()
404 client.SetTLSConfig(clientTLSConf)
405
406 resp, err := client.Get("https://" + addr)
407 require.NoError(t, err)
408 require.Equal(t, fiber.StatusOK, resp.StatusCode())
409 require.Equal(t, "tls forward", string(resp.Body()))
410 resp.Close()
411}
412
413// go test -run Test_Proxy_Modify_Response
414func Test_Proxy_Modify_Response(t *testing.T) {

Callers

nothing calls this directly

Calls 15

GetTLSConfigsFunction · 0.92
GetFunction · 0.92
restoreGlobalProxyClientFunction · 0.85
WithClientFunction · 0.85
ForwardFunction · 0.85
startServerFunction · 0.85
ListenMethod · 0.80
AddrMethod · 0.80
NewMethod · 0.65
GetMethod · 0.65
SendStringMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected