MCPcopy Index your code
hub / github.com/labstack/echo / TestStartConfig_WithHTTP2WithCustomTlsConfig

Function TestStartConfig_WithHTTP2WithCustomTlsConfig

server_test.go:619–702  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

617}
618
619func TestStartConfig_WithHTTP2WithCustomTlsConfig(t *testing.T) {
620 var testCases = []struct {
621 name string
622 disableHTTP2 bool
623 }{
624 {
625 name: "HTTP2 enabled default",
626 disableHTTP2: false,
627 },
628 {
629 name: "HTTP2 disabled",
630 disableHTTP2: true,
631 },
632 }
633
634 for _, tc := range testCases {
635 t.Run(tc.name, func(t *testing.T) {
636 e := New()
637
638 e.GET("/ok", func(c *Context) error {
639 return c.String(http.StatusOK, "OK")
640 })
641
642 addrChan := make(chan string)
643 errCh := make(chan error, 1)
644
645 ctx, shutdown := stdContext.WithTimeout(stdContext.Background(), 200*time.Millisecond)
646 defer shutdown()
647
648 go func() {
649 certFile := "_fixture/certs/cert.pem"
650 keyFile := "_fixture/certs/key.pem"
651
652 s := &StartConfig{
653 Address: ":0",
654 GracefulTimeout: 100 * time.Millisecond,
655 ListenerAddrFunc: func(addr net.Addr) {
656 addrChan <- addr.String()
657 },
658 }
659 if tc.disableHTTP2 {
660 s.TLSConfig = &tls.Config{
661 NextProtos: []string{"http/1.1"},
662 }
663 }
664 errCh <- s.StartTLS(ctx, e, certFile, keyFile)
665 }()
666
667 addr, err := waitForServerStart(addrChan, errCh)
668 assert.NoError(t, err)
669 url := fmt.Sprintf("https://%v/ok", addr)
670
671 // do ordinary http(s) request
672 client := &http.Client{Transport: &http.Transport{
673 TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
674 }}
675 res, err := client.Get(url)
676 assert.NoError(t, err)

Callers

nothing calls this directly

Calls 8

StartTLSMethod · 0.95
NewFunction · 0.85
waitForServerStartFunction · 0.85
GETMethod · 0.45
StringMethod · 0.45
GetMethod · 0.45
ErrorMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…