(t *testing.T)
| 42 | } |
| 43 | |
| 44 | func 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 | { |
nothing calls this directly
no test coverage detected