MCPcopy
hub / github.com/helm/helm / TestDownloadTo_TLS

Function TestDownloadTo_TLS

pkg/downloader/chart_downloader_test.go:246–304  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

244}
245
246func 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 }

Callers

nothing calls this directly

Calls 13

DownloadToMethod · 0.95
NewTempServerFunction · 0.92
WithChartSourceGlobFunction · 0.92
WithTLSConfigFunction · 0.92
MakeTestTLSConfigFunction · 0.92
AllFunction · 0.92
WithTLSClientConfigFunction · 0.92
StopMethod · 0.80
CreateIndexMethod · 0.80
FatalMethod · 0.80
LinkIndicesMethod · 0.80
RootMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…