Skip to content

add Copy as Python Requests #6871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
add test case for cookie parse
  • Loading branch information
Nriver committed May 23, 2024
commit 76be4bf6e95a6a30650234b7a1e223f00160dea6
15 changes: 12 additions & 3 deletions test/mitmproxy/addons/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,25 @@ def test_correct_host_used(self, get_request):


class TestExportPythonRequestsCommand:
def test_get(self, export_curl, get_request):
def test_get(self, get_request):
# test cookie
get_request.request.cookies = [
("cookie", "chocolate_chip"),
("session_id", "abc123"),
("user_id", "987654321")
]
result = (
"import requests\n"
"\n"
'url = "http://address:22/path?a=foo&a=bar&b=baz"\n'
"headers = {\n"
' "header": "qvalue",\n'
"}\n"
"cookies = {}\n"
"\n"
'cookies = {\n'
' "cookie": "chocolate_chip",\n'
' "session_id": "abc123",\n'
' "user_id": "987654321;",\n'
'}\n'
"body = None\n"
'res = requests.request(method="GET", url=url, headers=headers, '
"cookies=cookies, data=body)\n"
Expand Down