Changeset View
Changeset View
Standalone View
Standalone View
swh/auth/tests/django/test_utils.py
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | def test_oidc_user_from_decoded_token_empty_fields_ok(key, mapped_key): | ||||
assert getattr(user, mapped_key) == "" | assert getattr(user, mapped_key) == "" | ||||
def test_oidc_user_from_profile(keycloak_oidc): | def test_oidc_user_from_profile(keycloak_oidc): | ||||
user = oidc_user_from_profile(keycloak_oidc, OIDC_PROFILE) | user = oidc_user_from_profile(keycloak_oidc, OIDC_PROFILE) | ||||
_check_user(user) | _check_user(user) | ||||
@override_settings( | |||||
SWH_AUTH_SERVER_URL=None, SWH_AUTH_REALM_NAME=None, SWH_AUTH_CLIENT_ID=None, | |||||
) | |||||
def test_keycloak_oidc_client_missing_django_settings(): | def test_keycloak_oidc_client_missing_django_settings(): | ||||
with pytest.raises(ValueError, match="settings are mandatory"): | with pytest.raises(ValueError, match="settings are mandatory"): | ||||
keycloak_oidc_client() | keycloak_oidc_client() | ||||
@override_settings( | @override_settings( | ||||
KEYCLOAK_SERVER_URL=SERVER_URL, | SWH_AUTH_SERVER_URL=SERVER_URL, | ||||
KEYCLOAK_REALM_NAME=REALM_NAME, | SWH_AUTH_REALM_NAME=REALM_NAME, | ||||
KEYCLOAK_CLIENT_ID=CLIENT_ID, | SWH_AUTH_CLIENT_ID=CLIENT_ID, | ||||
) | ) | ||||
def test_keycloak_oidc_client_parameters_from_django_settings(): | def test_keycloak_oidc_client_parameters_from_django_settings(): | ||||
kc_oidc_client = keycloak_oidc_client() | kc_oidc_client = keycloak_oidc_client() | ||||
assert kc_oidc_client.server_url == SERVER_URL | assert kc_oidc_client.server_url == SERVER_URL | ||||
assert kc_oidc_client.realm_name == REALM_NAME | assert kc_oidc_client.realm_name == REALM_NAME | ||||
assert kc_oidc_client.client_id == CLIENT_ID | assert kc_oidc_client.client_id == CLIENT_ID |