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

Function Test_Proxy_Balancer_WithTlsConfig

middleware/proxy/proxy_test.go:199–235  ·  view source on GitHub ↗

go test -run Test_Proxy_Balancer_WithTlsConfig

(t *testing.T)

Source from the content-addressed store, hash-verified

197
198// go test -run Test_Proxy_Balancer_WithTlsConfig
199func Test_Proxy_Balancer_WithTlsConfig(t *testing.T) {
200 t.Parallel()
201
202 serverTLSConf, _, err := tlstest.GetTLSConfigs()
203 require.NoError(t, err)
204
205 ln, err := net.Listen(fiber.NetworkTCP4, "127.0.0.1:0")
206 require.NoError(t, err)
207
208 ln = tls.NewListener(ln, serverTLSConf)
209
210 app := fiber.New()
211
212 app.Get("/tlsbalancer", func(c fiber.Ctx) error {
213 return c.SendString("tls balancer")
214 })
215
216 addr := ln.Addr().String()
217 clientTLSConf := &tls.Config{InsecureSkipVerify: true}
218
219 // disable certificate verification in Balancer
220 app.Use(Balancer(Config{
221 Servers: []string{addr},
222 TLSConfig: clientTLSConf,
223 }))
224
225 startServer(app, ln)
226
227 client := clientpkg.New()
228 client.SetTLSConfig(clientTLSConf)
229
230 resp, err := client.Get("https://" + addr + "/tlsbalancer")
231 require.NoError(t, err)
232 require.Equal(t, fiber.StatusOK, resp.StatusCode())
233 require.Equal(t, "tls balancer", string(resp.Body()))
234 resp.Close()
235}
236
237// go test -run Test_Proxy_Balancer_IPv6_Upstream
238func Test_Proxy_Balancer_IPv6_Upstream(t *testing.T) {

Callers

nothing calls this directly

Calls 15

GetTLSConfigsFunction · 0.92
GetFunction · 0.92
BalancerFunction · 0.85
startServerFunction · 0.85
ListenMethod · 0.80
AddrMethod · 0.80
NewMethod · 0.65
GetMethod · 0.65
SendStringMethod · 0.65
StringMethod · 0.65
UseMethod · 0.65
SetTLSConfigMethod · 0.65

Tested by

no test coverage detected