cmd/gitbayd/tls_test.go

v1.43.1
gitbay/cmd/gitbayd/tls_test.go history · blame · raw

21 lines · 657 bytes

 1package main
 2
 3import (
 4	"crypto/tls"
 5	"testing"
 6)
 7
 8// The floor is stated in code rather than inherited from the Go
 9// release the binary was built with (#281).
10func TestServerTLSMinimum(t *testing.T) {
11	if got := serverTLS(nil).MinVersion; got != tls.VersionTLS12 {
12		t.Fatalf("files mode: MinVersion %#x, want %#x", got, tls.VersionTLS12)
13	}
14	// autocert's config carries the ALPN protocols TLS-ALPN-01 needs;
15	// setting the floor must keep them.
16	base := &tls.Config{NextProtos: []string{"h2", "http/1.1", "acme-tls/1"}}
17	got := serverTLS(base)
18	if got.MinVersion != tls.VersionTLS12 || len(got.NextProtos) != 3 {
19		t.Fatalf("acme mode: %+v", got)
20	}
21}