From a0d2a6ef01c45513dfacac957f5f9803e4fee9f2 Mon Sep 17 00:00:00 2001 From: Vladimir Brik <22751545+vbrik@users.noreply.github.com> Date: Wed, 27 Nov 2024 13:34:13 -0600 Subject: [PATCH] add test for /groups returning empty subgroups --- tests/krs/test_groups.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/krs/test_groups.py b/tests/krs/test_groups.py index cea19f1..5bbe67b 100644 --- a/tests/krs/test_groups.py +++ b/tests/krs/test_groups.py @@ -5,6 +5,28 @@ from ..util import keycloak_bootstrap +@pytest.mark.asyncio +async def test_confirm_empty_subgroups_keycloak_quirk(keycloak_bootstrap): + await groups.create_group('/group', rest_client=keycloak_bootstrap) + await groups.create_group('/group/subgroup', rest_client=keycloak_bootstrap) + ret = await keycloak_bootstrap.request( + 'GET', "/groups?briefRepresentation=false&populateHierarchy=true") + if ret[0]['subGroups']: + pytest.fail("""See full failure message. +It looks like bug where /groups incorrectly returns empty subgroups has been fixed +(see https://github.com/keycloak/keycloak/issues/27694). +This means that some functions that use the /groups endpoint unnecessarily apply +workarounds, which probably significantly slows them down. + +At the time of writing these are the affected functions: + +* group_info_by_id(): unnecessarily calls a function to populate subgroups, + which is quite slow. + +* get_group_hierarchy(): unnecessarily inserts "search=" into the URL, + which probably slows it down. +""") + @pytest.mark.asyncio async def test_list_groups_empty(keycloak_bootstrap): ret = await groups.list_groups(rest_client=keycloak_bootstrap)