Skip to content
Snippets Groups Projects
Commit a30d9355 authored by Antoine Lambert's avatar Antoine Lambert
Browse files

python: Reformat code with black 22.3.0

Related to T3922
parent 8b675b0b
No related branches found
No related tags found
No related merge requests found
......@@ -41,7 +41,9 @@ class KeycloakOpenIDConnect:
retrieved if not provided)
"""
self._keycloak = KeycloakOpenID(
server_url=server_url, client_id=client_id, realm_name=realm_name,
server_url=server_url,
client_id=client_id,
realm_name=realm_name,
)
self.server_url = server_url
self.realm_public_key = realm_public_key
......@@ -230,9 +232,7 @@ class KeycloakOpenIDConnect:
def keycloak_error_message(keycloak_error: KeycloakError) -> str:
"""Transform a keycloak exception into an error message.
"""
"""Transform a keycloak exception into an error message."""
try:
# keycloak error wrapped in a JSON document
msg_dict = json.loads(keycloak_error.error_message.decode())
......
......@@ -59,8 +59,7 @@ class KeycloackOpenIDConnectMock(KeycloakOpenIDConnect):
user_info: Dict = USER_INFO,
raw_realm_public_key: str = RAW_REALM_PUBLIC_KEY,
):
"""Constructor
"""
"""Constructor"""
super().__init__(
server_url=server_url, realm_name=realm_name, client_id=client_id
)
......@@ -182,7 +181,7 @@ def keycloak_oidc_factory(
raw_realm_public_key: str = RAW_REALM_PUBLIC_KEY,
):
"""Keycloak mock fixture factory. Report to
:py:class:`swh.auth.pytest_plugin.KeycloackOpenIDConnectMock` docstring.
:py:class:`swh.auth.pytest_plugin.KeycloackOpenIDConnectMock` docstring.
"""
......@@ -213,7 +212,9 @@ keycloak_mock_factory = keycloak_oidc_factory
# (cf. test_keycloak.py, test_utils.py, django related tests)
# or external modules using that pytest plugin
_keycloak_oidc = keycloak_oidc_factory(
server_url=SERVER_URL, realm_name=REALM_NAME, client_id=CLIENT_ID,
server_url=SERVER_URL,
realm_name=REALM_NAME,
client_id=CLIENT_ID,
)
......
......@@ -28,7 +28,10 @@ MIDDLEWARE = [
ROOT_URLCONF = "swh.auth.tests.django.app.apptest.urls"
DATABASES = {
"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": "swh-auth-test-db",}
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": "swh-auth-test-db",
}
}
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
......
......@@ -99,7 +99,9 @@ def test_oidc_user_from_profile(keycloak_oidc):
@override_settings(
SWH_AUTH_SERVER_URL=None, SWH_AUTH_REALM_NAME=None, SWH_AUTH_CLIENT_ID=None,
SWH_AUTH_SERVER_URL=None,
SWH_AUTH_REALM_NAME=None,
SWH_AUTH_CLIENT_ID=None,
)
def test_keycloak_oidc_client_missing_django_settings():
......
......@@ -116,9 +116,7 @@ def auth_config_path(tmp_path, monkeypatch, auth_config):
def test_auth_KeycloakOpenIDConnect_from_config(auth_config):
"""Instantiating keycloak client out of configuration dict is possible
"""
"""Instantiating keycloak client out of configuration dict is possible"""
client = KeycloakOpenIDConnect.from_config(**auth_config)
assert client.server_url == auth_config["keycloak"]["server_url"]
......@@ -127,9 +125,7 @@ def test_auth_KeycloakOpenIDConnect_from_config(auth_config):
def test_auth_KeycloakOpenIDConnect_from_configfile(auth_config_path, monkeypatch):
"""Instantiating keycloak client out of environment variable is possible
"""
"""Instantiating keycloak client out of environment variable is possible"""
client = KeycloakOpenIDConnect.from_configfile()
auth_config = read(auth_config_path)
......@@ -145,7 +141,7 @@ def test_auth_KeycloakOpenIDConnect_from_configfile_override(
"""Instantiating keycloak client out of environment variable is possible
And caller can override the configuration at calling
"""
"""
client = KeycloakOpenIDConnect.from_configfile(client_id="foobar")
auth_config = read(auth_config_path)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment