test_basicauth_with_netrc_leak() — requests Function Reference
Architecture documentation for the test_basicauth_with_netrc_leak() function in test_requests.py from the requests codebase.
Entity Profile
Dependency Diagram
graph TD 6bb9da6b_e000_6f0c_a66e_ce5afb53c072["test_basicauth_with_netrc_leak()"] 22b80b19_26d4_cd0e_c476_3edf87b3df14["TestRequests"] 6bb9da6b_e000_6f0c_a66e_ce5afb53c072 -->|defined in| 22b80b19_26d4_cd0e_c476_3edf87b3df14 style 6bb9da6b_e000_6f0c_a66e_ce5afb53c072 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_requests.py lines 710–738
def test_basicauth_with_netrc_leak(self, httpbin):
url1 = httpbin("basic-auth", "user", "pass")
url = url1[len("http://") :]
domain = url.split(":")[0]
url = f"http://example.com:@{url}"
netrc_file = ""
with tempfile.NamedTemporaryFile(mode="w", delete=False) as fp:
fp.write("machine example.com\n")
fp.write("login wronguser\n")
fp.write("password wrongpass\n")
fp.write(f"machine {domain}\n")
fp.write("login user\n")
fp.write("password pass\n")
fp.close()
netrc_file = fp.name
old_netrc = os.environ.get("NETRC", "")
os.environ["NETRC"] = netrc_file
try:
# Should use netrc
# Make sure that we don't use the example.com credentails
# for the request
r = requests.get(url)
assert r.status_code == 200
finally:
os.environ["NETRC"] = old_netrc
os.unlink(netrc_file)
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_basicauth_with_netrc_leak() do?
test_basicauth_with_netrc_leak() is a function in the requests codebase, defined in tests/test_requests.py.
Where is test_basicauth_with_netrc_leak() defined?
test_basicauth_with_netrc_leak() is defined in tests/test_requests.py at line 710.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free