(t *testing.T)
| 617 | } |
| 618 | |
| 619 | func 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) |
nothing calls this directly
no test coverage detected
searching dependent graphs…