Moved the _get_req_auth function into the test client class, and renamed it to __make_authorization.
This commit is contained in:
parent
ca22b9731c
commit
515098c32a
@ -49,15 +49,15 @@ class Client(WerkzeugClient):
|
|||||||
return response
|
return response
|
||||||
if hasattr(g, "_login_user"):
|
if hasattr(g, "_login_user"):
|
||||||
delattr(g, "_login_user")
|
delattr(g, "_login_user")
|
||||||
auth_data: Authorization = _get_req_auth(
|
auth_data: Authorization = self.__class__.__make_authorization(
|
||||||
www_authenticate, args[0], digest_auth[0], digest_auth[1])
|
www_authenticate, args[0], digest_auth[0], digest_auth[1])
|
||||||
response = super(Client, self).open(*args, auth=auth_data, **kwargs)
|
response = super(Client, self).open(*args, auth=auth_data, **kwargs)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
def _get_req_auth(www_authenticate: WWWAuthenticate, uri: str,
|
def __make_authorization(www_authenticate: WWWAuthenticate, uri: str,
|
||||||
username: str, password: str) -> Authorization:
|
username: str, password: str) -> Authorization:
|
||||||
"""Returns the request authorization from the response header.
|
"""Composes and returns the request authorization.
|
||||||
|
|
||||||
:param www_authenticate: The WWW-Authenticate response.
|
:param www_authenticate: The WWW-Authenticate response.
|
||||||
:param uri: The request URI.
|
:param uri: The request URI.
|
||||||
@ -83,7 +83,8 @@ def _get_req_auth(www_authenticate: WWWAuthenticate, uri: str,
|
|||||||
password_hash=make_password_hash(www_authenticate.realm,
|
password_hash=make_password_hash(www_authenticate.realm,
|
||||||
username, password),
|
username, password),
|
||||||
nonce=www_authenticate.nonce, qop=qop,
|
nonce=www_authenticate.nonce, qop=qop,
|
||||||
algorithm=www_authenticate.algorithm, cnonce=cnonce, nc=nc, body=None)
|
algorithm=www_authenticate.algorithm, cnonce=cnonce, nc=nc,
|
||||||
|
body=None)
|
||||||
|
|
||||||
data: t.Dict[str, str] = {
|
data: t.Dict[str, str] = {
|
||||||
"username": username, "realm": www_authenticate.realm,
|
"username": username, "realm": www_authenticate.realm,
|
||||||
|
Loading…
Reference in New Issue
Block a user