From bf9cea1432d67a1dc6dcd22d8a8a2712a7dba79d Mon Sep 17 00:00:00 2001 From: Justin Clift Date: Thu, 25 Jan 2024 22:35:04 +1000 Subject: [PATCH] WIP. Use an IS_TESTING env variable --- cmd/dio_test.go | 11 +++++++++++ cmd/root.go | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/cmd/dio_test.go b/cmd/dio_test.go index 67d47ef..cc19656 100644 --- a/cmd/dio_test.go +++ b/cmd/dio_test.go @@ -114,6 +114,17 @@ func (s *DioSuite) SetUpSuite(c *chk.C) { log.Fatalln(err) } TLSConfig.Certificates = []tls.Certificate{cert} + + // Load our self signed CA Cert chain, and set TLS1.2 as minimum + TLSConfig = tls.Config{ + Certificates: []tls.Certificate{cert}, + ClientCAs: ourCAPool, + InsecureSkipVerify: true, + MinVersion: tls.VersionTLS12, + PreferServerCipherSuites: true, + RootCAs: ourCAPool, + } + var email string certUser, email, _, err = getUserAndServer() if err != nil { diff --git a/cmd/root.go b/cmd/root.go index 692a1f5..5eee838 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -53,6 +53,11 @@ func init() { // Add support for pretty printing numbers numFormat = message.NewPrinter(message.MatchLanguage("en")) + // When run from go test we skip this, as we generate a temporary config file in the test suite setup + if os.Getenv("IS_TESTING") == "yes" { + return + } + // Add the global environment variables RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", fmt.Sprintf("config file (default is %s)", filepath.Join("$HOME", ".dio", "config.toml")))