(t *testing.T)
| 244 | } |
| 245 | |
| 246 | func TestDownloadTo_TLS(t *testing.T) { |
| 247 | // Set up mock server w/ tls enabled |
| 248 | srv := repotest.NewTempServer( |
| 249 | t, |
| 250 | repotest.WithChartSourceGlob("testdata/*.tgz*"), |
| 251 | repotest.WithTLSConfig(repotest.MakeTestTLSConfig(t, "../../testdata")), |
| 252 | ) |
| 253 | defer srv.Stop() |
| 254 | if err := srv.CreateIndex(); err != nil { |
| 255 | t.Fatal(err) |
| 256 | } |
| 257 | if err := srv.LinkIndices(); err != nil { |
| 258 | t.Fatal(err) |
| 259 | } |
| 260 | |
| 261 | repoConfig := filepath.Join(srv.Root(), "repositories.yaml") |
| 262 | repoCache := srv.Root() |
| 263 | contentCache := t.TempDir() |
| 264 | |
| 265 | c := ChartDownloader{ |
| 266 | Out: os.Stderr, |
| 267 | Verify: VerifyAlways, |
| 268 | Keyring: "testdata/helm-test-key.pub", |
| 269 | RepositoryConfig: repoConfig, |
| 270 | RepositoryCache: repoCache, |
| 271 | ContentCache: contentCache, |
| 272 | Getters: getter.All(&cli.EnvSettings{ |
| 273 | RepositoryConfig: repoConfig, |
| 274 | RepositoryCache: repoCache, |
| 275 | ContentCache: contentCache, |
| 276 | }), |
| 277 | Options: []getter.Option{ |
| 278 | getter.WithTLSClientConfig( |
| 279 | "", |
| 280 | "", |
| 281 | filepath.Join("../../testdata/rootca.crt"), |
| 282 | ), |
| 283 | }, |
| 284 | } |
| 285 | cname := "test/signtest" |
| 286 | dest := srv.Root() |
| 287 | where, v, err := c.DownloadTo(cname, "", dest) |
| 288 | if err != nil { |
| 289 | t.Fatal(err) |
| 290 | } |
| 291 | |
| 292 | target := filepath.Join(dest, "signtest-0.1.0.tgz") |
| 293 | if expect := target; where != expect { |
| 294 | t.Errorf("Expected download to %s, got %s", expect, where) |
| 295 | } |
| 296 | |
| 297 | if v.FileHash == "" { |
| 298 | t.Error("File hash was empty, but verification is required.") |
| 299 | } |
| 300 | |
| 301 | if _, err := os.Stat(target); err != nil { |
| 302 | t.Error(err) |
| 303 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…