MCPcopy Create free account
hub / github.com/blacklanternsecurity/bbot / test_http_proxy

Function test_http_proxy

bbot/test/test_step_1/test_web.py:396–417  ·  view source on GitHub ↗
(bbot_scanner, bbot_httpserver, proxy_server)

Source from the content-addressed store, hash-verified

394
395@pytest.mark.asyncio
396async 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

Callers

nothing calls this directly

Calls 3

bbot_scannerFunction · 0.85
requestMethod · 0.45
_cleanupMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…