|
6 | 6 | "time" |
7 | 7 |
|
8 | 8 | "github.com/databricks/databricks-sql-go/auth/pat" |
| 9 | + "github.com/databricks/databricks-sql-go/internal/client" |
9 | 10 | "github.com/databricks/databricks-sql-go/internal/config" |
| 11 | + "github.com/hashicorp/go-retryablehttp" |
10 | 12 | "github.com/stretchr/testify/assert" |
11 | 13 | "github.com/stretchr/testify/require" |
12 | 14 | ) |
@@ -38,6 +40,7 @@ func TestNewConnector(t *testing.T) { |
38 | 40 | WithTransport(roundTripper), |
39 | 41 | WithCloudFetch(true), |
40 | 42 | WithMaxDownloadThreads(15), |
| 43 | + WithSkipTLSHostVerify(), |
41 | 44 | ) |
42 | 45 | expectedCloudFetchConfig := config.CloudFetchConfig{ |
43 | 46 | UseCloudFetch: true, |
@@ -67,6 +70,7 @@ func TestNewConnector(t *testing.T) { |
67 | 70 | expectedCfg := config.WithDefaults() |
68 | 71 | expectedCfg.DriverVersion = DriverVersion |
69 | 72 | expectedCfg.UserConfig = expectedUserConfig |
| 73 | + expectedCfg.TLSConfig.InsecureSkipVerify = true |
70 | 74 | coni, ok := con.(*connector) |
71 | 75 | require.True(t, ok) |
72 | 76 | assert.Nil(t, err) |
@@ -184,6 +188,28 @@ func TestNewConnector(t *testing.T) { |
184 | 188 | } |
185 | 189 |
|
186 | 190 | }) |
| 191 | + |
| 192 | + t.Run("Connector test WithSkipTLSHostVerify with PoolClient", func(t *testing.T) { |
| 193 | + hostname := "databricks-host" |
| 194 | + con, err := NewConnector( |
| 195 | + WithServerHostname(hostname), |
| 196 | + WithSkipTLSHostVerify(), |
| 197 | + ) |
| 198 | + assert.Nil(t, err) |
| 199 | + |
| 200 | + coni, ok := con.(*connector) |
| 201 | + require.True(t, ok) |
| 202 | + userConfig := coni.cfg.UserConfig |
| 203 | + require.Equal(t, hostname, userConfig.Host) |
| 204 | + |
| 205 | + httpClient, ok := coni.client.Transport.(*retryablehttp.RoundTripper) |
| 206 | + require.True(t, ok) |
| 207 | + poolClient, ok := httpClient.Client.HTTPClient.Transport.(*client.Transport) |
| 208 | + require.True(t, ok) |
| 209 | + internalClient, ok := poolClient.Base.(*http.Transport) |
| 210 | + require.True(t, ok) |
| 211 | + require.True(t, internalClient.TLSClientConfig.InsecureSkipVerify) |
| 212 | + }) |
187 | 213 | } |
188 | 214 |
|
189 | 215 | type mockRoundTripper struct{} |
|
0 commit comments