Enforce command-specific permissions for self-serve lane operations and update related tests
This commit is contained in:
@@ -67,6 +67,18 @@ class moduleSelfServeRoute
|
||||
if ($command === null) {
|
||||
$response->error("Invalid command: " . $commandParam);
|
||||
}
|
||||
// Require permissions for specific commands
|
||||
switch ($command) {
|
||||
case \modules\selfserve\helpers\selfserve_lane_command::START:
|
||||
self::requirePermission('modules_selfserve_lane_command_execute_start');
|
||||
break;
|
||||
case \modules\selfserve\helpers\selfserve_lane_command::STOP:
|
||||
self::requirePermission('modules_selfserve_lane_command_execute_stop');
|
||||
break;
|
||||
case \modules\selfserve\helpers\selfserve_lane_command::RESET:
|
||||
self::requirePermission('modules_selfserve_lane_command_execute_reset');
|
||||
break;
|
||||
}
|
||||
// Execute the command
|
||||
try {
|
||||
$args = new \modules\selfserve\classes\selfserve_lane_command_arguments();
|
||||
@@ -87,7 +99,10 @@ class moduleSelfServeRoute
|
||||
}
|
||||
},
|
||||
[
|
||||
'modules_selfserve_lane_command_execute' => 'Execute self-serve lane command',
|
||||
'modules_selfserve_lane_command_execute' => 'Execute self-serve lane command. This is required together with specific command permissions below.',
|
||||
'modules_selfserve_lane_command_execute_start' => 'Execute self-serve lane START command',
|
||||
'modules_selfserve_lane_command_execute_stop' => 'Execute self-serve lane STOP command',
|
||||
'modules_selfserve_lane_command_execute_reset' => 'Execute self-serve lane RESET command',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
### POST /modules/self-serve/lane/command START
|
||||
@lane_id = 3
|
||||
@lane_id = 1
|
||||
POST {{api_url}}/modules/self-serve/lane/command
|
||||
Accept: application/json
|
||||
Content-Type: application/json
|
||||
@@ -16,6 +16,7 @@ Content-Type: application/json
|
||||
POST {{api_url}}/modules/self-serve/lane/command
|
||||
Accept: application/json
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{auth_token_superuser}}
|
||||
|
||||
{
|
||||
"command": "STOP",
|
||||
@@ -26,6 +27,7 @@ Content-Type: application/json
|
||||
POST {{api_url}}/modules/self-serve/lane/command
|
||||
Accept: application/json
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{auth_token_superuser}}
|
||||
|
||||
{
|
||||
"command": "RESET",
|
||||
|
||||
Reference in New Issue
Block a user