(bbot_scanner, bbot_httpserver, proxy_server)
| 394 | |
| 395 | @pytest.mark.asyncio |
| 396 | async def test_http_proxy(bbot_scanner, bbot_httpserver, proxy_server): |
| 397 | endpoint = "/test_http_proxy" |
| 398 | url = bbot_httpserver.url_for(endpoint) |
| 399 | # test user agent + custom headers |
| 400 | bbot_httpserver.expect_request(uri=endpoint).respond_with_data("test_http_proxy_yep") |
| 401 | |
| 402 | proxy_address = f"http://127.0.0.1:{proxy_server.server_address[1]}" |
| 403 | |
| 404 | scan = bbot_scanner("127.0.0.1", config={"web": {"http_proxy": proxy_address}}) |
| 405 | |
| 406 | assert len(proxy_server.RequestHandlerClass.urls) == 0 |
| 407 | |
| 408 | r = await scan.helpers.request(url) |
| 409 | |
| 410 | assert len(proxy_server.RequestHandlerClass.urls) == 1, ( |
| 411 | f"Request to {url} did not go through proxy {proxy_address}" |
| 412 | ) |
| 413 | visited_url = proxy_server.RequestHandlerClass.urls[0] |
| 414 | assert visited_url.endswith(endpoint), f"There was a problem with request to {url}: {visited_url}" |
| 415 | assert r.status_code == 200 and r.text == "test_http_proxy_yep" |
| 416 | |
| 417 | await scan._cleanup() |
| 418 | |
| 419 | |
| 420 | @pytest.mark.asyncio |
nothing calls this directly
no test coverage detected
searching dependent graphs…