Merged colosa/processmaker into master
This commit is contained in:
42
Rakefile
42
Rakefile
@@ -7,7 +7,12 @@ end
|
||||
|
||||
|
||||
task :required do
|
||||
#puts "Executind task: required"
|
||||
begin
|
||||
require 'json'
|
||||
rescue LoadError
|
||||
puts "JSON gem not found.\nInstall it by running 'gem install json'"
|
||||
exit(1)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -25,7 +30,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"
|
||||
@@ -44,8 +49,10 @@ task :build => [:required] do
|
||||
buildPmUi(Dir.pwd + "/vendor/colosa/pmUI", targetDir, mode)
|
||||
buildMafe(Dir.pwd + "/vendor/colosa/MichelangeloFE", targetDir, mode)
|
||||
|
||||
hashVendors = getHash(Dir.pwd + "/vendor/colosa/pmUI")+'-'+getHash(Dir.pwd + "/vendor/colosa/MichelangeloFE")
|
||||
pmuiHash = getHash(Dir.pwd + "/vendor/colosa/pmUI")
|
||||
mafeHash = getHash(Dir.pwd + "/vendor/colosa/MichelangeloFE")
|
||||
|
||||
hashVendors = pmuiHash+"-"+mafeHash
|
||||
## Building minified JS Files
|
||||
puts "Building file: " + "/js/mafe-#{hashVendors}.js".cyan
|
||||
mafeCompresedFile = targetDir + "/js/mafe-#{hashVendors}.js"
|
||||
@@ -75,11 +82,22 @@ task :build => [:required] do
|
||||
end
|
||||
|
||||
# Create buildhash file
|
||||
puts "Generated file: " + "/buildhash".cyan
|
||||
puts "create file: " + "/buildhash".cyan
|
||||
File.open(targetDir+"/buildhash", 'w+') do |writeFile|
|
||||
writeFile.write hashVendors
|
||||
end
|
||||
|
||||
puts "create file: " + "/versions".cyan
|
||||
versions = {
|
||||
:pmui_ver => getVersion(Dir.pwd + "/vendor/colosa/pmUI"),
|
||||
:pmui_hash => pmuiHash,
|
||||
:mafe_ver => getVersion(Dir.pwd + "/vendor/colosa/MichelangeloFE"),
|
||||
:mafe_hash => mafeHash
|
||||
}
|
||||
File.open(targetDir+"/versions", 'w+') do |writeFile|
|
||||
writeFile.write versions.to_json
|
||||
end
|
||||
|
||||
puts "-- DONE --\n".bold
|
||||
#task argv1.to_sym do ; end
|
||||
end
|
||||
@@ -112,7 +130,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 +187,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 +197,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 +330,4 @@ class String
|
||||
def bold; "\033[1m#{self}\033[22m" end
|
||||
def reverse_color; "\033[7m#{self}\033[27m" end
|
||||
end
|
||||
|
||||
|
||||
230
features/backend/admin_setup/roles/basic_tests_roles.feature
Normal file
230
features/backend/admin_setup/roles/basic_tests_roles.feature
Normal 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
|
||||
631
features/backend/admin_setup/roles/main_tests_roles.feature
Normal file
631
features/backend/admin_setup/roles/main_tests_roles.feature
Normal file
@@ -0,0 +1,631 @@
|
||||
@ProcessMakerMichelangelo @RestAPI
|
||||
Feature: Roles Main Tests
|
||||
Requirements:
|
||||
a workspace with the three roles created already loaded
|
||||
|
||||
Background:
|
||||
Given that I have a valid access_token
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
Scenario Outline: Get list of Roles using different filters
|
||||
Given I request "roles?filter=<filter>&start=<start>&limit=<limit>"
|
||||
Then the response status code should be <http_code>
|
||||
And the response charset is "UTF-8"
|
||||
And the content type is "application/json"
|
||||
And the type is "<type>"
|
||||
And the response has <records> records
|
||||
|
||||
Examples:
|
||||
|
||||
| test_description | filter | start | limit | records | http_code | type |
|
||||
| lowercase | admin | 0 | 1 | 1 | 200 | array |
|
||||
| uppercase | ADMIN | 0 | 1 | 1 | 200 | array |
|
||||
| limit=3 | a | 0 | 3 | 3 | 200 | array |
|
||||
| limit and start | a | 1 | 2 | 2 | 200 | array |
|
||||
| high number for start | a | 1000 | 1 | 0 | 200 | array |
|
||||
| high number for start | a | 1000 | 0 | 0 | 200 | array |
|
||||
| empty result | xyz | 0 | 0 | 0 | 200 | array |
|
||||
| empty string | | 0 | 10000 | 3 | 200 | array |
|
||||
| empty string | | 1 | 2 | 2 | 200 | array |
|
||||
| invalid start | a | b | c | 0 | 400 | string |
|
||||
| invalid limit | a | 0 | c | 0 | 400 | string |
|
||||
| search 0 | 0 | 0 | 0 | 0 | 200 | array |
|
||||
| search 0 | 0 | 0 | 100 | 0 | 200 | array |
|
||||
| negative numbers | a | -10 | -20 | 0 | 400 | string |
|
||||
| real numbers | a | 0.0 | 1.0 | 1 | 200 | string |
|
||||
| real numbers | a | 0.0 | 0.0 | 0 | 200 | string |
|
||||
| real numbers | a | 0.1 | 1.4599 | 0 | 400 | string |
|
||||
| real numbers | a | 1.5 | 1.4599 | 0 | 400 | string |
|
||||
|
||||
|
||||
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/<rol_uid>"
|
||||
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 | rol_code | rol_name | rol_status |
|
||||
| Review rol PROCESSMAKER_ADMIN | 00000000000000000000000000000002 | PROCESSMAKER_ADMIN | System Administrator | ACTIVE |
|
||||
| Review rol PROCESSMAKER_OPERATOR | 00000000000000000000000000000003 | PROCESSMAKER_OPERATOR | Operator | ACTIVE |
|
||||
| Review rol PROCESSMAKER_MANAGER | 00000000000000000000000000000004 | PROCESSMAKER_MANAGER | Manager | ACTIVE |
|
||||
|
||||
|
||||
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_OPERATOR | s | ACTIVE |
|
||||
| Create Role with name large | 2 | PROCESSMAKER_OPERATOR | Esta es una prueba de un rol con nombre largo | ACTIVE |
|
||||
| Create Role with Code Adminsitrator | 3 | PROCESSMAKER_ADMINISTRATOR | Rol con code administrator | ACTIVE |
|
||||
| Create Role with Code Manager | 4 | PROCESSMAKER_MANAGER | Rol con code manager | ACTIVE |
|
||||
| Create Role with Code Adminsitrator/inactive | 5 | PROCESSMAKER_ADMINISTRATOR | Rol con code administrator/inactive | INACTIVE |
|
||||
| Create Role with Code Operator/inactive | 6 | PROCESSMAKER_OPERATOR | Rol con code operator/inactive | INACTIVE |
|
||||
| Create Role with Code Manager/inactive | 7 | PROCESSMAKER_MANAGER | Rol con code manager/inactive | INACTIVE |
|
||||
| Create Role with character special | 8 | PROCESSMAKER_ADMINISTRATOR | Rol !@##$%&*()'][' 123 | ACTIVE |
|
||||
|
||||
|
||||
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 11 records
|
||||
|
||||
|
||||
#Assign users to role
|
||||
|
||||
#Scenario Outline: List assigned Users to Role & List available Users to assign to Role
|
||||
# Given that I want to get a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
|
||||
# And I request "role/<rol_uid_number>/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 <records> records
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# | rol_uid_number | records |
|
||||
# | 1 | 0 |
|
||||
# | 2 | 0 |
|
||||
# | 3 | 0 |
|
||||
# | 4 | 0 |
|
||||
# | 5 | 0 |
|
||||
# | 6 | 0 |
|
||||
# | 7 | 0 |
|
||||
# | 8 | 0 |
|
||||
#
|
||||
#
|
||||
#Scenario Outline: List assigned Users to Role & List available Users to assign to Role, using different filters
|
||||
# Given I request "roles/00000000000000000000000000000003/users?filter=<filter>&start=<start>&limit=<limit>"
|
||||
# Then the response status code should be <http_code>
|
||||
# And the response charset is "UTF-8"
|
||||
# And the content type is "application/json"
|
||||
# And the type is "<type>"
|
||||
# And the response has <records> records
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# | test_description | filter | start | limit | records | http_code | type |
|
||||
# | lowercase | amy | 0 | 1 | 1 | 200 | array |
|
||||
# | uppercase | AMY | 0 | 1 | 1 | 200 | array |
|
||||
# | limit=3 | a | 0 | 3 | 3 | 200 | array |
|
||||
# | limit and start | a | 1 | 2 | 2 | 200 | array |
|
||||
# | high number for start | a | 1000 | 1 | 0 | 200 | array |
|
||||
# | high number for start | a | 1000 | 0 | 0 | 200 | array |
|
||||
# | empty result | xyz | 0 | 0 | 0 | 200 | array |
|
||||
# | empty string | | 0 | 10000 | 61 | 200 | array |
|
||||
# | empty string | | 1 | 2 | 2 | 200 | array |
|
||||
# | invalid start | a | b | c | 0 | 400 | string |
|
||||
# | invalid limit | a | 0 | c | 0 | 400 | string |
|
||||
# | search 0 | 0 | 0 | 0 | 0 | 200 | array |
|
||||
# | search 0 | 0 | 0 | 100 | 0 | 200 | array |
|
||||
# | negative numbers | a | -10 | -20 | 0 | 400 | string |
|
||||
# | real numbers | a | 0.0 | 1.0 | 1 | 200 | string |
|
||||
# | real numbers | a | 0.0 | 0.0 | 0 | 200 | string |
|
||||
# | real numbers | a | 0.1 | 1.4599 | 0 | 400 | string |
|
||||
# | real numbers | a | 1.5 | 1.4599 | 0 | 400 | string |
|
||||
#
|
||||
#
|
||||
#Scenario Outline: List assigned Users to Role & List available Users to assign to Role, using different filters
|
||||
# Given I request "roles/00000000000000000000000000000002/available-users?filter=<filter>&start=<start>&limit=<limit>"
|
||||
# Then the response status code should be <http_code>
|
||||
# And the response charset is "UTF-8"
|
||||
# And the content type is "application/json"
|
||||
# And the type is "<type>"
|
||||
# And the response has <records> records
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# | test_description | filter | start | limit | records | http_code | type |
|
||||
# | lowercase | amy | 0 | 1 | 1 | 200 | array |
|
||||
# | uppercase | AMY | 0 | 1 | 1 | 200 | array |
|
||||
# | limit=3 | a | 0 | 3 | 3 | 200 | array |
|
||||
# | limit and start | a | 1 | 2 | 2 | 200 | array |
|
||||
# | high number for start | a | 1000 | 1 | 0 | 200 | array |
|
||||
# | high number for start | a | 1000 | 0 | 0 | 200 | array |
|
||||
# | empty result | xyz | 0 | 0 | 0 | 200 | array |
|
||||
# | empty string | | 0 | 10000 | 61 | 200 | array |
|
||||
# | empty string | | 1 | 2 | 2 | 200 | array |
|
||||
# | invalid start | a | b | c | 0 | 400 | string |
|
||||
# | invalid limit | a | 0 | c | 0 | 400 | string |
|
||||
# | search 0 | 0 | 0 | 0 | 0 | 200 | array |
|
||||
# | search 0 | 0 | 0 | 100 | 0 | 200 | array |
|
||||
# | negative numbers | a | -10 | -20 | 0 | 400 | string |
|
||||
# | real numbers | a | 0.0 | 1.0 | 1 | 200 | string |
|
||||
# | real numbers | a | 0.0 | 0.0 | 0 | 200 | string |
|
||||
# | real numbers | a | 0.1 | 1.4599 | 0 | 400 | string |
|
||||
# | real numbers | a | 1.5 | 1.4599 | 0 | 400 | string |
|
||||
#
|
||||
#
|
||||
#Scenario Outline: Assign User to Role
|
||||
# Given POST this data:
|
||||
# """
|
||||
# {
|
||||
# "usr_uid": "<usr_uid>"
|
||||
# }
|
||||
# """
|
||||
# And I request "role/rol_uid/user" with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
|
||||
# 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"
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# | Description | rol_uid_number | usr_uid |
|
||||
# | Assign user "aaron" | 1 | 51049032352d56710347233042615067 |
|
||||
# | Assign user "adam" | 2 | 44811996752d567110634a1013636964 |
|
||||
# | Assign user "alexis" | 3 | 61364466452d56711adb378002702791 |
|
||||
# | Assign user "amy" | 4 | 25286582752d56713231082039265791 |
|
||||
# | Assign user "brianna" | 5 | 86021298852d56716b85f73067566944 |
|
||||
# | Assign user "carter" | 6 | 32444503652d5671778fd20059078570 |
|
||||
# | Assign user "emily" | 7 | 34289569752d5673d310e82094574281 |
|
||||
# | Assign user "olivia" | 8 | 73005191052d56727901138030694610 |
|
||||
#
|
||||
#
|
||||
#Scenario Outline: List assigned Users to Role & List available Users to assign to Role
|
||||
# Given that I want to get a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
|
||||
# And I request "role/<rol_uid_number>/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 <records> records
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# | rol_uid_number | records |
|
||||
# | 1 | 1 |
|
||||
# | 2 | 1 |
|
||||
# | 3 | 1 |
|
||||
# | 4 | 1 |
|
||||
# | 5 | 1 |
|
||||
# | 6 | 1 |
|
||||
# | 7 | 1 |
|
||||
# | 8 | 1 |
|
||||
#
|
||||
#
|
||||
#Scenario Outline: Unassign User of the Role
|
||||
# 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/rol_uid/users/<usr_uid>"
|
||||
# And the content type is "application/json"
|
||||
# Then the response status code should be 200
|
||||
# And the response charset is "UTF-8"
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# | Description | rol_uid_number | usr_uid |
|
||||
# | Unassign user "aaron" | 1 | 51049032352d56710347233042615067 |
|
||||
# | Unassign user "adam" | 2 | 44811996752d567110634a1013636964 |
|
||||
# | Unassign user "alexis" | 3 | 61364466452d56711adb378002702791 |
|
||||
# | Unassign user "amy" | 4 | 25286582752d56713231082039265791 |
|
||||
# | Unassign user "brianna" | 5 | 86021298852d56716b85f73067566944 |
|
||||
# | Unassign user "carter" | 6 | 32444503652d5671778fd20059078570 |
|
||||
# | Unassign user "emily" | 7 | 34289569752d5673d310e82094574281 |
|
||||
# | Unassign user "olivia" | 8 | 73005191052d56727901138030694610 |
|
||||
#
|
||||
#
|
||||
#Scenario Outline: List assigned Users to Role & List available Users to assign to Role
|
||||
# Given that I want to get a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
|
||||
# And I request "role/<rol_uid_number>/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 <records> records
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# | rol_uid_number | records |
|
||||
# | 1 | 0 |
|
||||
# | 2 | 0 |
|
||||
# | 3 | 0 |
|
||||
# | 4 | 0 |
|
||||
# | 5 | 0 |
|
||||
# | 6 | 0 |
|
||||
# | 7 | 0 |
|
||||
# | 8 | 0 |
|
||||
|
||||
#Culminacion de los endpoint de asignacion de usuarios
|
||||
|
||||
#Role and Permission
|
||||
|
||||
Scenario Outline: List assigned Permissions to Role & List available Permissions to assign to Role
|
||||
Given that I want to get a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
|
||||
And I request "role/rol_uid/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 <records> records
|
||||
|
||||
Examples:
|
||||
|
||||
| rol_uid_number | records |
|
||||
| 1 | 0 |
|
||||
| 2 | 0 |
|
||||
| 3 | 0 |
|
||||
| 4 | 0 |
|
||||
| 5 | 0 |
|
||||
| 6 | 0 |
|
||||
| 7 | 0 |
|
||||
| 8 | 0 |
|
||||
|
||||
|
||||
Scenario Outline: List assigned Permissions to Role & List available Permissions to assign to Role, using different filters
|
||||
Given I request "roles/00000000000000000000000000000004/users?filter=<filter>&start=<start>&limit=<limit>"
|
||||
Then the response status code should be <http_code>
|
||||
And the response charset is "UTF-8"
|
||||
And the content type is "application/json"
|
||||
And the type is "<type>"
|
||||
And the response has <records> records
|
||||
|
||||
Examples:
|
||||
|
||||
| test_description | filter | start | limit | records | http_code | type |
|
||||
| lowercase | cases | 0 | 1 | 1 | 200 | array |
|
||||
| uppercase | CASES | 0 | 1 | 1 | 200 | array |
|
||||
| limit=3 | a | 0 | 3 | 3 | 200 | array |
|
||||
| limit and start | a | 1 | 2 | 2 | 200 | array |
|
||||
| high number for start | a | 1000 | 1 | 0 | 200 | array |
|
||||
| high number for start | a | 1000 | 0 | 0 | 200 | array |
|
||||
| empty result | xyz | 0 | 0 | 0 | 200 | array |
|
||||
| empty string | | 0 | 10000 | 13 | 200 | array |
|
||||
| empty string | | 1 | 2 | 2 | 200 | array |
|
||||
| invalid start | a | b | c | 0 | 400 | string |
|
||||
| invalid limit | a | 0 | c | 0 | 400 | string |
|
||||
| search 0 | 0 | 0 | 0 | 0 | 200 | array |
|
||||
| search 0 | 0 | 0 | 100 | 0 | 200 | array |
|
||||
| negative numbers | a | -10 | -20 | 0 | 400 | string |
|
||||
| real numbers | a | 0.0 | 1.0 | 1 | 200 | string |
|
||||
| real numbers | a | 0.0 | 0.0 | 0 | 200 | string |
|
||||
| real numbers | a | 0.1 | 1.4599 | 0 | 400 | string |
|
||||
| real numbers | a | 1.5 | 1.4599 | 0 | 400 | string |
|
||||
|
||||
|
||||
Scenario Outline: List assigned Permissions to Role & List available Permissions to assign to Role, using different filters
|
||||
Given I request "roles/00000000000000000000000000000003/available-users?filter=<filter>&start=<start>&limit=<limit>"
|
||||
Then the response status code should be <http_code>
|
||||
And the response charset is "UTF-8"
|
||||
And the content type is "application/json"
|
||||
And the type is "<type>"
|
||||
And the response has <records> records
|
||||
|
||||
Examples:
|
||||
|
||||
| test_description | filter | start | limit | records | http_code | type |
|
||||
| lowercase | add | 0 | 1 | 1 | 200 | array |
|
||||
| uppercase | ADD | 0 | 1 | 1 | 200 | array |
|
||||
| limit=3 | a | 0 | 3 | 3 | 200 | array |
|
||||
| limit and start | a | 1 | 2 | 2 | 200 | array |
|
||||
| high number for start | a | 1000 | 1 | 0 | 200 | array |
|
||||
| high number for start | a | 1000 | 0 | 0 | 200 | array |
|
||||
| empty result | xyz | 0 | 0 | 0 | 200 | array |
|
||||
| empty string | | 0 | 10000 | 14 | 200 | array |
|
||||
| empty string | | 1 | 2 | 2 | 200 | array |
|
||||
| invalid start | a | b | c | 0 | 400 | string |
|
||||
| invalid limit | a | 0 | c | 0 | 400 | string |
|
||||
| search 0 | 0 | 0 | 0 | 0 | 200 | array |
|
||||
| search 0 | 0 | 0 | 100 | 0 | 200 | array |
|
||||
| negative numbers | a | -10 | -20 | 0 | 400 | string |
|
||||
| real numbers | a | 0.0 | 1.0 | 1 | 200 | string |
|
||||
| real numbers | a | 0.0 | 0.0 | 0 | 200 | string |
|
||||
| real numbers | a | 0.1 | 1.4599 | 0 | 400 | string |
|
||||
| real numbers | a | 1.5 | 1.4599 | 0 | 400 | string |
|
||||
|
||||
|
||||
Scenario Outline: List assigned Permissions to Role & List available Permissions to assign to Role
|
||||
Given that I want to get a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
|
||||
And I request "role/rol_uid/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 <records> records
|
||||
|
||||
Examples:
|
||||
|
||||
| rol_uid_number | records |
|
||||
| 1 | 17 |
|
||||
| 2 | 17 |
|
||||
| 3 | 17 |
|
||||
| 4 | 17 |
|
||||
| 5 | 17 |
|
||||
| 6 | 17 |
|
||||
| 7 | 17 |
|
||||
| 8 | 17 |
|
||||
|
||||
|
||||
Scenario Outline: Assign Permission "PM_DASHBOARD" to Role
|
||||
Given POST this data:
|
||||
"""
|
||||
{
|
||||
"per_uid": "<per_uid>"
|
||||
}
|
||||
"""
|
||||
And I request "role/rol_uid/permission" with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
|
||||
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"
|
||||
|
||||
Examples:
|
||||
|
||||
| Description | rol_uid_number | per_uid |
|
||||
| Assign Permissions "PM_LOGIN" to rol 1 | 1 | 00000000000000000000000000000001 |
|
||||
| Assign Permissions "PM_SETUP" to rol 1 | 1 | 00000000000000000000000000000002 |
|
||||
| Assign Permissions "PM_USERS" to rol 1 | 1 | 00000000000000000000000000000003 |
|
||||
| Assign Permissions "PM_FACTORY" to rol 1 | 1 | 00000000000000000000000000000004 |
|
||||
| Assign Permissions "PM_CASES" to rol 1 | 1 | 00000000000000000000000000000005 |
|
||||
| Assign Permissions "PM_LOGIN" to rol 2 | 2 | 00000000000000000000000000000001 |
|
||||
| Assign Permissions "PM_ALLCASES" to rol 2 | 2 | 00000000000000000000000000000006 |
|
||||
| Assign Permissions "PM_REPORTS" to rol 2 | 2 | 00000000000000000000000000000008 |
|
||||
| Assign Permissions "PM_REASSIGNCASE" to rol 2 | 2 | 00000000000000000000000000000007 |
|
||||
| Assign Permissions "PM_SUPERVISOR" to rol 2 | 2 | 00000000000000000000000000000009 |
|
||||
| Assign Permissions "PM_SETUP_ADVANCE" to rol 3 | 3 | 00000000000000000000000000000010 |
|
||||
| Assign Permissions "PM_DASHBOARD" to rol 4 | 4 | 00000000000000000000000000000011 |
|
||||
| Assign Permissions "PM_WEBDAV" to rol 5 | 5 | 00000000000000000000000000000012 |
|
||||
| Assign Permissions "PM_DELETECASE" to rol 6 | 6 | 00000000000000000000000000000013 |
|
||||
| Assign Permissions "PM_EDITPERSONALINFO" to rol 7 | 7 | 00000000000000000000000000000014 |
|
||||
| Assign Permissions "PM_FOLDERS_VIEW" to rol 8 | 8 | 00000000000000000000000000000015 |
|
||||
| Assign Permissions "PM_FOLDERS_ADD_FOLDER" to rol 8 | 8 | 00000000000000000000000000000016 |
|
||||
| Assign Permissions "PM_FOLDERS_ADD_FILE" to rol 8 | 8 | 00000000000000000000000000000017 |
|
||||
| Assign Permissions "PM_CANCELCASE" to rol 8 | 8 | 00000000000000000000000000000018 |
|
||||
| Assign Permissions "PM_FOLDER_DEL" to rol 8 | 8 | 00000000000000000000000000000019 |
|
||||
|
||||
|
||||
Scenario Outline: List assigned Permissions to Role & List available Permissions to assign to Role
|
||||
Given that I want to get a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
|
||||
And I request "role/rol_uid/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 <records> records
|
||||
|
||||
Examples:
|
||||
|
||||
| rol_uid_number | records |
|
||||
| 1 | 5 |
|
||||
| 2 | 5 |
|
||||
| 3 | 1 |
|
||||
| 4 | 1 |
|
||||
| 5 | 1 |
|
||||
| 6 | 1 |
|
||||
| 7 | 1 |
|
||||
| 8 | 5 |
|
||||
|
||||
|
||||
Scenario Outline: List assigned Permissions to Role & List available Permissions to assign to Role
|
||||
Given that I want to get a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
|
||||
And I request "role/rol_uid/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 <records> records
|
||||
|
||||
Examples:
|
||||
|
||||
| rol_uid_number | records |
|
||||
| 1 | 12 |
|
||||
| 2 | 12 |
|
||||
| 3 | 16 |
|
||||
| 4 | 16 |
|
||||
| 5 | 16 |
|
||||
| 6 | 16 |
|
||||
| 7 | 16 |
|
||||
| 8 | 12 |
|
||||
|
||||
|
||||
Scenario Outline: Unassign Permission of the Role
|
||||
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/rol_uid/permission/per_uid"
|
||||
And the content type is "application/json"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
|
||||
Examples:
|
||||
|
||||
| Description | rol_uid_number | per_uid |
|
||||
| Unassign Permissions "PM_LOGIN" to rol 1 | 1 | 00000000000000000000000000000001 |
|
||||
| Unassign Permissions "PM_SETUP" to rol 1 | 1 | 00000000000000000000000000000002 |
|
||||
| Unassign Permissions "PM_USERS" to rol 1 | 1 | 00000000000000000000000000000003 |
|
||||
| Unassign Permissions "PM_FACTORY" to rol 1 | 1 | 00000000000000000000000000000004 |
|
||||
| Unassign Permissions "PM_CASES" to rol 1 | 1 | 00000000000000000000000000000005 |
|
||||
| Unassign Permissions "PM_LOGIN" to rol 2 | 2 | 00000000000000000000000000000001 |
|
||||
| Unassign Permissions "PM_ALLCASES" to rol 2 | 2 | 00000000000000000000000000000006 |
|
||||
| Unassign Permissions "PM_REPORTS" to rol 2 | 2 | 00000000000000000000000000000008 |
|
||||
| Unassign Permissions "PM_REASSIGNCASE" to rol 2 | 2 | 00000000000000000000000000000007 |
|
||||
| Unassign Permissions "PM_SUPERVISOR" to rol 2 | 2 | 00000000000000000000000000000009 |
|
||||
| Unassign Permissions "PM_SETUP_ADVANCE" to rol 3 | 3 | 00000000000000000000000000000010 |
|
||||
| Unassign Permissions "PM_DASHBOARD" to rol 4 | 4 | 00000000000000000000000000000011 |
|
||||
| Unassign Permissions "PM_WEBDAV" to rol 5 | 5 | 00000000000000000000000000000012 |
|
||||
| Unassign Permissions "PM_DELETECASE" to rol 6 | 6 | 00000000000000000000000000000013 |
|
||||
| Unassign Permissions "PM_EDITPERSONALINFO" to rol 7 | 7 | 00000000000000000000000000000014 |
|
||||
| Unassign Permissions "PM_FOLDERS_VIEW" to rol 8 | 8 | 00000000000000000000000000000015 |
|
||||
| Unassign Permissions "PM_FOLDERS_ADD_FOLDER" to rol 8 | 8 | 00000000000000000000000000000016 |
|
||||
| Unassign Permissions "PM_FOLDERS_ADD_FILE" to rol 8 | 8 | 00000000000000000000000000000017 |
|
||||
| Unassign Permissions "PM_CANCELCASE" to rol 8 | 8 | 00000000000000000000000000000018 |
|
||||
| Unassign Permissions "PM_FOLDER_DEL" to rol 8 | 8 | 00000000000000000000000000000019 |
|
||||
|
||||
|
||||
Scenario Outline: List assigned Permissions to Role & List available Permissions to assign to Role
|
||||
Given that I want to get a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
|
||||
And I request "role/rol_uid/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 <records> records
|
||||
|
||||
Examples:
|
||||
|
||||
| rol_uid_number | records |
|
||||
| 1 | 0 |
|
||||
| 2 | 0 |
|
||||
| 3 | 0 |
|
||||
| 4 | 0 |
|
||||
| 5 | 0 |
|
||||
| 6 | 0 |
|
||||
| 7 | 0 |
|
||||
| 8 | 0 |
|
||||
|
||||
|
||||
Scenario Outline: List assigned Permissions to Role & List available Permissions to assign to Role
|
||||
Given that I want to get a resource with the key "rol_uid" stored in session array as variable "rol_uid_<rol_uid_number>"
|
||||
And I request "role/rol_uid/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 <records> records
|
||||
|
||||
Examples:
|
||||
|
||||
| rol_uid_number | records |
|
||||
| 1 | 17 |
|
||||
| 2 | 17 |
|
||||
| 3 | 17 |
|
||||
| 4 | 17 |
|
||||
| 5 | 17 |
|
||||
| 6 | 17 |
|
||||
| 7 | 17 |
|
||||
| 8 | 17 |
|
||||
#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_OPERATOR | update_sample | INACTIVE |
|
||||
| Update name of role created in this script | 5 | PROCESSMAKER_ADMINISTRATOR | update2 | ACTIVE |
|
||||
| Update name of role created in this script | 8 | PROCESSMAKER_ADMINISTRATOR | update*'123 | 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_OPERATOR | update_sample | INACTIVE |
|
||||
| Update name of role created in this script | 5 | PROCESSMAKER_ADMINISTRATOR | update2 | ACTIVE |
|
||||
| Update name of role created in this script | 8 | PROCESSMAKER_ADMINISTRATOR | update*'123 | INACTIVE |
|
||||
|
||||
|
||||
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 11 records
|
||||
|
||||
|
||||
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 |
|
||||
| 2 |
|
||||
| 3 |
|
||||
| 4 |
|
||||
| 5 |
|
||||
| 6 |
|
||||
| 7 |
|
||||
| 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 3 records
|
||||
@@ -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 |
|
||||
@@ -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"
|
||||
|
||||
@@ -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 |
|
||||
@@ -97,7 +97,7 @@ class Translation extends BaseTranslation
|
||||
"$dateTo",
|
||||
Criteria::LESS_EQUAL
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
// end filter
|
||||
@@ -180,10 +180,10 @@ class Translation extends BaseTranslation
|
||||
//$json = new Services_JSON(); DEPRECATED
|
||||
$f = fopen( $cacheFileJS, 'w' );
|
||||
if ($f == false) {
|
||||
error_log("Error: Cannot write into cachefilejs: $cacheFileJS\n");
|
||||
error_log("Error: Cannot write into cachefilejs: $cacheFileJS\n");
|
||||
} else {
|
||||
fwrite( $f, "var G_STRINGS =" . Bootstrap::json_encode( $translationJS ) . ";\n");
|
||||
fclose( $f );
|
||||
fwrite( $f, "var G_STRINGS =" . Bootstrap::json_encode( $translationJS ) . ";\n");
|
||||
fclose( $f );
|
||||
}
|
||||
|
||||
$res['cacheFile'] = $cacheFile;
|
||||
@@ -215,7 +215,7 @@ class Translation extends BaseTranslation
|
||||
|
||||
foreach ($tranlations as $key => $row) {
|
||||
if ($row->getTrnCategory() === 'LABEL') {
|
||||
$translation[$row->getTrnLang()][$row->getTrnId()] = $row->getTrnValue();
|
||||
$translation[$row->getTrnLang()][$row->getTrnId()] = $row->getTrnValue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,10 +228,10 @@ class Translation extends BaseTranslation
|
||||
|
||||
$f = fopen( $cacheFileMafe, 'w' );
|
||||
if ($f == false) {
|
||||
error_log("Error: Cannot write into cacheFileMafe: $cacheFileMafe\n");
|
||||
error_log("Error: Cannot write into cacheFileMafe: $cacheFileMafe\n");
|
||||
} else {
|
||||
fwrite( $f, "var __TRANSLATIONMAFE = " . Bootstrap::json_encode( $translation ) . ";\n");
|
||||
fclose( $f );
|
||||
fwrite( $f, "var __TRANSLATIONMAFE = " . Bootstrap::json_encode( $translation ) . ";\n");
|
||||
fclose( $f );
|
||||
}
|
||||
|
||||
$res['cacheFileMafe'] = $cacheFileMafe;
|
||||
@@ -622,7 +622,7 @@ class Translation extends BaseTranslation
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function generateTransaltionMafe ($lang='en')
|
||||
{
|
||||
if (!file_exists(PATH_TRUNK .'vendor/colosa/MichelangeloFE/' . 'labels.php')) {
|
||||
@@ -636,4 +636,3 @@ class Translation extends BaseTranslation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -730,6 +730,15 @@ class Main extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (file_exists(PATH_HTML . "lib/versions")) {
|
||||
$versions = json_decode(file_get_contents(PATH_HTML . "lib/versions"), true);
|
||||
$pmuiVer = $versions["pmui_ver"];
|
||||
$mafeVer = $versions["mafe_ver"];
|
||||
} else {
|
||||
$pmuiVer = $mafeVer = "(unknown)";
|
||||
}
|
||||
|
||||
$sysSection = G::loadTranslation('ID_SYSTEM_INFO' );
|
||||
$pmSection = G::LoadTranslation('ID_PROCESS_INFORMATION');
|
||||
|
||||
@@ -740,6 +749,8 @@ class Main extends Controller
|
||||
$systemName = SYSTEM_NAME;
|
||||
}
|
||||
$properties[] = array ($systemName. ' Ver.', System::getVersion() . $ee, $pmSection);
|
||||
$properties[] = array("PMUI JS Lib. Ver.", $pmuiVer, $pmSection);
|
||||
$properties[] = array("MAFE JS Lib. Ver.", $mafeVer, $pmSection);
|
||||
|
||||
if (file_exists(PATH_DATA. 'log/upgrades.log')) {
|
||||
$properties[] = array (G::LoadTranslation('ID_UPGRADES_PATCHES'), '<a href="#" onclick="showUpgradedLogs(); return false;">' . G::LoadTranslation( 'ID_UPGRADE_VIEW_LOG') . '</a>' ,$pmSection);
|
||||
|
||||
@@ -25,7 +25,7 @@ class Cases
|
||||
{
|
||||
Validator::isArray($dataList, '$dataList');
|
||||
if (!isset($dataList["userId"])) {
|
||||
throw (new \Exception("The user with userId: '' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_USER_NOT_EXIST", array('userId',''))));
|
||||
} else {
|
||||
Validator::usrUid($dataList["userId"], "userId");
|
||||
}
|
||||
@@ -53,7 +53,7 @@ class Cases
|
||||
|
||||
$valuesCorrect = array('todo', 'draft', 'paused', 'sent', 'selfservice', 'unassigned', 'search');
|
||||
if (!in_array($action, $valuesCorrect)) {
|
||||
throw (new \Exception('The value for $action is incorrect.'));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_INCORRECT_VALUE_ACTION")));
|
||||
}
|
||||
|
||||
$start = (int)$start;
|
||||
@@ -669,7 +669,7 @@ class Cases
|
||||
$case = new \Cases();
|
||||
$fields = $case->loadCase($app_uid);
|
||||
if ($fields['APP_STATUS'] == 'CANCELLED') {
|
||||
throw (new \Exception("The case '$app_uid' is already canceled"));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_CASE_ALREADY_CANCELED", array($app_uid))));
|
||||
}
|
||||
$case->cancelCase( $app_uid, $del_index, $usr_uid );
|
||||
}
|
||||
@@ -697,7 +697,7 @@ class Cases
|
||||
$case = new \Cases();
|
||||
$fields = $case->loadCase($app_uid);
|
||||
if ($fields['APP_STATUS'] == 'CANCELLED') {
|
||||
throw (new \Exception("The case '$app_uid' is canceled"));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_CASE_IS_CANCELED", array($app_uid))));
|
||||
}
|
||||
|
||||
if ($del_index === false) {
|
||||
@@ -1413,7 +1413,7 @@ class Cases
|
||||
$respView = $case->getAllObjectsFrom( $pro_uid, $app_uid, $tas_uid, $usr_uid, 'VIEW' );
|
||||
$respBlock = $case->getAllObjectsFrom( $pro_uid, $app_uid, $tas_uid, $usr_uid, 'BLOCK' );
|
||||
if ($respView['CASES_NOTES'] == 0 && $respBlock['CASES_NOTES'] == 0) {
|
||||
throw (new \Exception("You do not have permission to cases notes."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_CASES_NOTES_NO_PERMISSIONS")));
|
||||
}
|
||||
|
||||
if ($sort != 'APP_NOTE.NOTE_DATE') {
|
||||
@@ -1496,7 +1496,7 @@ class Cases
|
||||
|
||||
Validator::isString($note_content, '$note_content');
|
||||
if (strlen($note_content) > 500) {
|
||||
throw (new \Exception("Invalid value for '$note_content', the permitted maximum length of 500 characters."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_INVALID_MAX_PERMITTED", array($note_content,'500'))));
|
||||
}
|
||||
|
||||
Validator::isBoolean($send_mail, '$send_mail');
|
||||
@@ -1508,7 +1508,7 @@ class Cases
|
||||
$respView = $case->getAllObjectsFrom( $pro_uid, $app_uid, $tas_uid, $usr_uid, 'VIEW' );
|
||||
$respBlock = $case->getAllObjectsFrom( $pro_uid, $app_uid, $tas_uid, $usr_uid, 'BLOCK' );
|
||||
if ($respView['CASES_NOTES'] == 0 && $respBlock['CASES_NOTES'] == 0) {
|
||||
throw (new \Exception("You do not have permission to cases notes."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_CASES_NOTES_NO_PERMISSIONS")));
|
||||
}
|
||||
|
||||
$note_content = addslashes($note_content);
|
||||
|
||||
@@ -105,21 +105,21 @@ class DataBaseConnection
|
||||
$typesExists[] = $value['id'];
|
||||
}
|
||||
if (!in_array($dataDBConnection['DBS_TYPE'], $typesExists)) {
|
||||
throw (new \Exception("The dababase connection with dbs_type: '" . $dataDBConnection['DBS_TYPE'] . " is invalid"));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_DBC_TYPE_INVALID", array($dataDBConnection['DBS_TYPE']))));
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($dataDBConnection['DBS_SERVER']) && $dataDBConnection['DBS_SERVER'] == '') {
|
||||
throw (new \Exception("The dababase connection with dbs_server: '" . $dataDBConnection['DBS_SERVER'] . "', is invalid"));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_DBC_SERVER_INVALID", array($dataDBConnection['DBS_SERVER']))));
|
||||
}
|
||||
|
||||
if (isset($dataDBConnection['DBS_DATABASE_NAME']) && $dataDBConnection['DBS_DATABASE_NAME'] == '') {
|
||||
throw (new \Exception("The dababase connection with dbs_database_name: '" . $dataDBConnection['DBS_DATABASE_NAME'] . "', is invalid"));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_DBC_DBNAME_INVALID", array($dataDBConnection['DBS_DATABASE_NAME']))));
|
||||
}
|
||||
|
||||
if (isset($dataDBConnection['DBS_PORT']) &&
|
||||
($dataDBConnection['DBS_PORT'] == ''|| $dataDBConnection['DBS_PORT'] == 0)) {
|
||||
throw (new \Exception("The dababase connection with dbs_port: '" . $dataDBConnection['DBS_PORT'] . "', is invalid"));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_DBC_PORT_INVALID", array($dataDBConnection['DBS_PORT']))));
|
||||
}
|
||||
|
||||
if (isset($dataDBConnection['DBS_ENCODE'])) {
|
||||
@@ -130,7 +130,7 @@ class DataBaseConnection
|
||||
$encodesExists[] = $value['0'];
|
||||
}
|
||||
if (!in_array($dataDBConnection['DBS_ENCODE'], $encodesExists)) {
|
||||
throw (new \Exception( "The dababase connection with dbs_encode: '" . $dataDBConnection['DBS_ENCODE'] . "', is invalid" ));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_DBC_ENCODE_INVALID", array($dataDBConnection['DBS_ENCODE']))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,11 +342,11 @@ class DataBaseConnection
|
||||
{
|
||||
$pro_uid = trim($pro_uid);
|
||||
if ($pro_uid == '') {
|
||||
throw (new \Exception("The project with prj_uid: '', does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_PROJECT_NOT_EXIST", array('prj_uid',''))));
|
||||
}
|
||||
$oProcess = new \Process();
|
||||
if (!($oProcess->processExists($pro_uid))) {
|
||||
throw (new \Exception("The project with prj_uid: '$pro_uid', does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_PROJECT_NOT_EXIST", array('prj_uid', $pro_uid))));
|
||||
}
|
||||
return $pro_uid;
|
||||
}
|
||||
@@ -365,11 +365,11 @@ class DataBaseConnection
|
||||
{
|
||||
$dbs_uid = trim($dbs_uid);
|
||||
if ($dbs_uid == '') {
|
||||
throw (new \Exception("The database connection with dbs_uid: '', does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_DBC_NOT_EXIST", array('dbs_uid',''))));
|
||||
}
|
||||
$oDBSource = new DbSource();
|
||||
if (!($oDBSource->Exists($dbs_uid, $pro_uid))) {
|
||||
throw (new \Exception("The database connection with dbs_uid: '$dbs_uid', does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_DBC_NOT_EXIST", array('dbs_uid',$dbs_uid))));
|
||||
}
|
||||
return $dbs_uid;
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ class Department
|
||||
if (isset($dep_data['DEP_TITLE'])) {
|
||||
Validator::depTitle($dep_data['DEP_TITLE']);
|
||||
} else {
|
||||
throw (new \Exception("The field dep_title is required."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_FIELD_REQUIRED", array('dep_title'))));
|
||||
}
|
||||
$dep_uid = $oDepartment->create($dep_data);
|
||||
$response = $this->getDepartment($dep_uid);
|
||||
@@ -288,11 +288,11 @@ class Department
|
||||
$oDepartment = new \Department();
|
||||
$countUsers = $oDepartment->cantUsersInDepartment($dep_uid);
|
||||
if ($countUsers != 0) {
|
||||
throw (new \Exception("Department cannot be deleted while has assigned users."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_CANT_DELETE_DEPARTMENT_HAS_USERS")));
|
||||
}
|
||||
$dep_data = $this->getDepartment($dep_uid);
|
||||
if ($dep_data['has_children'] != 0) {
|
||||
throw (new \Exception("Can not delete the department, it has a children department."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_CANT_DELETE_DEPARTMENT_HAS_CHILDREN")));
|
||||
}
|
||||
$oDepartment->remove($dep_uid);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class Event
|
||||
|
||||
$oProcess = new \Process();
|
||||
if (!($oProcess->processExists($pro_uid))) {
|
||||
throw (new \Exception( 'This process does not exist!' ));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_PROCESS_NOT_EXIST", array('pro_uid',$pro_uid))));
|
||||
}
|
||||
|
||||
$sDelimiter = \DBAdapter::getStringDelimiter();
|
||||
@@ -75,7 +75,7 @@ class Event
|
||||
}
|
||||
|
||||
if ($evn_uid != '' && empty($eventsArray)) {
|
||||
throw (new \Exception( 'This row does not exist!' ));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_ROW_DOES_NOT_EXIST")));
|
||||
} elseif ($evn_uid != '' && !empty($eventsArray)) {
|
||||
return current($eventsArray);
|
||||
}
|
||||
@@ -106,18 +106,18 @@ class Event
|
||||
$dataEvent = array_change_key_case($dataEvent, CASE_UPPER);
|
||||
if ($dataEvent['EVN_RELATED_TO'] == 'SINGLE') {
|
||||
if (empty($dataEvent['TAS_UID'])) {
|
||||
throw (new \Exception('The field "tas_uid" is required!'));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_FIELD_REQUIRED", array('tas_uid'))));
|
||||
}
|
||||
$this->validateTasUid($dataEvent['TAS_UID']);
|
||||
} else {
|
||||
if (empty($dataEvent['EVN_TAS_UID_FROM'])) {
|
||||
throw (new \Exception('The field "evn_tas_uid_from" is required!'));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_FIELD_REQUIRED", array('evn_tas_uid_from'))));
|
||||
}
|
||||
$this->validateTasUid($dataEvent['EVN_TAS_UID_FROM']);
|
||||
$dataEvent['TAS_UID'] = $dataEvent['EVN_TAS_UID_FROM'];
|
||||
|
||||
if (empty($dataEvent['EVN_TAS_UID_TO'])) {
|
||||
throw (new \Exception('The field "evn_tas_uid_to" is required!'));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_FIELD_REQUIRED", array('evn_tas_uid_to'))));
|
||||
}
|
||||
$this->validateTasUid($dataEvent['EVN_TAS_UID_TO']);
|
||||
}
|
||||
@@ -178,11 +178,11 @@ class Event
|
||||
{
|
||||
$pro_uid = trim($pro_uid);
|
||||
if ($pro_uid == '') {
|
||||
throw (new \Exception("The project with prj_uid: '', does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_PROJECT_NOT_EXIST", array('prj_uid',''))));
|
||||
}
|
||||
$oProcess = new \Process();
|
||||
if (!($oProcess->processExists($pro_uid))) {
|
||||
throw (new \Exception("The project with prj_uid: '$pro_uid', does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_PROJECT_NOT_EXIST", array('prj_uid',$pro_uid))));
|
||||
}
|
||||
return $pro_uid;
|
||||
}
|
||||
@@ -200,11 +200,11 @@ class Event
|
||||
{
|
||||
$evn_uid = trim($evn_uid);
|
||||
if ($evn_uid == '') {
|
||||
throw (new \Exception("The event with evn_uid: '', does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_EVENT_NOT_EXIST", array('evn_uid',''))));
|
||||
}
|
||||
$oEvent = new \Event();
|
||||
if (!($oEvent->Exists($evn_uid))) {
|
||||
throw (new \Exception("The event with evn_uid: '$evn_uid', does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_EVENT_NOT_EXIST", array('evn_uid',$evn_uid))));
|
||||
}
|
||||
return $evn_uid;
|
||||
}
|
||||
@@ -222,11 +222,11 @@ class Event
|
||||
{
|
||||
$tas_uid = trim($tas_uid);
|
||||
if ($tas_uid == '') {
|
||||
throw (new \Exception("The task with tas_uid: '', does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_TASK_NOT_EXIST", array('tas_uid',''))));
|
||||
}
|
||||
$oTask = new \Task();
|
||||
if (!($oTask->taskExists($tas_uid))) {
|
||||
throw (new \Exception("The task with tas_uid: '$tas_uid', does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_TASK_NOT_EXIST", array('tas_uid',$tas_uid))));
|
||||
}
|
||||
return $tas_uid;
|
||||
}
|
||||
@@ -244,12 +244,12 @@ class Event
|
||||
{
|
||||
$tri_uid = trim($tri_uid);
|
||||
if ($tri_uid == '') {
|
||||
throw (new \Exception("The trigger with tri_uid: '', does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_TRIGGER_NOT_EXIST", array('tri_uid',''))));
|
||||
}
|
||||
|
||||
$oTriggers = new \Triggers();
|
||||
if (!($oTriggers->TriggerExists($tri_uid))) {
|
||||
throw (new \Exception("The trigger with tri_uid: '', does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_TRIGGER_NOT_EXIST", array('tri_uid',$tri_uid))));
|
||||
}
|
||||
|
||||
return $tri_uid;
|
||||
|
||||
@@ -176,7 +176,7 @@ class ProcessPermissions
|
||||
}
|
||||
|
||||
if ($op_uid != '' && empty($aObjectsPermissions)) {
|
||||
throw (new \Exception( 'This row does not exist!!' ));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_ROW_DOES_NOT_EXIST")));
|
||||
} elseif ($op_uid != '' && !empty($aObjectsPermissions)) {
|
||||
$aObjectsPermissions = array_change_key_case($aObjectsPermissions, CASE_LOWER);
|
||||
return current($aObjectsPermissions);
|
||||
@@ -314,11 +314,11 @@ class ProcessPermissions
|
||||
{
|
||||
$pro_uid = trim($pro_uid);
|
||||
if ($pro_uid == '') {
|
||||
throw (new \Exception("The project with prj_uid: '' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_PROJECT_NOT_EXIST", array('prj_uid',''))));
|
||||
}
|
||||
$oProcess = new \Process();
|
||||
if (!($oProcess->processExists($pro_uid))) {
|
||||
throw (new \Exception("The project with prj_uid: '$pro_uid' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_PROJECT_NOT_EXIST", array('prj_uid',$pro_uid))));
|
||||
}
|
||||
return $pro_uid;
|
||||
}
|
||||
@@ -336,11 +336,11 @@ class ProcessPermissions
|
||||
{
|
||||
$op_uid = trim($op_uid);
|
||||
if ($op_uid == '') {
|
||||
throw (new \Exception("The process permission with op_uid: '' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_PROCESS_PERMISSION_NOT_EXIST", array('op_uid',''))));
|
||||
}
|
||||
$oObjectPermission = new \ObjectPermission();
|
||||
if (!($oObjectPermission->Exists($op_uid))) {
|
||||
throw (new \Exception("The process permission with op_uid: '$op_uid' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_PROCESS_PERMISSION_NOT_EXIST", array('op_uid',$op_uid))));
|
||||
}
|
||||
return $op_uid;
|
||||
}
|
||||
@@ -358,11 +358,11 @@ class ProcessPermissions
|
||||
{
|
||||
$usr_uid = trim($usr_uid);
|
||||
if ($usr_uid == '') {
|
||||
throw (new \Exception("The user with usr_uid: '' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_USER_NOT_EXIST", array('usr_uid',''))));
|
||||
}
|
||||
$oUsers = new \Users();
|
||||
if (!($oUsers->userExists($usr_uid))) {
|
||||
throw (new \Exception("The user with usr_uid: '$usr_uid' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_USER_NOT_EXIST", array('usr_uid',$usr_uid))));
|
||||
}
|
||||
return $usr_uid;
|
||||
}
|
||||
@@ -380,11 +380,11 @@ class ProcessPermissions
|
||||
{
|
||||
$grp_uid = trim($grp_uid);
|
||||
if ($grp_uid == '') {
|
||||
throw (new \Exception("The group with usr_uid: '' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_GROUP_NOT_EXIST", array('grp_uid',''))));
|
||||
}
|
||||
$oGroup = new \Groupwf();
|
||||
if (!($oGroup->GroupwfExists($grp_uid))) {
|
||||
throw (new \Exception("The group with usr_uid: '$grp_uid' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_GROUP_NOT_EXIST", array('grp_uid',$grp_uid))));
|
||||
}
|
||||
return $grp_uid;
|
||||
}
|
||||
@@ -402,11 +402,11 @@ class ProcessPermissions
|
||||
{
|
||||
$tas_uid = trim($tas_uid);
|
||||
if ($tas_uid == '') {
|
||||
throw (new \Exception("The task with tas_uid: '' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_TASK_NOT_EXIST", array('tas_uid',''))));
|
||||
}
|
||||
$oTask = new \Task();
|
||||
if (!($oTask->taskExists($tas_uid))) {
|
||||
throw (new \Exception("The task with tas_uid: '$tas_uid' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_TASK_NOT_EXIST", array('tas_uid',$tas_uid))));
|
||||
}
|
||||
return $tas_uid;
|
||||
}
|
||||
@@ -424,11 +424,11 @@ class ProcessPermissions
|
||||
{
|
||||
$dyn_uid = trim($dyn_uid);
|
||||
if ($dyn_uid == '') {
|
||||
throw (new \Exception("The dynaform with dynaforms: '' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_DYNAFORM_NOT_EXIST", array('dyn_uid',''))));
|
||||
}
|
||||
$oDynaform = new \Dynaform();
|
||||
if (!($oDynaform->dynaformExists($dyn_uid))) {
|
||||
throw (new \Exception("The dynaform with dynaforms: '$dyn_uid' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_DYNAFORM_NOT_EXIST", array('dyn_uid',$dyn_uid))));
|
||||
}
|
||||
return $dyn_uid;
|
||||
}
|
||||
@@ -446,11 +446,11 @@ class ProcessPermissions
|
||||
{
|
||||
$inp_uid = trim($inp_uid);
|
||||
if ($inp_uid == '') {
|
||||
throw (new \Exception("The input with inputs: '' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_INPUT_NOT_EXIST", array('inp_uid',''))));
|
||||
}
|
||||
$oInputDocument = new \InputDocument();
|
||||
if (!($oInputDocument->InputExists($inp_uid))) {
|
||||
throw (new \Exception("The input with inputs: '$inp_uid' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_INPUT_NOT_EXIST", array('inp_uid',$inp_uid))));
|
||||
}
|
||||
return $inp_uid;
|
||||
}
|
||||
@@ -468,11 +468,11 @@ class ProcessPermissions
|
||||
{
|
||||
$out_uid = trim($out_uid);
|
||||
if ($out_uid == '') {
|
||||
throw (new \Exception("The output with outputs: '' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_OUTPUT_NOT_EXIST", array('out_uid',''))));
|
||||
}
|
||||
$oOutputDocument = new \OutputDocument();
|
||||
if (!($oOutputDocument->OutputExists($out_uid))) {
|
||||
throw (new \Exception("The output with outputs: '$out_uid' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_OUTPUT_NOT_EXIST", array('out_uid',$out_uid))));
|
||||
}
|
||||
return $out_uid;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
408
workflow/engine/src/ProcessMaker/BusinessModel/Role/User.php
Normal file
408
workflow/engine/src/ProcessMaker/BusinessModel/Role/User.php
Normal file
@@ -0,0 +1,408 @@
|
||||
<?php
|
||||
namespace ProcessMaker\BusinessModel\Role;
|
||||
|
||||
class User
|
||||
{
|
||||
private $arrayFieldDefinition = array(
|
||||
"ROL_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "roleUid"),
|
||||
"USR_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "userUid")
|
||||
);
|
||||
|
||||
private $formatFieldNameInUppercase = true;
|
||||
|
||||
private $arrayFieldNameForException = array(
|
||||
"filter" => "FILTER",
|
||||
"start" => "START",
|
||||
"limit" => "LIMIT"
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor of the class
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
try {
|
||||
foreach ($this->arrayFieldDefinition as $key => $value) {
|
||||
$this->arrayFieldNameForException[$value["fieldNameAux"]] = $key;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the format of the fields name (uppercase, lowercase)
|
||||
*
|
||||
* @param bool $flag Value that set the format
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function setFormatFieldNameInUppercase($flag)
|
||||
{
|
||||
try {
|
||||
$this->formatFieldNameInUppercase = $flag;
|
||||
|
||||
$this->setArrayFieldNameForException($this->arrayFieldNameForException);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set exception messages for fields
|
||||
*
|
||||
* @param array $arrayData Data with the fields
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function setArrayFieldNameForException(array $arrayData)
|
||||
{
|
||||
try {
|
||||
foreach ($arrayData as $key => $value) {
|
||||
$this->arrayFieldNameForException[$key] = $this->getFieldNameByFormatFieldName($value);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the field according to the format
|
||||
*
|
||||
* @param string $fieldName Field name
|
||||
*
|
||||
* return string Return the field name according the format
|
||||
*/
|
||||
public function getFieldNameByFormatFieldName($fieldName)
|
||||
{
|
||||
try {
|
||||
return ($this->formatFieldNameInUppercase)? strtoupper($fieldName) : strtolower($fieldName);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if it's assigned the User to Role
|
||||
*
|
||||
* @param string $roleUid Unique id of Role
|
||||
* @param string $userUid Unique id of User
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if it's assigned the User to Role
|
||||
*/
|
||||
public function throwExceptionIfItsAssignedUserToRole($roleUid, $userUid, $fieldNameForException)
|
||||
{
|
||||
try {
|
||||
$obj = \UsersRolesPeer::retrieveByPK($userUid, $roleUid);
|
||||
|
||||
if (!is_null($obj)) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_ROLE_USER_IS_ALREADY_ASSIGNED", array($fieldNameForException, $userUid)));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if not it's assigned the User to Role
|
||||
*
|
||||
* @param string $roleUid Unique id of Role
|
||||
* @param string $userUid Unique id of User
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if not it's assigned the User to Role
|
||||
*/
|
||||
public function throwExceptionIfNotItsAssignedUserToRole($roleUid, $userUid, $fieldNameForException)
|
||||
{
|
||||
try {
|
||||
$obj = \UsersRolesPeer::retrieveByPK($userUid, $roleUid);
|
||||
|
||||
if (is_null($obj)) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_ROLE_USER_IS_NOT_ASSIGNED", array($fieldNameForException, $userUid)));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign User to Role
|
||||
*
|
||||
* @param string $roleUid Unique id of Role
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* return array Return data of the User assigned to Role
|
||||
*/
|
||||
public function create($roleUid, array $arrayData)
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
$validator = new \ProcessMaker\BusinessModel\Validator();
|
||||
|
||||
$validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData");
|
||||
$validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData");
|
||||
|
||||
//Set data
|
||||
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
||||
|
||||
unset($arrayData["ROL_UID"]);
|
||||
|
||||
//Verify data
|
||||
$role = new \ProcessMaker\BusinessModel\Role();
|
||||
|
||||
$role->throwExceptionIfNotExistsRole($roleUid, $this->arrayFieldNameForException["roleUid"]);
|
||||
|
||||
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true);
|
||||
|
||||
$process->throwExceptionIfNotExistsUser($arrayData["USR_UID"], $this->arrayFieldNameForException["userUid"]);
|
||||
|
||||
$this->throwExceptionIfItsAssignedUserToRole($roleUid, $arrayData["USR_UID"], $this->arrayFieldNameForException["userUid"]);
|
||||
|
||||
if ($arrayData["USR_UID"] == "00000000000000000000000000000001") {
|
||||
throw new \Exception(\G::LoadTranslation("ID_ADMINISTRATOR_ROLE_CANT_CHANGED"));
|
||||
}
|
||||
|
||||
//Create
|
||||
$role = new \Roles();
|
||||
|
||||
$arrayData = array_merge(array("ROL_UID" => $roleUid), $arrayData);
|
||||
|
||||
$role->assignUserToRole($arrayData);
|
||||
|
||||
//Return
|
||||
if (!$this->formatFieldNameInUppercase) {
|
||||
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
|
||||
}
|
||||
|
||||
return $arrayData;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unassign User of the Role
|
||||
*
|
||||
* @param string $roleUid Unique id of Role
|
||||
* @param string $userUid Unique id of User
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function delete($roleUid, $userUid)
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
$role = new \ProcessMaker\BusinessModel\Role();
|
||||
|
||||
$role->throwExceptionIfNotExistsRole($roleUid, $this->arrayFieldNameForException["roleUid"]);
|
||||
|
||||
$process->throwExceptionIfNotExistsUser($userUid, $this->arrayFieldNameForException["userUid"]);
|
||||
|
||||
$this->throwExceptionIfNotItsAssignedUserToRole($roleUid, $userUid, $this->arrayFieldNameForException["userUid"]);
|
||||
|
||||
if ($roleUid == "00000000000000000000000000000002" && $userUid == "00000000000000000000000000000001") {
|
||||
throw new \Exception(\G::LoadTranslation("ID_ADMINISTRATOR_ROLE_CANT_CHANGED"));
|
||||
}
|
||||
|
||||
//Delete
|
||||
$role = new \Roles();
|
||||
|
||||
$role->deleteUserRole($roleUid, $userUid);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get criteria for User
|
||||
*
|
||||
* @param string $roleUid Unique id of Role
|
||||
* @param array $arrayUserUidExclude Unique id of Users to exclude
|
||||
*
|
||||
* return object
|
||||
*/
|
||||
public function getUserCriteria($roleUid, array $arrayUserUidExclude = null)
|
||||
{
|
||||
try {
|
||||
$criteria = new \Criteria("rbac");
|
||||
|
||||
$criteria->addSelectColumn(\RbacUsersPeer::USR_UID);
|
||||
$criteria->addSelectColumn(\RbacUsersPeer::USR_USERNAME);
|
||||
$criteria->addSelectColumn(\RbacUsersPeer::USR_FIRSTNAME);
|
||||
$criteria->addSelectColumn(\RbacUsersPeer::USR_LASTNAME);
|
||||
$criteria->addSelectColumn(\RbacUsersPeer::USR_STATUS);
|
||||
|
||||
if ($roleUid != "") {
|
||||
$criteria->addJoin(\UsersRolesPeer::USR_UID, \RbacUsersPeer::USR_UID, \Criteria::LEFT_JOIN);
|
||||
$criteria->add(\UsersRolesPeer::ROL_UID, $roleUid, \Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$criteria->add(\RbacUsersPeer::USR_USERNAME, "", \Criteria::NOT_EQUAL);
|
||||
|
||||
if (!is_null($arrayUserUidExclude) && is_array($arrayUserUidExclude)) {
|
||||
$criteria->add(\RbacUsersPeer::USR_UID, $arrayUserUidExclude, \Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
return $criteria;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data of a User from a record
|
||||
*
|
||||
* @param array $record Record
|
||||
*
|
||||
* return array Return an array with data User
|
||||
*/
|
||||
public function getUserDataFromRecord(array $record)
|
||||
{
|
||||
try {
|
||||
return array(
|
||||
$this->getFieldNameByFormatFieldName("USR_UID") => $record["USR_UID"],
|
||||
$this->getFieldNameByFormatFieldName("USR_USERNAME") => $record["USR_USERNAME"],
|
||||
$this->getFieldNameByFormatFieldName("USR_FIRSTNAME") => $record["USR_FIRSTNAME"] . "",
|
||||
$this->getFieldNameByFormatFieldName("USR_LASTNAME") => $record["USR_LASTNAME"] . "",
|
||||
$this->getFieldNameByFormatFieldName("USR_STATUS") => ($record["USR_STATUS"] . "" == "1")? "ACTIVE" : "INACTIVE"
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all Users of a Role
|
||||
*
|
||||
* @param string $roleUid Unique id of Role
|
||||
* @param string $option Option (USERS, AVAILABLE-USERS)
|
||||
* @param array $arrayFilterData Data of the filters
|
||||
* @param string $sortField Field name to sort
|
||||
* @param string $sortDir Direction of sorting (ASC, DESC)
|
||||
* @param int $start Start
|
||||
* @param int $limit Limit
|
||||
*
|
||||
* return array Return an array with all Users of a Role
|
||||
*/
|
||||
public function getUsers($roleUid, $option, array $arrayFilterData = null, $sortField = null, $sortDir = null, $start = null, $limit = null)
|
||||
{
|
||||
try {
|
||||
$arrayUser = array();
|
||||
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
$role = new \ProcessMaker\BusinessModel\Role();
|
||||
|
||||
$role->throwExceptionIfNotExistsRole($roleUid, $this->arrayFieldNameForException["roleUid"]);
|
||||
|
||||
$process->throwExceptionIfDataNotMetFieldDefinition(
|
||||
array("OPTION" => $option),
|
||||
array("OPTION" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("USERS", "AVAILABLE-USERS"), "fieldNameAux" => "option")),
|
||||
array("option" => "\$option"),
|
||||
true
|
||||
);
|
||||
|
||||
$process->throwExceptionIfDataNotMetPagerVarDefinition(array("start" => $start, "limit" => $limit), $this->arrayFieldNameForException);
|
||||
|
||||
//Get data
|
||||
if (!is_null($limit) && $limit . "" == "0") {
|
||||
return $arrayUser;
|
||||
}
|
||||
|
||||
//SQL
|
||||
switch ($option) {
|
||||
case "USERS":
|
||||
//Criteria
|
||||
$criteria = $this->getUserCriteria($roleUid);
|
||||
break;
|
||||
case "AVAILABLE-USERS":
|
||||
//Get Uids
|
||||
$arrayUid = array();
|
||||
|
||||
$criteria = $this->getUserCriteria($roleUid);
|
||||
|
||||
$rsCriteria = \RbacUsersPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
|
||||
$arrayUid[] = $row["USR_UID"];
|
||||
}
|
||||
|
||||
//Criteria
|
||||
$criteria = $this->getUserCriteria("", $arrayUid);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]) && trim($arrayFilterData["filter"]) != "") {
|
||||
$criteria->add(
|
||||
$criteria->getNewCriterion(\RbacUsersPeer::USR_USERNAME, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE)->addOr(
|
||||
$criteria->getNewCriterion(\RbacUsersPeer::USR_FIRSTNAME, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE)->addOr(
|
||||
$criteria->getNewCriterion(\RbacUsersPeer::USR_LASTNAME, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE)))
|
||||
);
|
||||
}
|
||||
|
||||
//Number records total
|
||||
$criteriaCount = clone $criteria;
|
||||
|
||||
$criteriaCount->clearSelectColumns();
|
||||
$criteriaCount->addAsColumn("NUM_REC", "COUNT(" . \RbacUsersPeer::USR_UID . ")");
|
||||
|
||||
$rsCriteriaCount = \RbacUsersPeer::doSelectRS($criteriaCount);
|
||||
$rsCriteriaCount->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$rsCriteriaCount->next();
|
||||
$row = $rsCriteriaCount->getRow();
|
||||
|
||||
$numRecTotal = $row["NUM_REC"];
|
||||
|
||||
//SQL
|
||||
if (!is_null($sortField) && trim($sortField) != "") {
|
||||
$sortField = strtoupper($sortField);
|
||||
|
||||
if (in_array($sortField, array("USR_UID", "USR_USERNAME", "USR_FIRSTNAME", "USR_LASTNAME", "USR_STATUS"))) {
|
||||
$sortField = \RbacUsersPeer::TABLE_NAME . "." . $sortField;
|
||||
} else {
|
||||
$sortField = \RbacUsersPeer::USR_USERNAME;
|
||||
}
|
||||
} else {
|
||||
$sortField = \RbacUsersPeer::USR_USERNAME;
|
||||
}
|
||||
|
||||
if (!is_null($sortDir) && trim($sortDir) != "" && strtoupper($sortDir) == "DESC") {
|
||||
$criteria->addDescendingOrderByColumn($sortField);
|
||||
} else {
|
||||
$criteria->addAscendingOrderByColumn($sortField);
|
||||
}
|
||||
|
||||
if (!is_null($start)) {
|
||||
$criteria->setOffset((int)($start));
|
||||
}
|
||||
|
||||
if (!is_null($limit)) {
|
||||
$criteria->setLimit((int)($limit));
|
||||
}
|
||||
|
||||
$rsCriteria = \RbacUsersPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
|
||||
$arrayUser[] = $this->getUserDataFromRecord($row);
|
||||
}
|
||||
|
||||
//Return
|
||||
return $arrayUser;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ class Trigger
|
||||
|
||||
if (isset($dataTrigger['TRI_TITLE'])) {
|
||||
if (!$this->verifyNameTrigger($sProcessUID, $dataTrigger['TRI_TITLE'], $sTriggerUid)) {
|
||||
throw new \Exception('A trigger with the same name already exists in this process');
|
||||
throw new \Exception(\G::LoadTranslation("ID_CANT_SAVE_TRIGGER"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,11 +26,11 @@ class Validator
|
||||
{
|
||||
$dep_uid = trim($dep_uid);
|
||||
if ($dep_uid == '') {
|
||||
throw (new \Exception("The departament with $nameField: '' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_DEPARTMENT_NOT_EXIST", array($nameField,''))));
|
||||
}
|
||||
$oDepartment = new \Department();
|
||||
if (!($oDepartment->existsDepartment($dep_uid))) {
|
||||
throw (new \Exception("The departament with $nameField: '$dep_uid' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_DEPARTMENT_NOT_EXIST", array($nameField,$dep_uid))));
|
||||
}
|
||||
return $dep_uid;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class Validator
|
||||
{
|
||||
$dep_title = trim($dep_title);
|
||||
if ($dep_title == '') {
|
||||
throw (new \Exception("The departament with dep_title: '' is incorrect."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_DEPARTMENT_NOT_EXIST", array('dep_title',''))));
|
||||
}
|
||||
|
||||
$oCriteria = new \Criteria( 'workflow' );
|
||||
@@ -71,7 +71,7 @@ class Validator
|
||||
$oDataset = \DepartmentPeer::doSelectRS( $oCriteria );
|
||||
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
|
||||
if ($oDataset->next()) {
|
||||
throw (new \Exception("The departament with dep_title: '$dep_title' already exists."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_DEPARTMENT_NOT_EXIST", array('dep_title',$dep_title))));
|
||||
}
|
||||
return $dep_title;
|
||||
}
|
||||
@@ -92,7 +92,7 @@ class Validator
|
||||
$dep_status = trim($dep_status);
|
||||
$values = array('ACTIVE', 'INACTIVE');
|
||||
if (!in_array($dep_status, $values)) {
|
||||
throw (new \Exception("The departament with dep_status: '$dep_status' is incorrect."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_DEPARTMENT_NOT_EXIST", array('dep_status',$dep_status))));
|
||||
}
|
||||
return $dep_status;
|
||||
}
|
||||
@@ -113,11 +113,11 @@ class Validator
|
||||
{
|
||||
$usr_uid = trim($usr_uid);
|
||||
if ($usr_uid == '') {
|
||||
throw (new \Exception("The user with $nameField: '' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_USER_NOT_EXIST", array($nameField,''))));
|
||||
}
|
||||
$oUsers = new \Users();
|
||||
if (!($oUsers->userExists($usr_uid))) {
|
||||
throw (new \Exception("The user with $nameField: '$usr_uid' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_USER_NOT_EXIST", array($nameField,$usr_uid))));
|
||||
}
|
||||
return $usr_uid;
|
||||
}
|
||||
@@ -138,11 +138,11 @@ class Validator
|
||||
{
|
||||
$app_uid = trim($app_uid);
|
||||
if ($app_uid == '') {
|
||||
throw (new \Exception("The application with $nameField: '' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_APPLICATION_NOT_EXIST", array($nameField,''))));
|
||||
}
|
||||
$oApplication = new \Application();
|
||||
if (!($oApplication->exists($app_uid))) {
|
||||
throw (new \Exception("The application with $nameField: '$app_uid' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_APPLICATION_NOT_EXIST", array($nameField,$app_uid))));
|
||||
}
|
||||
return $app_uid;
|
||||
}
|
||||
@@ -163,11 +163,11 @@ class Validator
|
||||
{
|
||||
$tri_uid = trim($tri_uid);
|
||||
if ($tri_uid == '') {
|
||||
throw (new \Exception("The trigger with $nameField: '' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_TRIGGER_NOT_EXIST", array($nameField,''))));
|
||||
}
|
||||
$oTriggers = new \Triggers();
|
||||
if (!($oTriggers->TriggerExists($tri_uid))) {
|
||||
throw (new \Exception("The trigger with $nameField: '$tri_uid' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_TRIGGER_NOT_EXIST", array($nameField,$tri_uid))));
|
||||
}
|
||||
return $tri_uid;
|
||||
}
|
||||
@@ -188,11 +188,11 @@ class Validator
|
||||
{
|
||||
$pro_uid = trim($pro_uid);
|
||||
if ($pro_uid == '') {
|
||||
throw (new \Exception("The process with $nameField: '' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_PROCESS_NOT_EXIST", array($nameField,''))));
|
||||
}
|
||||
$oProcess = new \Process();
|
||||
if (!($oProcess->exists($pro_uid))) {
|
||||
throw (new \Exception("The process with $nameField: '$pro_uid' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_PROCESS_NOT_EXIST", array($nameField,$pro_uid))));
|
||||
}
|
||||
return $pro_uid;
|
||||
}
|
||||
@@ -213,11 +213,11 @@ class Validator
|
||||
{
|
||||
$cat_uid = trim($cat_uid);
|
||||
if ($cat_uid == '') {
|
||||
throw (new \Exception("The category with $nameField: '' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_CATEGORY_NOT_EXIST", array($nameField,''))));
|
||||
}
|
||||
$oCategory = new \ProcessCategory();
|
||||
if (!($oCategory->exists($cat_uid))) {
|
||||
throw (new \Exception("The category with $nameField: '$cat_uid' does not exist."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_CATEGORY_NOT_EXIST", array($nameField,$cat_uid))));
|
||||
}
|
||||
return $cat_uid;
|
||||
}
|
||||
@@ -238,11 +238,11 @@ class Validator
|
||||
{
|
||||
$date = trim($date);
|
||||
if ($date == '') {
|
||||
throw (new \Exception("The value '' is not a valid date for the format '$format'."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_DATE_NOT_VALID", array('',$format))));
|
||||
}
|
||||
$d = \DateTime::createFromFormat($format, $date);
|
||||
if (!($d && $d->format($format) == $date)) {
|
||||
throw (new \Exception("The value '$date' is not a valid date for the format '$format'."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_DATE_NOT_VALID", array($date,$format))));
|
||||
}
|
||||
return $date;
|
||||
}
|
||||
@@ -260,7 +260,7 @@ class Validator
|
||||
static public function isArray($field, $nameField)
|
||||
{
|
||||
if (!is_array($field)) {
|
||||
throw (new \Exception("Invalid value for '$nameField' it must be an array."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_ARRAY", array($nameField))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ class Validator
|
||||
static public function isString($field, $nameField)
|
||||
{
|
||||
if (!is_string($field)) {
|
||||
throw (new \Exception("Invalid value for '$nameField' it must be a string."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_STRING", array($nameField))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ class Validator
|
||||
static public function isInteger($field, $nameField)
|
||||
{
|
||||
if (!is_integer($field)) {
|
||||
throw (new \Exception("Invalid value for '$nameField' it must be a integer."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_INTEGER", array($nameField))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ class Validator
|
||||
static public function isBoolean($field, $nameField)
|
||||
{
|
||||
if (!is_bool($field)) {
|
||||
throw (new \Exception("Invalid value for '$nameField' it must be a boolean."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_BOOLEAN", array($nameField))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ class Validator
|
||||
static public function isNotEmpty($field, $nameField)
|
||||
{
|
||||
if (empty($field)) {
|
||||
throw (new \Exception("The field '$nameField' is empty."));
|
||||
throw (new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_IS_EMPTY", array($nameField))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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") {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
81
workflow/engine/src/ProcessMaker/Services/Api/Role/User.php
Normal file
81
workflow/engine/src/ProcessMaker/Services/Api/Role/User.php
Normal 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user