MCPcopy
hub / github.com/helm/helm / TestHTTPGetterTarDownload

Function TestHTTPGetterTarDownload

pkg/getter/httpgetter_test.go:516–550  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

514}
515
516func TestHTTPGetterTarDownload(t *testing.T) {
517 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
518 f, _ := os.Open("testdata/empty-0.0.1.tgz")
519 defer f.Close()
520
521 b := make([]byte, 512)
522 f.Read(b)
523 // Get the file size
524 FileStat, _ := f.Stat()
525 FileSize := strconv.FormatInt(FileStat.Size(), 10)
526
527 // Simulating improper header values from bitbucket
528 w.Header().Set("Content-Type", "application/x-tar")
529 w.Header().Set("Content-Encoding", "gzip")
530 w.Header().Set("Content-Length", FileSize)
531
532 f.Seek(0, 0)
533 io.Copy(w, f)
534 }))
535
536 defer srv.Close()
537
538 g, err := NewHTTPGetter(WithURL(srv.URL))
539 if err != nil {
540 t.Fatal(err)
541 }
542
543 data, _ := g.Get(srv.URL)
544 mimeType := http.DetectContentType(data.Bytes())
545
546 expectedMimeType := "application/x-gzip"
547 if mimeType != expectedMimeType {
548 t.Fatalf("Expected response with MIME type %s, but got %s", expectedMimeType, mimeType)
549 }
550}
551
552func TestHttpClientInsecureSkipVerify(t *testing.T) {
553 g := HTTPGetter{}

Callers

nothing calls this directly

Calls 9

GetMethod · 0.95
NewHTTPGetterFunction · 0.85
WithURLFunction · 0.85
CloseMethod · 0.80
CopyMethod · 0.80
FatalMethod · 0.80
FatalfMethod · 0.80
ReadMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…