From bc88949ffbfcced355d8f3e216b4f1e5101f8f4e Mon Sep 17 00:00:00 2001 From: Lucas Clemente Date: Fri, 15 Apr 2016 12:34:01 +0200 Subject: [PATCH] add a server config test --- server_config_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 server_config_test.go diff --git a/server_config_test.go b/server_config_test.go new file mode 100644 index 00000000..3710529b --- /dev/null +++ b/server_config_test.go @@ -0,0 +1,29 @@ +package quic + +import ( + "bytes" + + "github.com/lucas-clemente/quic-go/crypto" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("ServerConfig", func() { + var ( + kex crypto.KeyExchange + scfg *ServerConfig + ) + + BeforeEach(func() { + kex = crypto.NewCurve25519KEX() + scfg = NewServerConfig(kex, nil) + }) + + It("gets the proper binary representation", func() { + expected := bytes.NewBuffer([]byte{0x53, 0x43, 0x46, 0x47, 0x7, 0x0, 0x0, 0x0, 0x56, 0x45, 0x52, 0x0, 0x4, 0x0, 0x0, 0x0, 0x41, 0x45, 0x41, 0x44, 0x8, 0x0, 0x0, 0x0, 0x53, 0x43, 0x49, 0x44, 0x18, 0x0, 0x0, 0x0, 0x50, 0x55, 0x42, 0x53, 0x3b, 0x0, 0x0, 0x0, 0x4b, 0x45, 0x58, 0x53, 0x3f, 0x0, 0x0, 0x0, 0x4f, 0x42, 0x49, 0x54, 0x47, 0x0, 0x0, 0x0, 0x45, 0x58, 0x50, 0x59, 0x4f, 0x0, 0x0, 0x0, 0x51, 0x30, 0x33, 0x32, 0x43, 0x43, 0x32, 0x30, 0xc5, 0x1c, 0x73, 0x6b, 0x8f, 0x48, 0x49, 0xae, 0xb3, 0x0, 0xa2, 0xd4, 0x4b, 0xa0, 0xcf, 0xdf, 0x20, 0x0, 0x0}) + expected.Write(kex.PublicKey()) + expected.Write([]byte{0x43, 0x32, 0x35, 0x35, 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}) + Expect(scfg.Get()).To(Equal(expected.Bytes())) + }) +})