From f985cb54e1a5b10a9a35f3ab111b203eb4ef8811 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 20 Dec 2023 23:19:36 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- social_core/backends/okta.py | 11 ++++++----- social_core/tests/backends/test_okta.py | 22 +++++++++++++--------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/social_core/backends/okta.py b/social_core/backends/okta.py index 88abe984..2023c09f 100644 --- a/social_core/backends/okta.py +++ b/social_core/backends/okta.py @@ -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""" diff --git a/social_core/tests/backends/test_okta.py b/social_core/tests/backends/test_okta.py index bf0184f1..967d2db6 100644 --- a/social_core/tests/backends/test_okta.py +++ b/social_core/tests/backends/test_okta.py @@ -145,23 +145,27 @@ def setUp(self): oidc_config = json.loads(self.openid_config_body) 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(