github.com/daeuniverse/quic-go@v0.0.0-20240413031024-943f218e0810/internal/testdata/cert_test.go (about) 1 package testdata 2 3 import ( 4 "crypto/tls" 5 "io" 6 7 . "github.com/onsi/ginkgo/v2" 8 . "github.com/onsi/gomega" 9 ) 10 11 var _ = Describe("certificates", func() { 12 It("returns certificates", func() { 13 ln, err := tls.Listen("tcp", "localhost:4433", GetTLSConfig()) 14 Expect(err).ToNot(HaveOccurred()) 15 16 go func() { 17 defer GinkgoRecover() 18 conn, err := ln.Accept() 19 Expect(err).ToNot(HaveOccurred()) 20 defer conn.Close() 21 _, err = conn.Write([]byte("foobar")) 22 Expect(err).ToNot(HaveOccurred()) 23 }() 24 25 conn, err := tls.Dial("tcp", "localhost:4433", &tls.Config{RootCAs: GetRootCA()}) 26 Expect(err).ToNot(HaveOccurred()) 27 data, err := io.ReadAll(conn) 28 Expect(err).ToNot(HaveOccurred()) 29 Expect(string(data)).To(Equal("foobar")) 30 }) 31 })