use a self-signed certificate for integration tests

This commit is contained in:
Marten Seemann
2018-12-11 14:03:08 +06:30
parent 7b880f259f
commit 4abcce6408
22 changed files with 225 additions and 159 deletions

31
internal/testdata/cert_test.go vendored Normal file
View File

@@ -0,0 +1,31 @@
package testdata
import (
"crypto/tls"
"io/ioutil"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("certificates", func() {
It("returns certificates", func() {
ln, err := tls.Listen("tcp", "localhost:4433", GetTLSConfig())
Expect(err).ToNot(HaveOccurred())
go func() {
defer GinkgoRecover()
conn, err := ln.Accept()
Expect(err).ToNot(HaveOccurred())
defer conn.Close()
_, err = conn.Write([]byte("foobar"))
Expect(err).ToNot(HaveOccurred())
}()
conn, err := tls.Dial("tcp", "localhost:4433", &tls.Config{RootCAs: GetRootCA()})
Expect(err).ToNot(HaveOccurred())
data, err := ioutil.ReadAll(conn)
Expect(err).ToNot(HaveOccurred())
Expect(string(data)).To(Equal("foobar"))
})
})