From d5f9c09f925c59abdfcb5bf2af8813128ac89ad5 Mon Sep 17 00:00:00 2001 From: Wendy Nestor Date: Tue, 25 Feb 2014 11:15:21 -0400 Subject: [PATCH] Culminacion del feature pm user y creacion de nuevos archivos --- .../main_test_files_manager.feature | 96 +++++++++++++++++++ .../negative_tests_files_manager.feature | 0 .../pm_user/main_tests_pm_user.feature | 23 ++++- features/bootstrap/RestContext.php | 33 ++++++- 4 files changed, 149 insertions(+), 3 deletions(-) create mode 100644 features/backend/files_manager/main_test_files_manager.feature create mode 100644 features/backend/files_manager/negative_tests_files_manager.feature diff --git a/features/backend/files_manager/main_test_files_manager.feature b/features/backend/files_manager/main_test_files_manager.feature new file mode 100644 index 000000000..d457b9e44 --- /dev/null +++ b/features/backend/files_manager/main_test_files_manager.feature @@ -0,0 +1,96 @@ +@ProcessMakerMichelangelo @RestAPI +Feature: Files Manager Resources + + Background: + Given that I have a valid access_token + + Scenario: Get a list of main process files manager + Given I request "project/1265557095225ff5c688f46031700471/file-manager" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the content type is "application/json" + And the type is "array" + + Scenario: Get a list public folder of process files manager + Given I request "project/1265557095225ff5c688f46031700471/file-manager?path=public" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the content type is "application/json" + And the type is "array" + + Scenario: Get a list templates folder of process files manager + Given I request "project/1265557095225ff5c688f46031700471/file-manager?path=templates" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the content type is "application/json" + And the type is "array" + + Scenario Outline: Post files + Given POST this data: + """ + { + "prf_filename": "", + "prf_path": "", + "prf_content": "" + } + """ + And I request "project/1265557095225ff5c688f46031700471/file-manager" + Then the response status code should be + And the response charset is "UTF-8" + And the content type is "application/json" + And the type is "" + And store "prf_uid" in session array as variable "prf_uid" + + Examples: + | test_description | file_name | path | content | http_code | type | + | into public folder | testbehat.txt | public/ | test | 200 | object | + | into maintemplates folder | testbehat.txt | templates/ | test | 200 | object | + | into public subfolder | testbehat.txt | public/test_folder | test | 200 | object | + | into public subfolder | testbehat.txt | templates/test_folder | test | 200 | object | + + Scenario Outline: Post files + Given PUT this data: + """ + { + "prf_filename": "", + "prf_content": "" + } + """ + And I request "project/1265557095225ff5c688f46031700471/file-manager?path=" + Then the response status code should be + And the response charset is "UTF-8" + And the content type is "application/json" + And the type is "" + + Examples: + | test_description | file_name | path | content | http_code | type | + | put into public folder | testbehat.txt | public/ | put test | 200 | object | + | put into maintemplates folder | testbehat.txt | templates/ | put test | 200 | object | + | put into public subfolder | testbehat.txt | public/test_folder | put test | 200 | object | + | put into public subfolder | testbehat.txt | templates/test_folder | put test | 200 | object | + + + Scenario Outline: Delete file + Given that I want to delete a "" + And I request "project/1265557095225ff5c688f46031700471/file-manager?path=" + 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 | path | + | delete public folder | public/testbehat.txt | + | delete maintemplates folder | templates/testbehat.txt | + | delete public subfolder | public/test_folder/testbehat.txt | + | delete public subfolder | templates/test_folder/testbehat.txt | + + #Para que funcione este test, debe existir el archivo que se quiere subir + Scenario: Post files + Given POST I want to upload the file "/home/daniel/test.txt" to path "public". Url to create prf_uid "project/1265557095225ff5c688f46031700471/file-manager" and updload "project/1265557095225ff5c688f46031700471/file-manager/upload" + + Scenario: Delete file + Given that I want to delete a "public/test.txt" + And I request "project/1265557095225ff5c688f46031700471/file-manager?path=public/test.txt" + And the content type is "application/json" + Then the response status code should be 200 + And the response charset is "UTF-8" \ No newline at end of file diff --git a/features/backend/files_manager/negative_tests_files_manager.feature b/features/backend/files_manager/negative_tests_files_manager.feature new file mode 100644 index 000000000..e69de29bb diff --git a/features/backend/pm_user/main_tests_pm_user.feature b/features/backend/pm_user/main_tests_pm_user.feature index 97790df53..440eadbc3 100644 --- a/features/backend/pm_user/main_tests_pm_user.feature +++ b/features/backend/pm_user/main_tests_pm_user.feature @@ -94,7 +94,28 @@ Feature: User Main Tests | Create user Inactive | 4 | daniela | perez | daniela | daniela@gmail.com | grenn #544 | 555-6565 | US | FL | MIA | 555-6655-555 | Gerencia | | 2016-02-15 | | INACTIVE | PROCESSMAKER_OPERATOR | sample | sample | | Create user Vacation | 5 | micaela | sanchez | micaela | micaela@gmail.com | sancjh #544 | 555-6652 | US | FL | MIA | 555-6655-555 | Gerencia | | 2016-02-15 | | VACATION | PROCESSMAKER_OPERATOR | sample | sample | - + + #Para que funcione este test, debe existir el archivo que se quiere subir + #GET /api/1.0/{workspace}/user/{usr_uid} + # Upload a image + Scenario: Upload a image + Given POST I want to upload the image "/home/daniel/pic3.jpg" to user "00000000000000000000000000000001". Url "user/" + + + # Upload a image + Scenario Outline: Upload a image + Given POST I want to upload the image "" to user with the key "usr_uid" stored in session array as variable "usr_uid_". Url "user/" + + Examples: + + | Test_description | usr_number | usr_photo | + | Create without replaced by, calendar | 1 | /home/wendy/photo/pic1.jpg | + | Create without calendar | 2 | /home/wendy/photo/pic2.jpg | + | Create with all fields | 3 | /home/wendy/photo/pic3.jpg | + | Create user Inactive | 4 | ~/userPhoto/abcd.jpg | + | Create user Vacation | 5 | ~/userPhoto/abcd.jpg | + + Scenario: Get the users List when there are exactly 63 users And I request "users" And the content type is "application/json" diff --git a/features/bootstrap/RestContext.php b/features/bootstrap/RestContext.php index e6e26edca..557b26d2c 100644 --- a/features/bootstrap/RestContext.php +++ b/features/bootstrap/RestContext.php @@ -1355,6 +1355,7 @@ class RestContext extends BehatContext { $baseUrl = $this->getParameter('base_url'); $url = $baseUrl.$url.$usrUid."/image-upload"; + $accesstoken = $this->getParameter('access_token'); $headr = array(); $headr[] = 'Authorization: Bearer '.$accesstoken; @@ -1365,8 +1366,36 @@ class RestContext extends BehatContext curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $postResult = curl_exec($ch); + + if( $postResult === false) + { + //trigger_error(curl_error($ch)); + throw new Exception("Image upload failed ($imageFile):\n\n" + . curl_error($ch)); + } curl_close($ch); - echo $postResult; + echo $postResult; } -} + /** + * @Given /^POST I want to upload the image "([^"]*)" to user with the key "([^"]*)" stored in session array as variable "([^"]*)"\. Url "([^"]*)"$/ + */ + public function postIWantToUploadTheImageToUserWithTheKeyStoredInSessionArrayAsVariableUsrUidUrl($imageFile, $varName, $sessionVarName, $url) + { + if (file_exists("session.data")) { + $sessionData = json_decode(file_get_contents("session.data")); + } else { + $sessionData = array(); + } + if (!isset($sessionData->$sessionVarName) ) { + $varValue = ''; + } else { + $varValue = $sessionData->$sessionVarName; + } + + $usrUid = $varValue; + + $this->postIWantToUploadTheImageToUser($imageFile, $usrUid, $url); + } + +} \ No newline at end of file