From 70af4bf25640efa10d9f54d71d2a3d63a5484c98 Mon Sep 17 00:00:00 2001 From: Tobias Genannt Date: Mon, 22 Jan 2024 10:41:48 +0100 Subject: [PATCH] fix: name of client_id parameter The name client_role_id for the parameter is confusing because it expects the client_id. --- src/keycloak/keycloak_admin.py | 8 ++++---- tests/test_keycloak_admin.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/keycloak/keycloak_admin.py b/src/keycloak/keycloak_admin.py index 07790b2..fa87463 100644 --- a/src/keycloak/keycloak_admin.py +++ b/src/keycloak/keycloak_admin.py @@ -2453,14 +2453,14 @@ class KeycloakAdmin: ) return raise_error_from_response(data_raw, KeycloakPostError, expected_codes=[204]) - def update_client_role(self, client_role_id, role_name, payload): + def update_client_role(self, client_id, role_name, payload): """Update a client role. RoleRepresentation https://www.keycloak.org/docs-api/18.0/rest-api/index.html#_rolerepresentation - :param client_role_id: id of client (not client-id) - :type client_role_id: str + :param client_id: id of client (not client-id) + :type client_id: str :param role_name: role's name (not id!) :type role_name: str :param payload: RoleRepresentation @@ -2470,7 +2470,7 @@ class KeycloakAdmin: """ params_path = { "realm-name": self.connection.realm_name, - "id": client_role_id, + "id": client_id, "role-name": role_name, } data_raw = self.connection.raw_put( diff --git a/tests/test_keycloak_admin.py b/tests/test_keycloak_admin.py index a9a5904..e8f889a 100644 --- a/tests/test_keycloak_admin.py +++ b/tests/test_keycloak_admin.py @@ -1638,14 +1638,14 @@ def test_client_roles(admin: KeycloakAdmin, client: str): # Test update client role res = admin.update_client_role( - client_role_id=client, + client_id=client, role_name="client-role-test", payload={"name": "client-role-test-update"}, ) assert res == dict() with pytest.raises(KeycloakPutError) as err: res = admin.update_client_role( - client_role_id=client, + client_id=client, role_name="client-role-test", payload={"name": "client-role-test-update"}, )