diff options
Diffstat (limited to 'tcpproxy_test.go')
-rw-r--r-- | tcpproxy_test.go | 62 |
1 files changed, 5 insertions, 57 deletions
diff --git a/tcpproxy_test.go b/tcpproxy_test.go index b6135b2..38feb06 100644 --- a/tcpproxy_test.go +++ b/tcpproxy_test.go @@ -28,10 +28,8 @@ import ( "fmt" "io" "io/ioutil" - "log" "math/big" "net" - "os" "strings" "testing" "time" @@ -377,9 +375,9 @@ type tlsServer struct { } func (t *tlsServer) Start() { - cert, acmeCert := cert(t.Test, t.Domain), cert(t.Test, t.Domain+".acme.invalid") + cert := cert(t.Test, t.Domain) cfg := &tls.Config{ - Certificates: []tls.Certificate{cert, acmeCert}, + Certificates: []tls.Certificate{cert}, } cfg.BuildNameToCertificate() @@ -442,9 +440,9 @@ func cert(t *testing.T, domain string) tls.Certificate { } // newTLSServer starts a TLS server that serves a self-signed cert for -// domain, and a corresonding acme.invalid dummy domain. +// domain. func newTLSServer(t *testing.T, domain string) net.Listener { - cert, acmeCert := cert(t, domain), cert(t, domain+".acme.invalid") + cert := cert(t, domain) l := newLocalListener(t) go func() { @@ -455,7 +453,7 @@ func newTLSServer(t *testing.T, domain string) net.Listener { } cfg := &tls.Config{ - Certificates: []tls.Certificate{cert, acmeCert}, + Certificates: []tls.Certificate{cert}, } cfg.BuildNameToCertificate() conn := tls.Server(rawConn, cfg) @@ -485,53 +483,3 @@ func readTLS(dest, domain string) (string, error) { } return string(bs), nil } - -func TestProxyACME(t *testing.T) { - log.SetOutput(ioutil.Discard) - defer log.SetOutput(os.Stderr) - - front := newLocalListener(t) - defer front.Close() - - backFoo := newTLSServer(t, "foo.com") - defer backFoo.Close() - backBar := newTLSServer(t, "bar.com") - defer backBar.Close() - backQuux := newTLSServer(t, "quux.com") - defer backQuux.Close() - - p := testProxy(t, front) - p.AddSNIRoute(testFrontAddr, "foo.com", To(backFoo.Addr().String())) - p.AddSNIRoute(testFrontAddr, "bar.com", To(backBar.Addr().String())) - p.AddStopACMESearch(testFrontAddr) - p.AddSNIRoute(testFrontAddr, "quux.com", To(backQuux.Addr().String())) - if err := p.Start(); err != nil { - t.Fatal(err) - } - - tests := []struct { - domain, want string - succeeds bool - }{ - {"foo.com", "foo.com", true}, - {"bar.com", "bar.com", true}, - {"quux.com", "quux.com", true}, - {"xyzzy.com", "", false}, - {"foo.com.acme.invalid", "foo.com", true}, - {"bar.com.acme.invalid", "bar.com", true}, - {"quux.com.acme.invalid", "", false}, - } - for _, test := range tests { - got, err := readTLS(front.Addr().String(), test.domain) - if test.succeeds { - if err != nil { - t.Fatalf("readTLS %q got error %q, want nil", test.domain, err) - } - if got != test.want { - t.Fatalf("readTLS %q got %q, want %q", test.domain, got, test.want) - } - } else if err == nil { - t.Fatalf("readTLS %q unexpectedly succeeded", test.domain) - } - } -} |