From 1bb35ee3c4f956cf8f7bf7629ef4710f2ed8db0e Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Sat, 11 Jan 2020 10:56:58 +0900 Subject: [PATCH] Run TestPionE2ESimpleED25519 only on Go 1.13 Conditionally build TestPionE2ESimpleED25519 in e2e_v113_test.go. Once Go 1.12 is deprecated, move this test to e2e_test.go. --- e2e/e2e_test.go | 37 ------------------------------- e2e/e2e_v113_test.go | 52 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 37 deletions(-) create mode 100644 e2e/e2e_v113_test.go diff --git a/e2e/e2e_test.go b/e2e/e2e_test.go index 3d1bf2248..ec0196b59 100644 --- a/e2e/e2e_test.go +++ b/e2e/e2e_test.go @@ -1,7 +1,6 @@ package e2e import ( - "crypto/rand" "crypto/tls" "errors" "io" @@ -11,8 +10,6 @@ import ( "testing" "time" - "golang.org/x/crypto/ed25519" - "github.com/pion/dtls/v2" "github.com/pion/transport/test" ) @@ -212,40 +209,6 @@ func TestPionE2ESimple(t *testing.T) { } } -func TestPionE2ESimpleED25519(t *testing.T) { - lim := test.TimeOut(time.Second * 30) - defer lim.Stop() - - report := test.CheckRoutines(t) - defer report() - - serverPort := randomPort(t) - - for _, cipherSuite := range []dtls.CipherSuiteID{ - dtls.TLS_ECDHE_ECDSA_WITH_AES_128_CCM, - dtls.TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8, - dtls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, - dtls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, - } { - _, key, err := ed25519.GenerateKey(rand.Reader) - if err != nil { - t.Fatal(err) - } - cert, err := dtls.SelfSign(key) - if err != nil { - t.Fatal(err) - } - - cfg := &dtls.Config{ - Certificates: []tls.Certificate{cert}, - CipherSuites: []dtls.CipherSuiteID{cipherSuite}, - InsecureSkipVerify: true, - ConnectTimeout: dtls.ConnectTimeoutOption(5 * time.Second), - } - assertE2ECommunication(cfg, cfg, serverPort, t) - } -} - func TestPionE2ESimplePSK(t *testing.T) { lim := test.TimeOut(time.Second * 30) defer lim.Stop() diff --git a/e2e/e2e_v113_test.go b/e2e/e2e_v113_test.go new file mode 100644 index 000000000..fe5f1cd7f --- /dev/null +++ b/e2e/e2e_v113_test.go @@ -0,0 +1,52 @@ +// +build go1.13 + +package e2e + +import ( + "crypto/rand" + "crypto/tls" + "testing" + "time" + + "golang.org/x/crypto/ed25519" + + "github.com/pion/dtls/v2" + "github.com/pion/transport/test" +) + +// ED25519 is not supported in Go 1.12 crypto/x509. +// Once Go 1.12 is deprecated, move this test to e2e_test.go. + +func TestPionE2ESimpleED25519(t *testing.T) { + lim := test.TimeOut(time.Second * 30) + defer lim.Stop() + + report := test.CheckRoutines(t) + defer report() + + serverPort := randomPort(t) + + for _, cipherSuite := range []dtls.CipherSuiteID{ + dtls.TLS_ECDHE_ECDSA_WITH_AES_128_CCM, + dtls.TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8, + dtls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, + dtls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, + } { + _, key, err := ed25519.GenerateKey(rand.Reader) + if err != nil { + t.Fatal(err) + } + cert, err := dtls.SelfSign(key) + if err != nil { + t.Fatal(err) + } + + cfg := &dtls.Config{ + Certificates: []tls.Certificate{cert}, + CipherSuites: []dtls.CipherSuiteID{cipherSuite}, + InsecureSkipVerify: true, + ConnectTimeout: dtls.ConnectTimeoutOption(5 * time.Second), + } + assertE2ECommunication(cfg, cfg, serverPort, t) + } +}