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

pytest_plugin: Add generic keycloak_oidc fixture instantiation

This will simplify fixture use in external modules that use the
pytest plugin.
parent 88e7075a
No related branches found
No related tags found
1 merge request!16pytest_plugin: Add generic keycloak_oidc fixture instantiation
......@@ -13,7 +13,14 @@ from keycloak.exceptions import KeycloakError
import pytest
from swh.auth.keycloak import KeycloakOpenIDConnect
from swh.auth.tests.sample_data import OIDC_PROFILE, RAW_REALM_PUBLIC_KEY, USER_INFO
from swh.auth.tests.sample_data import (
CLIENT_ID,
OIDC_PROFILE,
RAW_REALM_PUBLIC_KEY,
REALM_NAME,
SERVER_URL,
USER_INFO,
)
class KeycloackOpenIDConnectMock(KeycloakOpenIDConnect):
......@@ -193,3 +200,10 @@ def keycloak_oidc_factory(
# for backward compatibility
# TODO: remove that alias once swh-deposit and swh-web use new function name
keycloak_mock_factory = keycloak_oidc_factory
# generic keycloak fixture that can be used within tests
# (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,
)
# Copyright (C) 2021 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU Affero General Public License version 3, or any later version
# See top-level LICENSE file for more information
from swh.auth.pytest_plugin import keycloak_oidc_factory
from swh.auth.tests.sample_data import CLIENT_ID, REALM_NAME, SERVER_URL
# keycloak fixture used within tests (cf. test_keycloak.py, test_utils.py)
keycloak_oidc = keycloak_oidc_factory(
server_url=SERVER_URL, realm_name=REALM_NAME, client_id=CLIENT_ID,
)
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