Skip to content

Commit 9a6549b

Browse files
committed
Some more abilities renaming
1 parent 183702c commit 9a6549b

File tree

6 files changed

+18
-17
lines changed

6 files changed

+18
-17
lines changed

packages/service-library/src/servicelib/rabbitmq/rpc_interfaces/webserver/functions/functions_rpc_interface.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,15 +413,17 @@ async def get_function_user_permissions(
413413

414414

415415
@log_decorator(_logger, level=logging.DEBUG)
416-
async def get_functions_user_abilities(
416+
async def get_functions_user_api_access_rights(
417417
rabbitmq_rpc_client: RabbitMQRPCClient,
418418
*,
419419
user_id: UserID,
420420
product_name: ProductName,
421421
) -> FunctionUserApiAccessRights:
422422
result = await rabbitmq_rpc_client.request(
423423
WEBSERVER_RPC_NAMESPACE,
424-
TypeAdapter(RPCMethodName).validate_python("get_functions_user_abilities"),
424+
TypeAdapter(RPCMethodName).validate_python(
425+
"get_functions_user_api_access_rights"
426+
),
425427
user_id=user_id,
426428
product_name=product_name,
427429
)

services/api-server/src/simcore_service_api_server/api/routes/functions_routes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,17 +375,17 @@ async def run_function( # noqa: PLR0913
375375
) -> RegisteredFunctionJob:
376376

377377
# Make sure the user is allowed to execute any function
378-
# (read/write ability is checked in the other endpoint called in this method)
379-
user_abilities = await wb_api_rpc.get_functions_user_abilities(
378+
# (read/write right is checked in the other endpoint called in this method)
379+
user_api_access_rights = await wb_api_rpc.get_functions_user_api_access_rights(
380380
user_id=user_id, product_name=product_name
381381
)
382-
if not user_abilities.execute_functions:
382+
if not user_api_access_rights.execute_functions:
383383
raise FunctionsExecuteApiAccessDeniedError(
384384
user_id=user_id,
385385
function_id=function_id,
386386
)
387387
# Make sure the user is allowed to execute this particular function
388-
# (read/write ability is checked in the other endpoint called in this method)
388+
# (read/write right is checked in the other endpoint called in this method)
389389
user_permissions: FunctionUserAccessRights = (
390390
await wb_api_rpc.get_function_user_permissions(
391391
function_id=function_id, user_id=user_id, product_name=product_name

services/api-server/src/simcore_service_api_server/services_rpc/wb_api_server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,13 +544,13 @@ async def get_function_user_permissions(
544544
function_id=function_id,
545545
)
546546

547-
async def get_functions_user_abilities(
547+
async def get_functions_user_api_access_rights(
548548
self,
549549
*,
550550
user_id: UserID,
551551
product_name: ProductName,
552552
) -> FunctionUserApiAccessRights:
553-
return await functions_rpc_interface.get_functions_user_abilities(
553+
return await functions_rpc_interface.get_functions_user_api_access_rights(
554554
self._client,
555555
user_id=user_id,
556556
product_name=product_name,

services/api-server/tests/unit/api_functions/test_api_routers_functions.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ async def test_list_function_job_collections_with_function_filter(
591591
)
592592

593593

594-
@pytest.mark.parametrize("user_has_execute_ability", [False, True])
594+
@pytest.mark.parametrize("user_has_execute_right", [False, True])
595595
@pytest.mark.parametrize(
596596
"funcapi_endpoint,endpoint_inputs", [("run", {}), ("map", [{}, {}])]
597597
)
@@ -603,13 +603,12 @@ async def test_run_map_function_not_allowed(
603603
user_id: UserID,
604604
mocked_webserver_rest_api_base: respx.MockRouter,
605605
mocked_webserver_rpc_api: dict[str, MockType],
606-
user_has_execute_ability: bool,
606+
user_has_execute_right: bool,
607607
funcapi_endpoint: str,
608608
endpoint_inputs: dict | list[dict],
609609
) -> None:
610610
"""Test that running a function is not allowed."""
611611

612-
# Mock the function's user permissions and abilities
613612
mock_handler_in_functions_rpc_interface(
614613
"get_function_user_permissions",
615614
FunctionUserAccessRights(
@@ -620,10 +619,10 @@ async def test_run_map_function_not_allowed(
620619
),
621620
)
622621
mock_handler_in_functions_rpc_interface(
623-
"get_functions_user_abilities",
622+
"get_functions_user_api_access_rights",
624623
FunctionUserApiAccessRights(
625624
user_id=user_id,
626-
execute_functions=user_has_execute_ability,
625+
execute_functions=user_has_execute_right,
627626
write_functions=True,
628627
read_functions=True,
629628
),
@@ -640,7 +639,7 @@ async def async_magic():
640639
json=endpoint_inputs,
641640
auth=auth,
642641
)
643-
if user_has_execute_ability:
642+
if user_has_execute_right:
644643
assert response.status_code == status.HTTP_403_FORBIDDEN
645644
assert response.json()["errors"][0] == (
646645
f"Function {mock_registered_function.uid} execute access denied for user {user_id}"

services/web/server/src/simcore_service_webserver/functions/_controller/_functions_rpc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ async def get_function_user_permissions(
414414

415415

416416
@router.expose(reraise_if_error_type=())
417-
async def get_functions_user_abilities(
417+
async def get_functions_user_api_access_rights(
418418
app: web.Application,
419419
*,
420420
user_id: UserID,
@@ -423,7 +423,7 @@ async def get_functions_user_abilities(
423423
"""
424424
Returns a dictionary with the user's abilities for all function related objects.
425425
"""
426-
return await _functions_service.get_functions_user_abilities(
426+
return await _functions_service.get_functions_user_api_access_rights(
427427
app=app,
428428
user_id=user_id,
429429
product_name=product_name,

services/web/server/src/simcore_service_webserver/functions/_functions_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ async def get_function_user_permissions(
448448
)
449449

450450

451-
async def get_functions_user_abilities(
451+
async def get_functions_user_api_access_rights(
452452
app: web.Application,
453453
*,
454454
user_id: UserID,

0 commit comments

Comments
 (0)