diff options
Diffstat (limited to 'test/gitlabstub/option.go')
-rw-r--r-- | test/gitlabstub/option.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/gitlabstub/option.go b/test/gitlabstub/option.go index d55abec2..366aeb5d 100644 --- a/test/gitlabstub/option.go +++ b/test/gitlabstub/option.go @@ -1,6 +1,7 @@ package gitlabstub import ( + "crypto/tls" "net/http" "time" ) @@ -9,10 +10,17 @@ type config struct { pagesHandler http.HandlerFunc pagesRoot string delay time.Duration + tlsConfig *tls.Config } type Option func(*config) +func defaultTLSConfig() *tls.Config { + return &tls.Config{ + MinVersion: tls.VersionTLS12, + } +} + func WithPagesHandler(ph http.HandlerFunc) Option { return func(sc *config) { sc.pagesHandler = ph @@ -30,3 +38,12 @@ func WithDelay(delay time.Duration) Option { sc.delay = delay } } + +func WithCertificate(cert tls.Certificate) Option { + return func(c *config) { + if c.tlsConfig == nil { + c.tlsConfig = defaultTLSConfig() + } + c.tlsConfig.Certificates = append(c.tlsConfig.Certificates, cert) + } +} |