2727 FunctionsWriteApiAccessDeniedError ,
2828 FunctionWriteAccessDeniedError ,
2929)
30+ from models_library .groups import EVERYONE_GROUP_ID
3031from models_library .products import ProductName
3132from models_library .rest_ordering import OrderBy , OrderDirection
3233from pytest_simcore .helpers .webserver_users import UserInfoDict
@@ -194,7 +195,7 @@ async def test_list_functions(
194195 )
195196
196197 # Assert the list contains the registered function
197- assert len (functions ) > 0
198+ assert len (functions ) == 1
198199 assert any (f .uid == registered_function .uid for f in functions )
199200
200201
@@ -221,7 +222,7 @@ async def test_list_functions_mixed_user(
221222 )
222223 for _ in range (2 )
223224 ]
224-
225+ assert int ( logged_user [ "primary_gid" ]) != 1
225226 # List functions for the other logged user
226227 other_functions , _ = await webserver_rpc_client .functions .list_functions (
227228 pagination_limit = 10 ,
@@ -250,7 +251,7 @@ async def test_list_functions_mixed_user(
250251 product_name = osparc_product_name ,
251252 )
252253 # Assert the list contains only the logged user's function
253- assert len (functions ) == 2
254+ assert len (functions ) == len ( registered_functions )
254255 assert all (f .uid in [rf .uid for rf in registered_functions ] for f in functions )
255256
256257 other_functions , _ = await webserver_rpc_client .functions .list_functions (
@@ -260,11 +261,48 @@ async def test_list_functions_mixed_user(
260261 product_name = osparc_product_name ,
261262 )
262263 # Assert the list contains only the other user's functions
263- assert len (other_functions ) == 3
264+ assert len (other_functions ) == len ( other_registered_function )
264265 assert all (
265266 f .uid in [orf .uid for orf in other_registered_function ] for f in other_functions
266267 )
267268
269+ # Add other-user permissions to a logged user function
270+ await webserver_rpc_client .functions .set_group_permissions (
271+ object_type = "function" ,
272+ permission_group_id = int (other_logged_user ["primary_gid" ]),
273+ object_ids = [registered_functions [0 ].uid ],
274+ user_id = logged_user ["id" ],
275+ product_name = osparc_product_name ,
276+ read = True ,
277+ )
278+
279+ other_functions , _ = await webserver_rpc_client .functions .list_functions (
280+ pagination_limit = 10 ,
281+ pagination_offset = 0 ,
282+ user_id = other_logged_user ["id" ],
283+ product_name = osparc_product_name ,
284+ )
285+
286+ assert len (other_functions ) == len (other_registered_function ) + 1
287+ assert any (f .uid == registered_functions [0 ].uid for f in other_functions )
288+
289+ # Add all-user permissions to a logged user function
290+ await webserver_rpc_client .functions .set_group_permissions (
291+ object_type = "function" ,
292+ permission_group_id = EVERYONE_GROUP_ID ,
293+ object_ids = [registered_functions [0 ].uid ],
294+ user_id = logged_user ["id" ],
295+ product_name = osparc_product_name ,
296+ read = True ,
297+ )
298+ other_functions , _ = await webserver_rpc_client .functions .list_functions (
299+ pagination_limit = 10 ,
300+ pagination_offset = 0 ,
301+ user_id = other_logged_user ["id" ],
302+ product_name = osparc_product_name ,
303+ )
304+ assert len (other_functions ) == len (other_registered_function ) + 1
305+
268306
269307@pytest .mark .parametrize ("user_role" , [UserRole .USER ])
270308@pytest .mark .parametrize (
0 commit comments