@@ -18,6 +18,7 @@ package webhook_test
18
18
19
19
import (
20
20
"context"
21
+ "crypto/tls"
21
22
"fmt"
22
23
"io"
23
24
"net"
@@ -186,7 +187,7 @@ var _ = Describe("Webhook Server", func() {
186
187
})
187
188
})
188
189
189
- It ("should serve be able to serve in unmanaged mode" , func () {
190
+ It ("should be able to serve in unmanaged mode" , func () {
190
191
server = & webhook.Server {
191
192
Host : servingOpts .LocalServingHost ,
192
193
Port : servingOpts .LocalServingPort ,
@@ -207,6 +208,46 @@ var _ = Describe("Webhook Server", func() {
207
208
ctxCancel ()
208
209
Eventually (doneCh , "4s" ).Should (BeClosed ())
209
210
})
211
+
212
+ It ("should respect passed in TLS configurations" , func () {
213
+ var finalCfg * tls.Config
214
+ tlsCfgFunc := func (cfg * tls.Config ) {
215
+ cfg .CipherSuites = []uint16 {
216
+ tls .TLS_AES_128_GCM_SHA256 ,
217
+ tls .TLS_AES_256_GCM_SHA384 ,
218
+ }
219
+ // save cfg after changes to test against
220
+ finalCfg = cfg
221
+ }
222
+ server = & webhook.Server {
223
+ Host : servingOpts .LocalServingHost ,
224
+ Port : servingOpts .LocalServingPort ,
225
+ CertDir : servingOpts .LocalServingCertDir ,
226
+ TLSMinVersion : "1.2" ,
227
+ TLSOpts : []func (* tls.Config ){
228
+ tlsCfgFunc ,
229
+ },
230
+ }
231
+ server .Register ("/somepath" , & testHandler {})
232
+ doneCh := genericStartServer (func (ctx context.Context ) {
233
+ Expect (server .StartStandalone (ctx , scheme .Scheme ))
234
+ })
235
+
236
+ Eventually (func () ([]byte , error ) {
237
+ resp , err := client .Get (fmt .Sprintf ("https://%s/somepath" , testHostPort ))
238
+ Expect (err ).NotTo (HaveOccurred ())
239
+ defer resp .Body .Close ()
240
+ return io .ReadAll (resp .Body )
241
+ }).Should (Equal ([]byte ("gadzooks!" )))
242
+ Expect (finalCfg .MinVersion ).To (Equal (uint16 (tls .VersionTLS12 )))
243
+ Expect (finalCfg .CipherSuites ).To (ContainElements (
244
+ tls .TLS_AES_128_GCM_SHA256 ,
245
+ tls .TLS_AES_256_GCM_SHA384 ,
246
+ ))
247
+
248
+ ctxCancel ()
249
+ Eventually (doneCh , "4s" ).Should (BeClosed ())
250
+ })
210
251
})
211
252
212
253
type testHandler struct {
0 commit comments