github.com/pion/dtls/v2@v2.2.12/cipher_suite_go114_test.go (about)

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