@@ -21,6 +21,7 @@ import (
2121 "encoding/base64"
2222 "io/ioutil"
2323 "os"
24+ "runtime"
2425 "testing"
2526
2627 "github.com/stretchr/testify/assert"
@@ -212,21 +213,30 @@ func TestBuildConfig(t *testing.T) {
212213}
213214
214215func TestCipherSuitePreference (t * testing.T ) {
216+ tmpCaBundle , err := ioutil .TempFile ("" , "ghostunnel-test" )
217+ panicOnError (err )
218+
219+ tmpCaBundle .WriteString (testCertificate )
220+ tmpCaBundle .WriteString ("\n " )
221+
222+ tmpCaBundle .Sync ()
223+ defer os .Remove (tmpCaBundle .Name ())
224+
215225 * enabledCipherSuites = "XYZ"
216- conf , err := buildConfig ("" )
226+ conf , err := buildConfig (tmpCaBundle . Name () )
217227 assert .NotNil (t , err , "should not be able to build TLS config with invalid cipher suite option" )
218228
219229 * enabledCipherSuites = ""
220- conf , err = buildConfig ("" )
230+ conf , err = buildConfig (tmpCaBundle . Name () )
221231 assert .NotNil (t , err , "should not be able to build TLS config wihout cipher suite selection" )
222232
223233 * enabledCipherSuites = "CHACHA,AES"
224- conf , err = buildConfig ("" )
234+ conf , err = buildConfig (tmpCaBundle . Name () )
225235 assert .Nil (t , err , "should be able to build TLS config" )
226236 assert .True (t , conf .CipherSuites [0 ] == tls .TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 , "expecting ChaCha20" )
227237
228238 * enabledCipherSuites = "AES,CHACHA"
229- conf , err = buildConfig ("" )
239+ conf , err = buildConfig (tmpCaBundle . Name () )
230240 assert .Nil (t , err , "should be able to build TLS config" )
231241 assert .True (t , conf .CipherSuites [0 ] == tls .TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 , "expecting AES" )
232242}
@@ -247,6 +257,11 @@ func TestReload(t *testing.T) {
247257}
248258
249259func TestBuildConfigSystemRoots (t * testing.T ) {
260+ if runtime .GOOS == "windows" {
261+ // System roots are not supported on Windows
262+ t .SkipNow ()
263+ return
264+ }
250265 conf , err := buildConfig ("" )
251266 assert .Nil (t , err , "should be able to build TLS config" )
252267 assert .NotNil (t , conf .RootCAs , "config must have CA certs" )
0 commit comments