Se modifica BEHAT FILES MANAGER y PMUSER
This commit is contained in:
@@ -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 <http_code>
|
||||
And the response charset is "UTF-8"
|
||||
And the content type is "application/json"
|
||||
And the type is "<type>"
|
||||
And store "prf_uid" in session array as variable "prf_uid<i>"
|
||||
|
||||
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=<path>"
|
||||
Then the response status code should be 200
|
||||
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>"
|
||||
@@ -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 "<path>"
|
||||
And I request "project/1265557095225ff5c688f46031700471/file-manager?path=<path>"
|
||||
@@ -84,3 +83,14 @@ Feature: Files Manager Resources
|
||||
| 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 "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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
FA<?php
|
||||
use Behat\Behat\Context\BehatContext;
|
||||
use Behat\Gherkin\Node\PyStringNode;
|
||||
use Behat\Gherkin\Node\TableNode;
|
||||
@@ -1311,5 +1311,58 @@ class RestContext extends BehatContext
|
||||
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user