MCPcopy Create free account
hub / github.com/M1r0ku/frp-Modify / TestGetHTTPSHostname

Function TestGetHTTPSHostname

frp-dev/pkg/util/vhost/https_test.go:12–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestGetHTTPSHostname(t *testing.T) {
13 require := require.New(t)
14
15 l, err := net.Listen("tcp", ":")
16 require.NoError(err)
17 defer l.Close()
18
19 var conn net.Conn
20 go func() {
21 conn, _ = l.Accept()
22 require.NotNil(conn)
23 }()
24
25 go func() {
26 time.Sleep(100 * time.Millisecond)
27 tls.Dial("tcp", l.Addr().String(), &tls.Config{
28 InsecureSkipVerify: true,
29 ServerName: "example.com",
30 })
31 }()
32
33 time.Sleep(200 * time.Millisecond)
34 _, infos, err := GetHTTPSHostname(conn)
35 require.NoError(err)
36 require.Equal("example.com", infos["Host"])
37 require.Equal("https", infos["Scheme"])
38}

Callers

nothing calls this directly

Calls 7

GetHTTPSHostnameFunction · 0.85
EqualMethod · 0.80
CloseMethod · 0.65
ListenMethod · 0.45
AcceptMethod · 0.45
StringMethod · 0.45
AddrMethod · 0.45

Tested by

no test coverage detected