MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_socks5_auth_success

Function test_socks5_auth_success

test/mitmproxy/proxy/layers/test_modes.py:490–521  ·  view source on GitHub ↗
(
    client_greeting: bytes,
    server_choice: bytes,
    client_auth: bytes,
    server_resp: bytes,
    address: bytes,
    packed: bytes,
    tctx: Context,
)

Source from the content-addressed store, hash-verified

488 ],
489)
490def test_socks5_auth_success(
491 client_greeting: bytes,
492 server_choice: bytes,
493 client_auth: bytes,
494 server_resp: bytes,
495 address: bytes,
496 packed: bytes,
497 tctx: Context,
498):
499 ProxyAuth().load(tctx.options)
500 tctx.options.proxyauth = "user:password"
501 server = Placeholder(Server)
502 nextlayer = Placeholder(NextLayer)
503 playbook = (
504 Playbook(modes.Socks5Proxy(tctx), logs=True)
505 >> DataReceived(tctx.client, client_greeting)
506 << SendData(tctx.client, server_choice)
507 >> DataReceived(tctx.client, client_auth)
508 << modes.Socks5AuthHook(Placeholder(modes.Socks5AuthData))
509 >> reply(side_effect=_valid_socks_auth)
510 << SendData(tctx.client, server_resp)
511 >> DataReceived(
512 tctx.client, b"\x05\x01\x00" + packed + b"\x12\x34applicationdata"
513 )
514 << OpenConnection(server)
515 >> reply(None)
516 << SendData(tctx.client, b"\x05\x00\x00\x01\x00\x00\x00\x00\x00\x00")
517 << NextLayerHook(nextlayer)
518 )
519 assert playbook
520 assert server().address == (address, 0x1234)
521 assert nextlayer().data_client() == b"applicationdata"
522
523
524@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 10

ProxyAuthClass · 0.90
PlaceholderFunction · 0.90
PlaybookClass · 0.90
DataReceivedClass · 0.90
SendDataClass · 0.90
replyClass · 0.90
OpenConnectionClass · 0.90
NextLayerHookClass · 0.90
data_clientMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…