Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 11, 01:00 UTC
| 1 | package caddyhttp |
| 2 | |
| 3 | import ( |
| 4 | "reflect" |
| 5 | "testing" |
| 6 | ) |
| 7 | |
| 8 | func TestHTTPSRRALPNsDefaultProtocols(t *testing.T) { |
| 9 | srv := &Server{} |
| 10 | |
| 11 | got := httpsRRALPNs(srv) |
| 12 | want := []string{"h3", "h2", "http/1.1"} |
| 13 | |
| 14 | if !reflect.DeepEqual(got, want) { |
| 15 | t.Fatalf("unexpected ALPN values: got %v want %v", got, want) |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | func TestHTTPSRRALPNsListenProtocolOverrides(t *testing.T) { |
| 20 | srv := &Server{ |
| 21 | Protocols: []string{"h1", "h2"}, |
| 22 | ListenProtocols: [][]string{ |
| 23 | {"h1"}, |
| 24 | nil, |
| 25 | {}, |
| 26 | {"h3", ""}, |
| 27 | }, |
| 28 | } |
| 29 | |
| 30 | got := httpsRRALPNs(srv) |
| 31 | want := []string{"h3", "h2", "http/1.1"} |
| 32 | |
| 33 | if !reflect.DeepEqual(got, want) { |
| 34 | t.Fatalf("unexpected ALPN values: got %v want %v", got, want) |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | func TestHTTPSRRALPNsIgnoresH2COnly(t *testing.T) { |
| 39 | srv := &Server{ |
| 40 | Protocols: []string{"h2c"}, |
| 41 | } |
| 42 | |
| 43 | got := httpsRRALPNs(srv) |
| 44 | if len(got) != 0 { |
| 45 | t.Fatalf("unexpected ALPN values: got %v want none", got) |
| 46 | } |
| 47 | } |