MCPcopy Index your code
hub / github.com/python/cpython / _validate_auth

Method _validate_auth

Lib/test/test_urllib2_localnet.py:127–143  ·  view source on GitHub ↗
(self, auth_dict, password, method, uri)

Source from the content-addressed store, hash-verified

125 return auth_dict
126
127 def _validate_auth(self, auth_dict, password, method, uri):
128 final_dict = {}
129 final_dict.update(auth_dict)
130 final_dict["password"] = password
131 final_dict["method"] = method
132 final_dict["uri"] = uri
133 HA1_str = "%(username)s:%(realm)s:%(password)s" % final_dict
134 HA1 = hashlib.md5(HA1_str.encode("ascii")).hexdigest()
135 HA2_str = "%(method)s:%(uri)s" % final_dict
136 HA2 = hashlib.md5(HA2_str.encode("ascii")).hexdigest()
137 final_dict["HA1"] = HA1
138 final_dict["HA2"] = HA2
139 response_str = "%(HA1)s:%(nonce)s:%(nc)s:" \
140 "%(cnonce)s:%(qop)s:%(HA2)s" % final_dict
141 response = hashlib.md5(response_str.encode("ascii")).hexdigest()
142
143 return response == auth_dict["response"]
144
145 def _return_auth_challenge(self, request_handler):
146 request_handler.send_response(407, "Proxy Authentication Required")

Callers 1

handle_requestMethod · 0.95

Calls 3

hexdigestMethod · 0.80
updateMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected