mirror of
https://github.com/caddyserver/caddy.git
synced 2026-05-17 05:03:12 -04:00
* tls: add alpn to managed HTTPS records * tls: centralise HTTPS RR ALPN defaults and registration Reuse shared protocol defaults instead of repeating the default HTTP protocol list, unify server name registration to carry ALPN in one experimental API and reuse the TLS default ALPN ordering for HTTPS RR publication * http: centralise effective protocol resolution for HTTPS RR ALPN
48 lines
884 B
Go
48 lines
884 B
Go
package caddyhttp
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestHTTPSRRALPNsDefaultProtocols(t *testing.T) {
|
|
srv := &Server{}
|
|
|
|
got := httpsRRALPNs(srv)
|
|
want := []string{"h3", "h2", "http/1.1"}
|
|
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Fatalf("unexpected ALPN values: got %v want %v", got, want)
|
|
}
|
|
}
|
|
|
|
func TestHTTPSRRALPNsListenProtocolOverrides(t *testing.T) {
|
|
srv := &Server{
|
|
Protocols: []string{"h1", "h2"},
|
|
ListenProtocols: [][]string{
|
|
{"h1"},
|
|
nil,
|
|
{},
|
|
{"h3", ""},
|
|
},
|
|
}
|
|
|
|
got := httpsRRALPNs(srv)
|
|
want := []string{"h3", "h2", "http/1.1"}
|
|
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Fatalf("unexpected ALPN values: got %v want %v", got, want)
|
|
}
|
|
}
|
|
|
|
func TestHTTPSRRALPNsIgnoresH2COnly(t *testing.T) {
|
|
srv := &Server{
|
|
Protocols: []string{"h2c"},
|
|
}
|
|
|
|
got := httpsRRALPNs(srv)
|
|
if len(got) != 0 {
|
|
t.Fatalf("unexpected ALPN values: got %v want none", got)
|
|
}
|
|
}
|