diff --git a/features/backend/files_manager/basic_sequence_files_manager.feature b/features/backend/files_manager/basic_sequence_files_manager.feature index 1f3cf3e46..146e38164 100644 --- a/features/backend/files_manager/basic_sequence_files_manager.feature +++ b/features/backend/files_manager/basic_sequence_files_manager.feature @@ -35,20 +35,18 @@ Feature: Files Manager Resources } """ And I request "project/1265557095225ff5c688f46031700471/file-manager" - Then the response status code should be 200 + 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 | i | - | into public folder | testbehat.txt | public/ | test | 200 | object | 0 | - | into maintemplates folder | testbehat.txt | templates/ | test | 200 | object | 1 | - | into public subfolder | testbehat.txt | public/test_folder | test | 200 | object | 2 | - | into public subfolder | testbehat.txt | templates/test_folder | test | 200 | object | 3 | - - + | 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: @@ -59,7 +57,7 @@ Feature: Files Manager Resources } """ And I request "project/1265557095225ff5c688f46031700471/file-manager?path=" - Then the response status code should be 200 + 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 "" @@ -71,6 +69,7 @@ Feature: Files Manager Resources | 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=" @@ -83,4 +82,15 @@ Feature: Files Manager Resources | 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 | \ No newline at end of file + | 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 "http://daniel.pmos.colosa.net/api/1.0/daniel/project/1265557095225ff5c688f46031700471/file-manager" and updload "http://daniel.pmos.colosa.net/api/1.0/daniel/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" diff --git a/features/backend/pm_user/basic_sequence_pm_user.feature b/features/backend/pm_user/basic_sequence_pm_user.feature index aa0b2c27c..64302976d 100644 --- a/features/backend/pm_user/basic_sequence_pm_user.feature +++ b/features/backend/pm_user/basic_sequence_pm_user.feature @@ -31,6 +31,12 @@ Feature: User And the response charset is "UTF-8" And the type is "object" + #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/pic2.jpg" to user "00000000000000000000000000000001". Url "http://daniel.pmos.colosa.net/api/1.0/daniel/user/" + #POST /api/1.0/{workspace}/user # Create new User Scenario Outline: Create new User diff --git a/features/bootstrap/RestContext.php b/features/bootstrap/RestContext.php index bc50f1684..10fb06e68 100644 --- a/features/bootstrap/RestContext.php +++ b/features/bootstrap/RestContext.php @@ -1,4 +1,4 @@ -iRequest($url); } + + //*********** POST - UPLOAD FILE MANAGER + /** + * @Given /^POST I want to upload the file "([^"]*)" to path "([^"]*)". Url to create prf_uid "([^"]*)" and updload "([^"]*)"$/ + */ + public function postIWantToUploadTheFileToPathPublicUrlToCreatePrfUidAndUpdload($prfFile, $prfPath, $postUrl, $url) + { + $accesstoken = $this->getParameter('access_token'); + $headr = array(); + $headr[] = 'Authorization: Bearer '.$accesstoken; + $path = rtrim($prfPath, '/') . '/'; + $sfile = end(explode("/",$prfFile)); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL,$postUrl); + curl_setopt($ch, CURLOPT_HTTPHEADER,$headr); + curl_setopt($ch, CURLOPT_POSTFIELDS, array('prf_filename'=>$sfile, "prf_path" => $path, "prf_content" => "")); + 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); + curl_close($ch); + $aResult = explode(",",$postResult); + $aFileUid = explode(":",$aResult[0]); + $prfUid = trim(str_replace('"','',$aFileUid[1])); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL,$url); + curl_setopt($ch, CURLOPT_HTTPHEADER,$headr); + curl_setopt($ch, CURLOPT_POSTFIELDS, array('my_file'=>'@'.$prfFile, 'prf_uid' => $prfUid)); + 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); + curl_close($ch); + } + + //*********** POST - UPLOAD IMAGE + /** + * @Given /^POST I want to upload the image "([^"]*)" to user "([^"]*)". Url "([^"]*)"$/ + */ + public function postIWantToUploadTheImageToUser($imageFile, $usrUid, $url) + { + $url = $url.$usrUid."/image-upload"; + $accesstoken = $this->getParameter('access_token'); + $headr = array(); + $headr[] = 'Authorization: Bearer '.$accesstoken; + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL,$url); + curl_setopt($ch, CURLOPT_HTTPHEADER,$headr); + curl_setopt($ch, CURLOPT_POSTFIELDS, array('USR_PHOTO'=>'@'.$imageFile)); + 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); + curl_close($ch); + echo $postResult; + } }