(t *testing.T)
| 284 | } |
| 285 | |
| 286 | func TestDoubleEncodingSendsEncodedPaths(t *testing.T) { |
| 287 | resetTestState() |
| 288 | |
| 289 | ts, getRequests := testServer(t, nil) |
| 290 | defer ts.Close() |
| 291 | |
| 292 | opts := RequestOptions{ |
| 293 | uri: ts.URL + "/admin", |
| 294 | headers: []header{{"User-Agent", "test"}}, |
| 295 | method: "GET", |
| 296 | proxy: &url.URL{}, |
| 297 | timeout: 5000, |
| 298 | rateLimit: false, |
| 299 | redirect: false, |
| 300 | verbose: true, |
| 301 | } |
| 302 | |
| 303 | requestDoubleEncoding(opts) |
| 304 | |
| 305 | reqs := getRequests() |
| 306 | if len(reqs) == 0 { |
| 307 | t.Fatal("expected double-encoding requests to be sent, got 0") |
| 308 | } |
| 309 | |
| 310 | // Double-encoded paths should contain percent-encoded characters |
| 311 | foundEncoded := false |
| 312 | for _, r := range reqs { |
| 313 | raw := r.URL.RawPath |
| 314 | if raw == "" { |
| 315 | raw = r.URL.Path |
| 316 | } |
| 317 | if strings.Contains(raw, "%25") || strings.Contains(raw, "%") { |
| 318 | foundEncoded = true |
| 319 | break |
| 320 | } |
| 321 | } |
| 322 | if !foundEncoded { |
| 323 | t.Error("expected at least one request with double-encoded path characters") |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | func TestPathCaseSwitchingSendsVariations(t *testing.T) { |
| 328 | resetTestState() |
nothing calls this directly
no test coverage detected