...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package tlsutil
16
17 import (
18 "crypto/tls"
19 "testing"
20 )
21
22 func TestGetCipherSuite_not_existing(t *testing.T) {
23 _, ok := GetCipherSuite("not_existing")
24 if ok {
25 t.Fatal("Expected not ok")
26 }
27 }
28
29 func CipherSuiteExpectedToExist(tb testing.TB, cipher string, expectedId uint16) {
30 vid, ok := GetCipherSuite(cipher)
31 if !ok {
32 tb.Errorf("Expected %v cipher to exist", cipher)
33 }
34 if vid != expectedId {
35 tb.Errorf("For %v expected=%v found=%v", cipher, expectedId, vid)
36 }
37 }
38
39 func TestGetCipherSuite_success(t *testing.T) {
40 CipherSuiteExpectedToExist(t, "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA)
41 CipherSuiteExpectedToExist(t, "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256)
42
43
44 CipherSuiteExpectedToExist(t, "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305", tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256)
45 CipherSuiteExpectedToExist(t, "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305", tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256)
46 }
47
48 func TestGetCipherSuite_insecure(t *testing.T) {
49 CipherSuiteExpectedToExist(t, "TLS_ECDHE_RSA_WITH_RC4_128_SHA", tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA)
50 }
51
View as plain text