Skip to content

Commit

Permalink
test: Add test for custom Docker config headers (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmidyson committed Jun 5, 2023
1 parent 3db704c commit 353d0b6
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/e2e/imagebundle/push_bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import (
"fmt"
"net"
"net/http/httptest"
"os"
"path/filepath"
"runtime"
"strconv"

"github.com/docker/cli/cli/config"
"github.com/elazarl/goproxy"
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/remote"
Expand Down Expand Up @@ -188,4 +190,31 @@ var _ = Describe("Push Bundle", func() {

runTest(helpers.GetFirstNonLoopbackIP(GinkgoT()).String(), "", false)
})

It("Success using a proxy and headers from Docker config", Serial, func() {
proxy := goproxy.NewProxyHttpServer()
proxy.Verbose = true
proxy.Logger = GinkgoWriter

proxyServer := httptest.NewServer(proxy)
defer proxyServer.Close()

GinkgoT().Setenv("http_proxy", proxyServer.URL)
GinkgoT().Setenv("https_proxy", proxyServer.URL)

runTest(helpers.GetFirstNonLoopbackIP(GinkgoT()).String(), "", false)

dockerConfigDir := GinkgoT().TempDir()
GinkgoT().Setenv("DOCKER_CONFIG", dockerConfigDir)
err := os.WriteFile(
filepath.Join(dockerConfigDir, config.ConfigFileName),
[]byte(`{
"HttpHeaders": {
"MyHeader": "MyValue"
}
}`),
0o644,
)
Expect(err).ToNot(HaveOccurred())
})
})

0 comments on commit 353d0b6

Please sign in to comment.