e2e_v113_test.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // +build go1.13,!js
  2. package e2e
  3. import (
  4. "context"
  5. "crypto/ed25519"
  6. "crypto/rand"
  7. "crypto/tls"
  8. "testing"
  9. "time"
  10. "github.com/pion/dtls/v2"
  11. "github.com/pion/dtls/v2/pkg/crypto/selfsign"
  12. "github.com/pion/transport/test"
  13. )
  14. // ED25519 is not supported in Go 1.12 crypto/x509.
  15. // Once Go 1.12 is deprecated, move this test to e2e_test.go.
  16. func testPionE2ESimpleED25519(t *testing.T, server, client func(*comm)) {
  17. lim := test.TimeOut(time.Second * 30)
  18. defer lim.Stop()
  19. report := test.CheckRoutines(t)
  20. defer report()
  21. for _, cipherSuite := range []dtls.CipherSuiteID{
  22. dtls.TLS_ECDHE_ECDSA_WITH_AES_128_CCM,
  23. dtls.TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8,
  24. dtls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
  25. dtls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
  26. } {
  27. cipherSuite := cipherSuite
  28. t.Run(cipherSuite.String(), func(t *testing.T) {
  29. ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
  30. defer cancel()
  31. _, key, err := ed25519.GenerateKey(rand.Reader)
  32. if err != nil {
  33. t.Fatal(err)
  34. }
  35. cert, err := selfsign.SelfSign(key)
  36. if err != nil {
  37. t.Fatal(err)
  38. }
  39. cfg := &dtls.Config{
  40. Certificates: []tls.Certificate{cert},
  41. CipherSuites: []dtls.CipherSuiteID{cipherSuite},
  42. InsecureSkipVerify: true,
  43. }
  44. serverPort := randomPort(t)
  45. comm := newComm(ctx, cfg, cfg, serverPort, server, client)
  46. comm.assert(t)
  47. })
  48. }
  49. }
  50. func TestPionE2ESimpleED25519(t *testing.T) {
  51. testPionE2ESimpleED25519(t, serverPion, clientPion)
  52. }