mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-15 17:17:02 +02:00
Linting and fix unit tests
This commit is contained in:
parent
733cc53f91
commit
7681cc4f0b
4 changed files with 65 additions and 68 deletions
|
@ -117,26 +117,7 @@ class Client(oic.Client):
|
|||
|
||||
logger.debug("request args: %s" % request_args)
|
||||
|
||||
try:
|
||||
# prepare the request for sending
|
||||
cis = self.construct_AuthorizationRequest(request_args=request_args)
|
||||
logger.debug("request: %s" % cis)
|
||||
|
||||
# obtain the url and headers from the prepared request
|
||||
url, body, headers, cis = self.uri_and_body(
|
||||
AuthorizationRequest,
|
||||
cis,
|
||||
method="GET",
|
||||
request_args=request_args,
|
||||
)
|
||||
|
||||
logger.debug("body: %s" % body)
|
||||
logger.debug("URL: %s" % url)
|
||||
logger.debug("headers: %s" % headers)
|
||||
except Exception as err:
|
||||
logger.error(err)
|
||||
logger.error("Failed to prepare request for %s" % state)
|
||||
raise o_e.InternalError(locator=state)
|
||||
url, headers = self._prepare_authn_request(request_args, state) # C901 too complex
|
||||
|
||||
try:
|
||||
# create the redirect object
|
||||
|
@ -159,6 +140,35 @@ class Client(oic.Client):
|
|||
request_args["vtr"] = self.get_vtr_value()
|
||||
request_args["vtm"] = self.get_vtm_value()
|
||||
|
||||
def _prepare_authn_request(self, request_args, state):
|
||||
"""
|
||||
Constructs an authorization request. Then, assembles the url, body, headers, and cis.
|
||||
|
||||
Returns the assembled url and associated header information: `(url, headers)`
|
||||
"""
|
||||
try:
|
||||
# prepare the request for sending
|
||||
cis = self.construct_AuthorizationRequest(request_args=request_args)
|
||||
logger.debug("request: %s" % cis)
|
||||
|
||||
# obtain the url and headers from the prepared request
|
||||
url, body, headers, cis = self.uri_and_body(
|
||||
AuthorizationRequest,
|
||||
cis,
|
||||
method="GET",
|
||||
request_args=request_args,
|
||||
)
|
||||
|
||||
logger.debug("body: %s" % body)
|
||||
logger.debug("URL: %s" % url)
|
||||
logger.debug("headers: %s" % headers)
|
||||
except Exception as err:
|
||||
logger.error(err)
|
||||
logger.error("Failed to prepare request for %s" % state)
|
||||
raise o_e.InternalError(locator=state)
|
||||
|
||||
return (url, headers)
|
||||
|
||||
def callback(self, unparsed_response, session):
|
||||
"""Step 3: Receive OP's response, request an access token, and user info."""
|
||||
logger.debug("Processing the OpenID Connect callback response...")
|
||||
|
@ -311,7 +321,7 @@ class Client(oic.Client):
|
|||
"""Returns the vtm value from settings.
|
||||
This helper function is called from djangooidc views."""
|
||||
return self.behaviour.get("vtm")
|
||||
|
||||
|
||||
def get_vtr_value(self, cleaned=True):
|
||||
"""Returns the vtr value from settings.
|
||||
This helper function is called from djangooidc views."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue