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

Function Test_Proxy_Forward_WithTlsConfig_To_Http

middleware/proxy/proxy_test.go:322–351  ·  view source on GitHub ↗

go test -run Test_Proxy_Forward_WithTlsConfig_To_Http

(t *testing.T)

Source from the content-addressed store, hash-verified

320
321// go test -run Test_Proxy_Forward_WithTlsConfig_To_Http
322func Test_Proxy_Forward_WithTlsConfig_To_Http(t *testing.T) {
323 t.Parallel()
324
325 _, targetAddr := createProxyTestServerIPv4(t, func(c fiber.Ctx) error {
326 return c.SendString("hello from target")
327 })
328
329 proxyServerTLSConf, _, err := tlstest.GetTLSConfigs()
330 require.NoError(t, err)
331
332 proxyServerLn, err := net.Listen(fiber.NetworkTCP4, "127.0.0.1:0")
333 require.NoError(t, err)
334
335 proxyServerLn = tls.NewListener(proxyServerLn, proxyServerTLSConf)
336 proxyAddr := proxyServerLn.Addr().String()
337
338 app := fiber.New()
339 app.Use(Forward("http://" + targetAddr))
340 startServer(app, proxyServerLn)
341
342 client := clientpkg.New()
343 client.SetTimeout(5 * time.Second)
344 client.TLSConfig().InsecureSkipVerify = true
345
346 resp, err := client.Get("https://" + proxyAddr)
347 require.NoError(t, err)
348 require.Equal(t, fiber.StatusOK, resp.StatusCode())
349 require.Equal(t, "hello from target", string(resp.Body()))
350 resp.Close()
351}
352
353// go test -run Test_Proxy_Forward
354func Test_Proxy_Forward(t *testing.T) {

Callers

nothing calls this directly

Calls 15

GetTLSConfigsFunction · 0.92
GetFunction · 0.92
ForwardFunction · 0.85
startServerFunction · 0.85
ListenMethod · 0.80
AddrMethod · 0.80
SendStringMethod · 0.65
StringMethod · 0.65
NewMethod · 0.65
UseMethod · 0.65
TLSConfigMethod · 0.65

Tested by

no test coverage detected