cipher_suite_go114_test.go 1.2 KB

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