Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9124390
D5335.id19131.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Subscribers
None
D5335.id19131.diff
View Options
diff --git a/swh/auth/pytest_plugin.py b/swh/auth/pytest_plugin.py
--- a/swh/auth/pytest_plugin.py
+++ b/swh/auth/pytest_plugin.py
@@ -155,7 +155,7 @@
self.login.side_effect = exception
-def keycloak_mock_factory(
+def keycloak_oidc_factory(
server_url: str,
realm_name: str,
client_id: str,
@@ -173,7 +173,7 @@
"""
@pytest.fixture
- def keycloak_open_id_connect():
+ def keycloak_oidc():
return KeycloackOpenIDConnectMock(
server_url=server_url,
realm_name=realm_name,
@@ -187,4 +187,9 @@
raw_realm_public_key=raw_realm_public_key,
)
- return keycloak_open_id_connect
+ return keycloak_oidc
+
+
+# for backward compatibility
+# TODO: remove that alias once swh-deposit and swh-web use new function name
+keycloak_mock_factory = keycloak_oidc_factory
diff --git a/swh/auth/tests/conftest.py b/swh/auth/tests/conftest.py
--- a/swh/auth/tests/conftest.py
+++ b/swh/auth/tests/conftest.py
@@ -4,10 +4,10 @@
# See top-level LICENSE file for more information
-from swh.auth.pytest_plugin import keycloak_mock_factory
+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_mock = keycloak_mock_factory(
+keycloak_oidc = keycloak_oidc_factory(
server_url=SERVER_URL, realm_name=REALM_NAME, client_id=CLIENT_ID,
)
diff --git a/swh/auth/tests/django/test_utils.py b/swh/auth/tests/django/test_utils.py
--- a/swh/auth/tests/django/test_utils.py
+++ b/swh/auth/tests/django/test_utils.py
@@ -92,8 +92,8 @@
assert getattr(user, mapped_key) == ""
-def test_oidc_user_from_profile(keycloak_mock):
- user = oidc_user_from_profile(keycloak_mock, OIDC_PROFILE)
+def test_oidc_user_from_profile(keycloak_oidc):
+ user = oidc_user_from_profile(keycloak_oidc, OIDC_PROFILE)
_check_user(user)
diff --git a/swh/auth/tests/test_keycloak.py b/swh/auth/tests/test_keycloak.py
--- a/swh/auth/tests/test_keycloak.py
+++ b/swh/auth/tests/test_keycloak.py
@@ -17,8 +17,8 @@
from swh.core.config import read
-def test_keycloak_well_known(keycloak_mock):
- well_known_result = keycloak_mock.well_known()
+def test_keycloak_oidc_well_known(keycloak_oidc):
+ well_known_result = keycloak_oidc.well_known()
assert set(well_known_result.keys()) == {
"issuer",
"authorization_endpoint",
@@ -30,10 +30,10 @@
}
-def test_keycloak_authorization_url(keycloak_mock):
- actual_auth_uri = keycloak_mock.authorization_url("http://redirect-uri", foo="bar")
+def test_keycloak_oidc_authorization_url(keycloak_oidc):
+ actual_auth_uri = keycloak_oidc.authorization_url("http://redirect-uri", foo="bar")
- expected_auth_url = keycloak_mock.well_known()["authorization_endpoint"]
+ expected_auth_url = keycloak_oidc.well_known()["authorization_endpoint"]
parsed_result = urlparse(actual_auth_uri)
assert expected_auth_url.endswith(parsed_result.path)
@@ -46,40 +46,40 @@
}
-def test_keycloak_authorization_code_fail(keycloak_mock):
+def test_keycloak_oidc_authorization_code_fail(keycloak_oidc):
"Authorization failure raise error"
# Simulate failed authentication with Keycloak
- keycloak_mock.set_auth_success(False)
+ keycloak_oidc.set_auth_success(False)
with pytest.raises(KeycloakError):
- keycloak_mock.authorization_code("auth-code", "redirect-uri")
+ keycloak_oidc.authorization_code("auth-code", "redirect-uri")
with pytest.raises(KeycloakError):
- keycloak_mock.login("username", "password")
+ keycloak_oidc.login("username", "password")
-def test_keycloak_authorization_code(keycloak_mock):
- actual_response = keycloak_mock.authorization_code("auth-code", "redirect-uri")
+def test_keycloak_oidc_authorization_code(keycloak_oidc):
+ actual_response = keycloak_oidc.authorization_code("auth-code", "redirect-uri")
assert actual_response == OIDC_PROFILE
-def test_keycloak_refresh_token(keycloak_mock):
- actual_result = keycloak_mock.refresh_token("refresh-token")
+def test_keycloak_oidc_refresh_token(keycloak_oidc):
+ actual_result = keycloak_oidc.refresh_token("refresh-token")
assert actual_result == OIDC_PROFILE
-def test_keycloak_userinfo(keycloak_mock):
- actual_user_info = keycloak_mock.userinfo("refresh-token")
+def test_keycloak_oidc_userinfo(keycloak_oidc):
+ actual_user_info = keycloak_oidc.userinfo("refresh-token")
assert actual_user_info == USER_INFO
-def test_keycloak_logout(keycloak_mock):
+def test_keycloak_oidc_logout(keycloak_oidc):
"""Login out does not raise"""
- keycloak_mock.logout("refresh-token")
+ keycloak_oidc.logout("refresh-token")
-def test_keycloak_decode_token(keycloak_mock):
- actual_decoded_data = keycloak_mock.decode_token(OIDC_PROFILE["access_token"])
+def test_keycloak_oidc_decode_token(keycloak_oidc):
+ actual_decoded_data = keycloak_oidc.decode_token(OIDC_PROFILE["access_token"])
actual_decoded_data2 = copy(actual_decoded_data)
expected_decoded_token = copy(DECODED_TOKEN)
@@ -90,8 +90,8 @@
assert actual_decoded_data2 == expected_decoded_token
-def test_keycloak_login(keycloak_mock):
- actual_response = keycloak_mock.login("username", "password")
+def test_keycloak_oidc_login(keycloak_oidc):
+ actual_response = keycloak_oidc.login("username", "password")
assert actual_response == OIDC_PROFILE
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jun 20, 7:04 PM (2 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3226754
Attached To
D5335: tests: Rename keycloak_mock fixture to keycloak_oidc
Event Timeline
Log In to Comment