MCPcopy
hub / github.com/sipeed/picoclaw / TestDownloadFile_DefaultAllowsLoopbackURL

Function TestDownloadFile_DefaultAllowsLoopbackURL

pkg/utils/http_guard_test.go:205–220  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

203}
204
205func TestDownloadFile_DefaultAllowsLoopbackURL(t *testing.T) {
206 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
207 w.WriteHeader(http.StatusOK)
208 _, _ = w.Write([]byte("local download"))
209 }))
210 defer server.Close()
211
212 path := DownloadFile(server.URL, "file.txt", DownloadOptions{
213 LoggerPrefix: "test",
214 Timeout: 5 * time.Second,
215 })
216 if path == "" {
217 t.Fatal("expected default DownloadFile to allow loopback URL")
218 }
219 defer os.Remove(path)
220}
221
222func TestDownloadFile_BlockPrivateTargetsBlocksRedirectToLoopback(t *testing.T) {
223 target := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 5

DownloadFileFunction · 0.85
RemoveMethod · 0.80
CloseMethod · 0.65
WriteHeaderMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected