diff --git a/jhub_apps/service/utils.py b/jhub_apps/service/utils.py index 7cf18657..61e362b8 100644 --- a/jhub_apps/service/utils.py +++ b/jhub_apps/service/utils.py @@ -158,7 +158,11 @@ def get_shared_servers(current_hub_user): user_servers_without_default_jlab = list(filter(lambda server: server["name"] != "", all_users_servers)) hub_client_user = HubClient(username=current_hub_user['name']) shared_servers = hub_client_user.get_shared_servers() - shared_server_names = {shared_server["server"]["name"] for shared_server in shared_servers} + shared_server_names = { + shared_server["server"]["name"] for shared_server in shared_servers + # remove shared apps by current user + if shared_server["server"]["user"]["name"] != current_hub_user['name'] + } shared_servers_rich = [ server for server in user_servers_without_default_jlab if server["name"] in shared_server_names diff --git a/jhub_apps/tests/tests_unit/test_api.py b/jhub_apps/tests/tests_unit/test_api.py index 9ff4af4c..396f91d1 100644 --- a/jhub_apps/tests/tests_unit/test_api.py +++ b/jhub_apps/tests/tests_unit/test_api.py @@ -170,8 +170,10 @@ def test_shared_server_filtering(hub_get_shared_servers, get_users): } ] hub_get_shared_servers.return_value = [ - {"server": {"name": "panel-56"}}, - {"server": {"name": "panel-34"}}, + {"server": {"name": "panel-56", "user": {"name": "another-user"}}}, + {"server": {"name": "panel-34", "user": {"name": "another-user"}}}, + {"server": {"name": "panel-23", "user": {"name": "fakeuser"}}}, + {"server": {"name": "panel-42", "user": {"name": "fakeuser"}}}, ] shared_servers = get_shared_servers(current_hub_user) assert shared_servers == [