Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 20, 2023
1 parent b52e1d2 commit f985cb5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
11 changes: 6 additions & 5 deletions social_core/backends/okta.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,20 @@ def oidc_config_url(self):
# If the URL path does not contain an authorizedServerId, we need
# to truncate the path in order to generate a proper openid-configuration
# URL.
if url.path == '/oauth2/':
url = url._replace(path='')
if url.path == "/oauth2/":
url = url._replace(path="")

return urljoin(
urlunparse(url),
'./.well-known/openid-configuration?client_id={}'.format(
self.setting('KEY')
)
"./.well-known/openid-configuration?client_id={}".format(
self.setting("KEY")
),
)

def oidc_config(self):
return self.get_json(self.oidc_config_url())


class OktaOAuth2(OktaMixin, BaseOAuth2):
"""Okta OAuth authentication backend"""

Expand Down
22 changes: 13 additions & 9 deletions social_core/tests/backends/test_okta.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,23 +145,27 @@ def setUp(self):
oidc_config = json.loads(self.openid_config_body)

Check failure on line 145 in social_core/tests/backends/test_okta.py

View workflow job for this annotation

GitHub Actions / flake8

local variable 'oidc_config' is assigned to but never used

def jwks(_request, _uri, headers):
return 200, headers, json.dumps({'keys': [self.key]})
return 200, headers, json.dumps({"keys": [self.key]})

def test_okta_oidc_config(self):
# With no custom authorization server
self.strategy.set_settings({
'SOCIAL_AUTH_OKTA_OPENIDCONNECT_API_URL': 'https://dev-000000.oktapreview.com/oauth2',
})
self.strategy.set_settings(
{
"SOCIAL_AUTH_OKTA_OPENIDCONNECT_API_URL": "https://dev-000000.oktapreview.com/oauth2",
}
)
self.assertEqual(
self.backend.oidc_config_url(),
'https://dev-000000.oktapreview.com/.well-known/openid-configuration?client_id=a-key'
"https://dev-000000.oktapreview.com/.well-known/openid-configuration?client_id=a-key",
)
self.strategy.set_settings(
{
"SOCIAL_AUTH_OKTA_OPENIDCONNECT_API_URL": "https://dev-000000.oktapreview.com/oauth2/id-123456",
}
)
self.strategy.set_settings({
'SOCIAL_AUTH_OKTA_OPENIDCONNECT_API_URL': 'https://dev-000000.oktapreview.com/oauth2/id-123456',
})
self.assertEqual(
self.backend.oidc_config_url(),
'https://dev-000000.oktapreview.com/oauth2/id-123456/.well-known/openid-configuration?client_id=a-key'
"https://dev-000000.oktapreview.com/oauth2/id-123456/.well-known/openid-configuration?client_id=a-key",
)

HTTPretty.register_uri(
Expand Down

0 comments on commit f985cb5

Please sign in to comment.