cipher_suite_go114_test.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // +build go1.14
  2. package dtls
  3. import (
  4. "testing"
  5. )
  6. func TestInsecureCipherSuites(t *testing.T) {
  7. r := InsecureCipherSuites()
  8. if len(r) != 0 {
  9. t.Fatalf("Expected no insecure ciphersuites, got %d", len(r))
  10. }
  11. }
  12. func TestCipherSuites(t *testing.T) {
  13. ours := allCipherSuites()
  14. theirs := CipherSuites()
  15. if len(ours) != len(theirs) {
  16. t.Fatalf("Expected %d CipherSuites, got %d", len(ours), len(theirs))
  17. }
  18. for i, s := range ours {
  19. i := i
  20. s := s
  21. t.Run(s.String(), func(t *testing.T) {
  22. c := theirs[i]
  23. if c.ID != uint16(s.ID()) {
  24. t.Fatalf("Expected ID: 0x%04X, got 0x%04X", s.ID(), c.ID)
  25. }
  26. if c.Name != s.String() {
  27. t.Fatalf("Expected Name: %s, got %s", s.String(), c.Name)
  28. }
  29. if len(c.SupportedVersions) != 1 {
  30. t.Fatalf("Expected %d SupportedVersion, got %d", 1, len(c.SupportedVersions))
  31. }
  32. if c.SupportedVersions[0] != VersionDTLS12 {
  33. t.Fatalf("Expected SupportedVersions 0x%04X, got 0x%04X", VersionDTLS12, c.SupportedVersions[0])
  34. }
  35. if c.Insecure {
  36. t.Fatalf("Expected Insecure %t, got %t", false, c.Insecure)
  37. }
  38. })
  39. }
  40. }