MCPcopy
hub / github.com/snyk/cli / Test_canGoThroughProxy

Function Test_canGoThroughProxy

cliv2/internal/proxy/proxy_test.go:107–139  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

105}
106
107func Test_canGoThroughProxy(t *testing.T) {
108 basecache := "testcache"
109 version := "1.1.1"
110
111 config := setup(t, basecache, version)
112 defer teardown(t, basecache)
113
114 config.Set(configuration.INSECURE_HTTPS, false)
115
116 wp, err := proxy.NewWrapperProxy(config, version, &debugLogger, caData)
117 assert.Nil(t, err)
118
119 err = wp.Start()
120 assert.Nil(t, err)
121
122 useProxyAuth := true
123 proxiedClient, err := helper_getHttpClient(wp, useProxyAuth)
124 assert.Nil(t, err)
125
126 res, err := proxiedClient.Get("https://downloads.snyk.io/cli/latest/version")
127 if err != nil {
128 t.Fatal(err)
129 }
130 defer func() {
131 if res != nil && res.Body != nil {
132 _ = res.Body.Close()
133 }
134 }()
135
136 assert.Equal(t, 200, res.StatusCode)
137
138 wp.Close()
139}
140
141func Test_proxyRejectsWithoutBasicAuthHeader(t *testing.T) {
142 basecache := "testcache"

Callers

nothing calls this directly

Calls 5

StartMethod · 0.95
CloseMethod · 0.95
teardownFunction · 0.85
helper_getHttpClientFunction · 0.85
setupFunction · 0.70

Tested by

no test coverage detected