(t *testing.T)
| 203 | } |
| 204 | |
| 205 | func 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 | |
| 222 | func TestDownloadFile_BlockPrivateTargetsBlocksRedirectToLoopback(t *testing.T) { |
| 223 | target := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected