Merged colosa/processmaker into master

This commit is contained in:
jonathan quispe
2014-05-29 16:35:19 -04:00
12 changed files with 1461 additions and 28 deletions

View File

@@ -25,7 +25,7 @@ task :build => [:required] do
if mode == "production"
targetDir = publicDir + "/lib"
pmUIFontsDir = targetDir + "/css/fonts"
pmUIFontsDir = targetDir + "/fonts"
else
targetDir = publicDir + "/lib-dev"
pmUIFontsDir = pmUIDir + "/fonts"
@@ -112,7 +112,7 @@ def buildPmUi(homeDir, targetDir, mode)
puts "\nCopying font files into: #{pmUIFontsDir}".bold
theme = "mafe"
copyFiles({"#{homeDir}/themes/#{theme}/fonts/*" => "#{targetDir}"})
copyFiles({"#{homeDir}/themes/#{theme}/fonts/*" => "#{pmUIFontsDir}"})
puts "\nPMUI Build Finished".magenta
end
@@ -169,10 +169,9 @@ end
def getVersion(path)
if File.exists? path + '/VERSION.txt'
version = File.read path + '/VERSION.txt'
else
version = "(unknown)"
version = ""
Dir.chdir(path) do
version = `rake version`
end
return version.strip
@@ -180,7 +179,11 @@ end
def getHash(path)
hash = `git rev-parse --short HEAD`
hash = ""
Dir.chdir(path) do
hash = `git rev-parse --short HEAD`
end
return hash.strip
end
@@ -309,3 +312,4 @@ class String
def bold; "\033[1m#{self}\033[22m" end
def reverse_color; "\033[7m#{self}\033[27m" end
end

View File

@@ -0,0 +1,230 @@
@ProcessMakerMichelangelo @RestAPI
Feature: Roles
Background:
Given that I have a valid access_token
Scenario: Get list of Roles
Given I request "role"
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"
And the response has 3 records
Scenario: Get a single Role
Given I request "role/00000000000000000000000000000002"
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 "object"
Scenario Outline: Create new Role
Given POST this data:
"""
{
"rol_code": "<rol_code>",
"rol_name": "<rol_name>",
"rol_status": "<rol_status>"
}
"""
And I request "role"
Then the response status code should be 201
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "object"
And store "rol_uid" in session array as variable "rol_uid_<rol_uid_number>"
Examples:
| test_description | rol_uid_number | rol_code | rol_name | rol_status |
| Create Role with name short | 1 | PROCESSMAKER_OPERATOR1 | sample | ACTIVE |
#Assign users to role
#Scenario: List assigned Users to Role & List available Users to assign to Role
# Given I request "role/00000000000000000000000000000003/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"
# And the response has 61 records
#
#Scenario: Assign User to Role
# Given POST this data:
# """
# {
# "usr_uid": "310985970530cbfa4ec0593063369294"
# }
# """
# And I request "role/00000000000000000000000000000003/user"
# Then the response status code should be 201
# And the response charset is "UTF-8"
# And the content type is "application/json"
# And the type is "object"
#
#
#Scenario: Get list of Roles
# Given I request "roles"
# 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"
# And the response has 62 records
#
#
#Scenario: Unassign User of the Role
# Given that I want to delete a resource with the key "310985970530cbfa4ec0593063369294"
# And I request "role/00000000000000000000000000000003/user/310985970530cbfa4ec0593063369294"
# And the content type is "application/json"
# Then the response status code should be 200
# And the response charset is "UTF-8"
#
#
#Scenario: Get list of Roles
# Given I request "roles"
# 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"
# And the response has 61 records
#Culminacion de los endpoint de asignacion de usuarios
#Role and Permission
Scenario: List assigned Permissions to Role & List available Permissions to assign to Role
Given I request "role/00000000000000000000000000000003/permissions"
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"
And the response has 3 records
Scenario: List assigned Permissions to Role & List available Permissions to assign to Role
Given I request "role/00000000000000000000000000000003/available-permissions"
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"
And the response has 14 recordsuser
Scenario: Assign Permission "PM_DASHBOARD" to Role
Given POST this data:
"""
{
"per_uid": "00000000000000000000000000000011"
}
"""
And I request "role/00000000000000000000000000000003/permission"
Then the response status code should be 201
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "object"
Scenario: List assigned Permissions to Role & List available Permissions to assign to Role
Given I request "role/00000000000000000000000000000003/permissions"
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"
And the response has 4 records
Scenario: List assigned Permissions to Role & List available Permissions to assign to Role
Given I request "role/00000000000000000000000000000003/available-permissions"
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"
And the response has 15 records
Scenario: Unassign Permission of the Role
Given that I want to delete a resource with the key ""
And I request "role/00000000000000000000000000000003/permission/00000000000000000000000000000011"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
Scenario: List assigned Permissions to Role & List available Permissions to assign to Role
Given I request "role/00000000000000000000000000000003/permissions"
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"
And the response has 3 records
Scenario: List assigned Permissions to Role & List available Permissions to assign to Role
Given I request "role/00000000000000000000000000000003/available-permissions"
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"
And the response has 14 records
#Culminacion de behat para Role and Permission
Scenario Outline: Update Role
Given PUT this data:
"""
{
"rol_code": "<rol_code>",
"rol_name": "<rol_name>",
"rol_status": "<rol_status>"
}
"""
And that I want to update a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
And I request "role"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
Examples:
| test_description | rol_uid_number | rol_code | rol_name | rol_status |
| Update name of role created in this script | 1 | PROCESSMAKER_OPERATOR1 | update_sample | INACTIVE |
Scenario Outline: Get a single Role created in this script
Given that I want to get a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
Given I request "role"
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 "object"
And that "rol_code" is set to "<rol_code>"
And that "rol_name" is set to "<rol_name>"
And that "rol_status" is set to "<rol_status>"
Examples:
| test_description | rol_uid_number | rol_code | rol_name | rol_status |
| Update name of role created in this script | 1 | PROCESSMAKER_OPERATOR1 | update_sample | INACTIVE |
Scenario Outline: Delete all roles created in this scritp
Given that I want to delete a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
And I request "role"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"
Examples:
| rol_uid_number |
| 1 |
Scenario: Get list of Roles
Given I request "roles"
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"
And the response has 3 records

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,66 @@
@ProcessMakerMichelangelo @RestAPI
Feature: Roles Negative Tests
Background:
Given that I have a valid access_token
Scenario Outline: Create new Role (NEGATIVE TESTS)
Given POST this data:
"""
{
"rol_code": "<rol_code>",
"rol_name": "<rol_name>",
"rol_status": "<rol_status>"
}
"""
And I request "role"
Then the response status code should be <error_code>
And the response status message should have the following text "<error_message>"
Examples:
| test_description | rol_code | rol_name | rol_status | error_code | error_message |
| Create Role with same name | PROCESSMAKER_OPERATOR | Operator | ACTIVE | 400 | already_exists |
| Create Role without fill required fields "rol_code" | | sample | | 400 | required_fields |
| Create Role without fill required fields "rol_name" | PROCESSMAKER_ADMINISTRATOR1 | | ACTIVE | 400 | required_fields |
| Create Role without fill required fields "rol_status" | PROCESSMAKER_MANAGER1 | Rol con code manager | | 400 | required_fields |
| Create Role with wrong field rol_status | PROCESSMAKER_ADMINISTRATOR2 | Rol con code administrator/inactive | SAMPLE | 400 | rol_status |
#Scenario Outline: Assign User to Role (NEGATIVE TESTS)
# Given POST this data:
# """
# {
# "usr_uid": "<usr_uid>"
# }
# """
# And I request "role/rol_uid/user"
# Then the response status code should be <error_code>
# And the response status message should have the following text "<error_message>"
#
# Examples:
#
# | Description | rol_uid | usr_uid | error_code | error_message |
# | Without rol_uid | 00000000000000000000000000000004 | 51049032352d56710347233042615067 | 400 | rol_uid |
# | Without usr_uid | 00000000000000000000000000000004 | | 400 | usr_uid |
# | Assign same user to rol | 00000000000000000000000000000002 | 00000000000000000000000000000001 | 400 | usr_uid |
Scenario Outline: Assign Permission "PM_DASHBOARD" to Role (NEGATIVE TESTS)
Given POST this data:
"""
{
"per_uid": "<per_uid>"
}
"""
And I request "role/rol_uid/permission"
Then the response status code should be <error_code>
And the response status message should have the following text "<error_message>"
Examples:
| Description | rol_uid | per_uid | error_code | error_message |
| Assign same permissions in rol "PROCESSMAKER_MANAGER" | 00000000000000000000000000000004 | 00000000000000000000000000000001 | 400 | per_uid |
| Create rol without rol_uid | | 00000000000000000000000000000002 | 400 | rol_uid |
| Create rol without per_uid | 00000000000000000000000000000004 | | 400 | per_uid |

View File

@@ -151,7 +151,7 @@ Scenario: Delete a Project created previously in this script
#Import Process
Scenario Outline: Import a process
Given POST upload a project file "<project_file>" to "project/import?option=<import_option>"
Given POST upload a project file "<project_file>" to "project/import?option=<import_option>&option_group=merge"
Then the response status code should be 201
And the response charset is "UTF-8"
And the content type is "application/json"

View File

@@ -13,4 +13,17 @@ Scenario Outline: Import a process negative tests
Examples:
| Description | project_file | import_option | error_code | error_message |
| Import process when the process alredy exists | /home/wendy/uploadfiles/Process_Complete_BPMN.pmx | create | 400 | already exists |
#| Invalid path | /processmaker/sample/Project_invalido.pmx | create | 400 | invalid |
#| Invalid path | /processmaker/sample/Project_invalido.pmx | create | 400 | invalid |
| Field Required project_file | | create | 400 | project_file |
Scenario Outline: Import a process with wrong "option"
Given POST upload a project file "<project_file>" to "project/import?option=<option>&option_group=<option_group>"
Then the response status code should be 400
And the response status message should have the following text "<error_message>"
Examples:
| Description | project_file | option | option_group | error_message |
| Invalid option | /home/wendy/uploadfiles/Process_NewCreate_BPMN.pmx | sample | merge | option |
| Invalid option_group | /home/wendy/uploadfiles/Process_Complete_BPMN.pmx | create | sample | option_group |

View File

@@ -62,7 +62,7 @@ class Role
*
* return void
*/
public function setArrayFieldNameForException($arrayData)
public function setArrayFieldNameForException(array $arrayData)
{
try {
foreach ($arrayData as $key => $value) {
@@ -191,9 +191,9 @@ class Role
public function throwExceptionIfNotExistsRole($roleUid, $fieldNameForException)
{
try {
$role = \RolesPeer::retrieveByPK($roleUid);
$obj = \RolesPeer::retrieveByPK($roleUid);
if (is_null($role)) {
if (is_null($obj)) {
throw new \Exception(\G::LoadTranslation("ID_ROLE_DOES_NOT_EXIST", array($fieldNameForException, $roleUid)));
}
} catch (\Exception $e) {
@@ -251,7 +251,7 @@ class Role
*
* return void Throw exception if data has an invalid value
*/
public function throwExceptionIfDataIsInvalid($roleUid, $arrayData)
public function throwExceptionIfDataIsInvalid($roleUid, array $arrayData)
{
try {
//Set variables
@@ -289,7 +289,7 @@ class Role
*
* return array Return data of the new Role created
*/
public function create($arrayData)
public function create(array $arrayData)
{
try {
//Verify data
@@ -335,7 +335,7 @@ class Role
*
* return array Return data of the Role updated
*/
public function update($roleUid, $arrayData)
public function update($roleUid, array $arrayData)
{
try {
$arrayDataBackup = $arrayData;
@@ -445,7 +445,7 @@ class Role
*
* return array Return an array with data Role
*/
public function getRoleDataFromRecord($record)
public function getRoleDataFromRecord(array $record)
{
try {
$conf = new \Configurations();
@@ -487,7 +487,7 @@ class Role
*
* return array Return an array with all Roles
*/
public function getRoles($arrayFilterData = null, $sortField = null, $sortDir = null, $start = null, $limit = null)
public function getRoles(array $arrayFilterData = null, $sortField = null, $sortDir = null, $start = null, $limit = null)
{
try {
$arrayRole = array();

File diff suppressed because it is too large Load Diff

View File

@@ -67,7 +67,7 @@ class WebEntry
*
* return void
*/
public function setArrayFieldNameForException($arrayData)
public function setArrayFieldNameForException(array $arrayData)
{
try {
foreach ($arrayData as $key => $value) {
@@ -175,9 +175,9 @@ class WebEntry
public function throwExceptionIfNotExistsWebEntry($webEntryUid, $fieldNameForException)
{
try {
$webEntry = \WebEntryPeer::retrieveByPK($webEntryUid);
$obj = \WebEntryPeer::retrieveByPK($webEntryUid);
if (is_null($webEntry)) {
if (is_null($obj)) {
throw new \Exception(\G::LoadTranslation("ID_WEB_ENTRY_DOES_NOT_EXIST", array($fieldNameForException, $webEntryUid)));
}
} catch (\Exception $e) {
@@ -215,7 +215,7 @@ class WebEntry
*
* return void Throw exception if data has an invalid value
*/
public function throwExceptionIfDataIsInvalid($webEntryUid, $processUid, $arrayData)
public function throwExceptionIfDataIsInvalid($webEntryUid, $processUid, array $arrayData)
{
try {
//Set variables
@@ -537,7 +537,7 @@ class WebEntry
*
* return array Return data of the new Web Entry created
*/
public function create($processUid, $userUidCreator, $arrayData)
public function create($processUid, $userUidCreator, array $arrayData)
{
try {
//Verify data
@@ -622,7 +622,7 @@ class WebEntry
*
* return array Return data of the Web Entry updated
*/
public function update($webEntryUid, $userUidUpdater, $arrayData)
public function update($webEntryUid, $userUidUpdater, array $arrayData)
{
try {
//Verify data
@@ -797,7 +797,7 @@ class WebEntry
*
* return array Return an array with data Web Entry
*/
public function getWebEntryDataFromRecord($record)
public function getWebEntryDataFromRecord(array $record)
{
try {
if ($record["WE_METHOD"] == "WS") {

View File

@@ -71,7 +71,7 @@ class WebEntry extends Api
*
* @status 201
*/
public function doPostWebEntry($prj_uid, $request_data)
public function doPostWebEntry($prj_uid, array $request_data)
{
try {
$arrayData = $this->webEntry->create($prj_uid, $this->getUserId(), $request_data);
@@ -91,7 +91,7 @@ class WebEntry extends Api
* @param string $we_uid {@min 32}{@max 32}
* @param array $request_data
*/
public function doPutWebEntry($prj_uid, $we_uid, $request_data)
public function doPutWebEntry($prj_uid, $we_uid, array $request_data)
{
try {
$arrayData = $this->webEntry->update($we_uid, $this->getUserId(), $request_data);

View File

@@ -66,7 +66,7 @@ class Role extends Api
*
* @status 201
*/
public function doPost($request_data)
public function doPost(array $request_data)
{
try {
$arrayData = $this->role->create($request_data);
@@ -85,7 +85,7 @@ class Role extends Api
* @param string $rol_uid {@min 32}{@max 32}
* @param array $request_data
*/
public function doPut($rol_uid, $request_data)
public function doPut($rol_uid, array $request_data)
{
try {
$arrayData = $this->role->update($rol_uid, $request_data);

View File

@@ -0,0 +1,81 @@
<?php
namespace ProcessMaker\Services\Api\Role;
use \ProcessMaker\Services\Api;
use \Luracast\Restler\RestException;
/**
* Role\User Api Controller
*
* @protected
*/
class User extends Api
{
private $roleUser;
/**
* Constructor of the class
*
* return void
*/
public function __construct()
{
try {
$this->roleUser = new \ProcessMaker\BusinessModel\Role\User();
$this->roleUser->setFormatFieldNameInUppercase(false);
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* @url GET /:rol_uid/users
* @url GET /:rol_uid/available-users
*
* @param string $rol_uid {@min 32}{@max 32}
*/
public function doGetUsers($rol_uid, $filter = null, $start = null, $limit = null)
{
try {
$response = $this->roleUser->getUsers($rol_uid, (preg_match("/^.*\/users$/", $this->restler->url))? "USERS" : "AVAILABLE-USERS", array("filter" => $filter), null, null, $start, $limit);
return $response;
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* @url POST /:rol_uid/user
*
* @param string $rol_uid {@min 32}{@max 32}
* @param array $request_data
*
* @status 201
*/
public function doPostUser($rol_uid, array $request_data)
{
try {
$arrayData = $this->roleUser->create($rol_uid, $request_data);
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
/**
* @url DELETE /:rol_uid/user/:usr_uid
*
* @param string $rol_uid {@min 32}{@max 32}
* @param string $usr_uid {@min 32}{@max 32}
*/
public function doDeleteUser($rol_uid, $usr_uid)
{
try {
$this->roleUser->delete($rol_uid, $usr_uid);
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
}
}