diff --git a/features/backend/project_user_resources/project_user.feature b/features/backend/project_user_resources/project_user.feature new file mode 100644 index 000000000..dba737a98 --- /dev/null +++ b/features/backend/project_user_resources/project_user.feature @@ -0,0 +1,49 @@ +@ProcessMakerMichelangelo @RestAPI +Feature: Project User Resources + + Background: + Given that I have a valid access_token + + Scenario: Get a list of users of a project + Given I request "project/1265557095225ff5c688f46031700471/users" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the content type is "application/json" + And the type is "array" + + Scenario: Get a list of starting task of a project + Given I request "project/1265557095225ff5c688f46031700471/starting-tasks" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the content type is "application/json" + And the type is "array" + + Scenario: Get a list of start task of a user + Given I request "project/1265557095225ff5c688f46031700471/user/00000000000000000000000000000001/starting-tasks" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the content type is "application/json" + And the type is "array" + + Scenario Outline: Verify if a user can start a task + Given POST this data: + """ + { + "act_uid": "", + "username": "", + "password": "" + } + """ + And I request "project/1265557095225ff5c688f46031700471/ws/user/can-start-task" + Then the response status code should be + And the response charset is "UTF-8" + And the content type is "application/json" + And the type is "" + + Examples: + | test_description | act_uid | username | password | http_code | type | + | error username | 1352844695225ff5fe54de2005407079 | adm | admin | 400 | string | + | error password | 1352844695225ff5fe54de2005407079 | admin | adm | 400 | string | + | short activity | 1352844695225ff5fe54de20 | admin | admin | 400 | string | + | error activity | 225ff5fe54de20054070791352844695 | admin | admin | 400 | string | + | all ok | 1352844695225ff5fe54de2005407079 | admin | admin | 200 | array | diff --git a/workflow/engine/src/BusinessModel/ProjectUser.php b/workflow/engine/src/BusinessModel/ProjectUser.php index d948022ea..9fe785bf0 100644 --- a/workflow/engine/src/BusinessModel/ProjectUser.php +++ b/workflow/engine/src/BusinessModel/ProjectUser.php @@ -223,7 +223,7 @@ class ProjectUser $oCriteria->add( \UsersPeer::USR_USERNAME, $sWS_USER ); $userIsAssigned = \GroupUserPeer::doCount( $oCriteria ); if (! ($userIsAssigned >= 1)) { - $messageCode = "The User `" . $sWS_USER . "` doesn't have the activity `" . $sTASKS . "` assigned"; + throw (new \Exception( "The User `" . $sWS_USER . "` doesn't have the activity `" . $sTASKS . "` assigned")); } } $oDataset = \TaskUserPeer::doSelectRS($oCriteria); @@ -237,7 +237,7 @@ class ProjectUser $oDataset->next(); } } else { - $messageCode = $result->message; + throw (new \Exception( $result->message)); } return $messageCode; } catch (Exception $e) { diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Project/ProjectUsers.php b/workflow/engine/src/Services/Api/ProcessMaker/Project/ProjectUsers.php index 2c1860d8d..2358892cf 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Project/ProjectUsers.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Project/ProjectUsers.php @@ -75,7 +75,7 @@ class ProjectUsers extends Api * * @url POST /:prjUid/ws/user/can-start-task */ - public function doGetProjectWsUserCanStartTask($prjUid, wsUserCanStartTaskStructure $request_data = null) + public function doPostProjectWsUserCanStartTask($prjUid, wsUserCanStartTaskStructure $request_data = null) { try { $request_data = (array)($request_data);