MCPcopy Index your code
hub / github.com/coder/coder / Test_configureCipherSuites

Function Test_configureCipherSuites

cli/server_internal_test.go:44–197  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

42}
43
44func Test_configureCipherSuites(t *testing.T) {
45 t.Parallel()
46
47 cipherNames := func(ciphers []*tls.CipherSuite) []string {
48 var names []string
49 for _, c := range ciphers {
50 names = append(names, c.Name)
51 }
52 return names
53 }
54
55 cipherIDs := func(ciphers []*tls.CipherSuite) []uint16 {
56 var ids []uint16
57 for _, c := range ciphers {
58 ids = append(ids, c.ID)
59 }
60 return ids
61 }
62
63 cipherByName := func(cipher string) *tls.CipherSuite {
64 for _, c := range append(tls.CipherSuites(), tls.InsecureCipherSuites()...) {
65 if cipher == c.Name {
66 return c
67 }
68 }
69 return nil
70 }
71
72 tests := []struct {
73 name string
74 wantErr string
75 wantWarnings []string
76 inputCiphers []string
77 minTLS uint16
78 maxTLS uint16
79 allowInsecure bool
80 expectCiphers []uint16
81 }{
82 {
83 name: "AllSecure",
84 minTLS: tls.VersionTLS10,
85 maxTLS: tls.VersionTLS13,
86 inputCiphers: cipherNames(tls.CipherSuites()),
87 wantWarnings: []string{},
88 expectCiphers: cipherIDs(tls.CipherSuites()),
89 },
90 {
91 name: "AllowInsecure",
92 minTLS: tls.VersionTLS10,
93 maxTLS: tls.VersionTLS13,
94 inputCiphers: append(cipherNames(tls.CipherSuites()), tls.InsecureCipherSuites()[0].Name),
95 allowInsecure: true,
96 wantWarnings: []string{
97 "insecure tls cipher specified",
98 },
99 expectCiphers: append(cipherIDs(tls.CipherSuites()), tls.InsecureCipherSuites()[0].ID),
100 },
101 {

Callers

nothing calls this directly

Calls 5

configureCipherSuitesFunction · 0.85
RunMethod · 0.65
SyncMethod · 0.45
ContainsMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected