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

Function Test_Client_TLS_Error

client/client_test.go:1910–1942  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1908}
1909
1910func Test_Client_TLS_Error(t *testing.T) {
1911 t.Parallel()
1912
1913 serverTLSConf, clientTLSConf, err := tlstest.GetTLSConfigs()
1914 clientTLSConf.MaxVersion = tls.VersionTLS12
1915 serverTLSConf.MinVersion = tls.VersionTLS13
1916 require.NoError(t, err)
1917
1918 ln, err := net.Listen(fiber.NetworkTCP4, "127.0.0.1:0")
1919 require.NoError(t, err)
1920
1921 ln = tls.NewListener(ln, serverTLSConf)
1922
1923 app := fiber.New()
1924 app.Get("/", func(c fiber.Ctx) error {
1925 return c.SendString("tls")
1926 })
1927
1928 go func() {
1929 assert.NoError(t, app.Listener(ln, fiber.ListenConfig{
1930 DisableStartupMessage: true,
1931 }))
1932 }()
1933 time.Sleep(1 * time.Second)
1934
1935 client := New()
1936 resp, err := client.SetTLSConfig(clientTLSConf).Get("https://" + ln.Addr().String())
1937
1938 require.Error(t, err)
1939 cfg := client.TLSConfig()
1940 require.Same(t, clientTLSConf, cfg)
1941 require.Nil(t, resp)
1942}
1943
1944func Test_Client_TLS_Empty_TLSConfig(t *testing.T) {
1945 t.Parallel()

Callers

nothing calls this directly

Calls 12

GetTLSConfigsFunction · 0.92
ListenMethod · 0.80
ListenerMethod · 0.80
AddrMethod · 0.80
NewFunction · 0.70
NewMethod · 0.65
GetMethod · 0.65
SendStringMethod · 0.65
SetTLSConfigMethod · 0.65
StringMethod · 0.65
ErrorMethod · 0.65
TLSConfigMethod · 0.65

Tested by

no test coverage detected