Merge branch 'master' into refactoringTests
This commit is contained in:
@@ -750,4 +750,37 @@ class GraphHelper {
|
||||
|
||||
return HttpRequestHelper::sendRequest($url, '', 'PATCH', $user, $password, $header, $body);
|
||||
}
|
||||
|
||||
* @param string $baseUrl
|
||||
* @param string $xRequestId
|
||||
* @param string $user
|
||||
* @param string $password
|
||||
* @param string $currentPassword
|
||||
* @param string $newPassword
|
||||
*
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public static function changeOwnPassword(
|
||||
string $baseUrl,
|
||||
string $xRequestId,
|
||||
string $user,
|
||||
string $password,
|
||||
string $currentPassword,
|
||||
string $newPassword
|
||||
): ResponseInterface {
|
||||
$url = self::getFullUrl($baseUrl, 'me/changePassword');
|
||||
$payload['currentPassword'] = $currentPassword;
|
||||
$payload['newPassword'] = $newPassword;
|
||||
|
||||
return HttpRequestHelper::sendRequest(
|
||||
$url,
|
||||
$xRequestId,
|
||||
"POST",
|
||||
$user,
|
||||
$password,
|
||||
self::getRequestHeaders(),
|
||||
\json_encode($payload)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ default:
|
||||
ldapInitialUserFilePath: /../../config/ldap-users.ldif
|
||||
contexts:
|
||||
- GraphContext:
|
||||
- SpacesContext:
|
||||
- OccContext:
|
||||
- FeatureContext: &common_feature_context_params
|
||||
baseUrl: http://localhost:8080
|
||||
@@ -25,6 +26,7 @@ default:
|
||||
- ChecksumContext:
|
||||
- FavoritesContext:
|
||||
- FilesVersionsContext:
|
||||
- OCSContext:
|
||||
- PublicWebDavContext:
|
||||
- TrashbinContext:
|
||||
- WebDavPropertiesContext:
|
||||
@@ -51,12 +53,16 @@ default:
|
||||
- '%paths.base%/../features/apiArchiver'
|
||||
contexts:
|
||||
- ArchiverContext:
|
||||
- SpacesContext:
|
||||
- OccContext:
|
||||
- FeatureContext: *common_feature_context_params
|
||||
- CapabilitiesContext:
|
||||
- ChecksumContext:
|
||||
- FilesVersionsContext:
|
||||
- OCSContext:
|
||||
- PublicWebDavContext:
|
||||
- TrashbinContext:
|
||||
- WebDavPropertiesContext:
|
||||
|
||||
apiGraph:
|
||||
paths:
|
||||
|
||||
@@ -29,3 +29,17 @@ The expected failures in this file are from features in the owncloud/ocis repo.
|
||||
- [apiGraph/createGroupCaseSensitive.feature:19](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/createGroupCaseSensitive.feature#L19)
|
||||
- [apiGraph/createGroupCaseSensitive.feature:20](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/createGroupCaseSensitive.feature#L20)
|
||||
- [apiGraph/createGroupCaseSensitive.feature:21](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/createGroupCaseSensitive.feature#L21)
|
||||
|
||||
### [PROPFIND on accepted shares with identical names containing brackets exit with 404](https://github.com/owncloud/ocis/issues/4421)
|
||||
|
||||
- [apiSpaces/changingFilesShare.feature:12](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/changingFilesShare.feature#L12)
|
||||
|
||||
#### [Webdav LOCK operations](https://github.com/owncloud/ocis/issues/1284)
|
||||
- [apiSpaces/lockSpaces.feature:31](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L31)
|
||||
- [apiSpaces/lockSpaces.feature:32](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L32)
|
||||
- [apiSpaces/lockSpaces.feature:50](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L50)
|
||||
- [apiSpaces/lockSpaces.feature:51](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L51)
|
||||
- [apiSpaces/lockSpaces.feature:71](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L71)
|
||||
- [apiSpaces/lockSpaces.feature:72](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L72)
|
||||
- [apiSpaces/lockSpaces.feature:89](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L89)
|
||||
- [apiSpaces/lockSpaces.feature:90](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L90)
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
@api
|
||||
Feature: an user changes its own password
|
||||
|
||||
Scenario Outline: change own password
|
||||
Given user "Alice" has been created with default attributes and without skeleton files
|
||||
When the user "Alice" changes its own password "<currentPassword>" to "<newPassword>" using the Graph API
|
||||
Then the HTTP status code should be "<code>"
|
||||
Examples:
|
||||
| currentPassword | newPassword | code |
|
||||
| 123456 | validPass | 204 |
|
||||
| 123456 | кириллица | 204 |
|
||||
| 123456 | 密码 | 204 |
|
||||
| 123456 | ?&^%0 | 204 |
|
||||
| 123456 | | 400 |
|
||||
| 123456 | 123456 | 400 |
|
||||
| wrongPass | 123456 | 500 |
|
||||
| | validPass | 400 |
|
||||
@@ -0,0 +1,39 @@
|
||||
@api @skipOnOcV10
|
||||
Feature:
|
||||
|
||||
Background:
|
||||
Given using spaces DAV path
|
||||
And these users have been created with default attributes and without skeleton files:
|
||||
| username |
|
||||
| Alice |
|
||||
| Brian |
|
||||
|
||||
@issue-4421
|
||||
Scenario: Move files between shares by different users
|
||||
Given user "Carol" has been created with default attributes and without skeleton files
|
||||
And user "Alice" has uploaded file with content "some data" to "/textfile0.txt"
|
||||
And user "Alice" has created folder "/PARENT"
|
||||
And user "Brian" has created folder "/PARENT"
|
||||
And user "Alice" has moved file "textfile0.txt" to "PARENT/from_alice.txt" in space "Personal"
|
||||
And user "Alice" has shared folder "/PARENT" with user "Carol"
|
||||
And user "Brian" has shared folder "/PARENT" with user "Carol"
|
||||
And user "Carol" has accepted share "/PARENT" offered by user "Alice"
|
||||
And user "Carol" has accepted share "/PARENT" offered by user "Brian"
|
||||
When user "Carol" moves file "PARENT/from_alice.txt" to "PARENT (1)/from_alice.txt" in space "Shares Jail" using the WebDAV API
|
||||
Then the HTTP status code should be "201"
|
||||
And for user "Carol" folder "PARENT" of the space "Shares Jail" should not contain these entries:
|
||||
| from_alice.txt |
|
||||
And for user "Carol" folder "PARENT (1)" of the space "Shares Jail" should contain these entries:
|
||||
| from_alice.txt |
|
||||
|
||||
|
||||
Scenario: overwrite a received file share
|
||||
Given user "Alice" has uploaded file with content "this is the old content" to "/textfile1.txt"
|
||||
And user "Alice" has shared file "/textfile1.txt" with user "Brian"
|
||||
And user "Brian" has accepted share "/textfile1.txt" offered by user "Alice"
|
||||
When user "Brian" uploads a file inside space "Shares Jail" with content "this is a new content" to "textfile1.txt" using the WebDAV API
|
||||
Then the HTTP status code should be "204"
|
||||
And for user "Brian" the space "Shares Jail" should contain these entries:
|
||||
| textfile1.txt |
|
||||
And for user "Brian" the content of the file "/textfile1.txt" of the space "Shares Jail" should be "this is a new content"
|
||||
And for user "Alice" the content of the file "/textfile1.txt" of the space "Personal" should be "this is a new content"
|
||||
@@ -0,0 +1,46 @@
|
||||
@api @skipOnOcV10
|
||||
Feature: favorite
|
||||
|
||||
Background:
|
||||
Given these users have been created with default attributes and without skeleton files:
|
||||
| username |
|
||||
| Alice |
|
||||
| Brian |
|
||||
And using spaces DAV path
|
||||
And user "Alice" has created folder "/PARENT"
|
||||
|
||||
|
||||
Scenario: favorite a received share itself
|
||||
Given user "Alice" has shared folder "/PARENT" with user "Brian"
|
||||
And user "Brian" has accepted share "/PARENT" offered by user "Alice"
|
||||
When user "Brian" favorites element "/PARENT" in space "Shares Jail" using the WebDAV API
|
||||
Then the HTTP status code should be "207"
|
||||
And as user "Brian" folder "/PARENT" inside space "Shares Jail" should contain a property "oc:favorite" with value "1"
|
||||
|
||||
|
||||
Scenario: favorite a file inside of a received share
|
||||
Given user "Alice" has uploaded file with content "some data" to "/PARENT/parent.txt"
|
||||
And user "Alice" has shared folder "/PARENT" with user "Brian"
|
||||
And user "Brian" has accepted share "/PARENT" offered by user "Alice"
|
||||
When user "Brian" favorites element "/PARENT/parent.txt" in space "Shares Jail" using the WebDAV API
|
||||
Then the HTTP status code should be "207"
|
||||
And as user "Brian" file "/PARENT/parent.txt" inside space "Shares Jail" should contain a property "oc:favorite" with value "1"
|
||||
|
||||
|
||||
Scenario: favorite a folder inside of a received share
|
||||
Given user "Alice" has created folder "/PARENT/sub-folder"
|
||||
And user "Alice" has shared folder "/PARENT" with user "Brian"
|
||||
And user "Brian" has accepted share "/PARENT" offered by user "Alice"
|
||||
When user "Brian" favorites element "/PARENT/sub-folder" in space "Shares Jail" using the WebDAV API
|
||||
Then the HTTP status code should be "207"
|
||||
And as user "Brian" folder "/PARENT/sub-folder" inside space "Shares Jail" should contain a property "oc:favorite" with value "1"
|
||||
|
||||
|
||||
Scenario: sharee file favorite state should not change the favorite state of sharer
|
||||
Given user "Alice" has uploaded file with content "some data" to "/PARENT/parent.txt"
|
||||
And user "Alice" has shared file "/PARENT/parent.txt" with user "Brian"
|
||||
And user "Brian" has accepted share "/parent.txt" offered by user "Alice"
|
||||
When user "Brian" favorites element "/parent.txt" in space "Shares Jail" using the WebDAV API
|
||||
Then the HTTP status code should be "207"
|
||||
And as user "Brian" file "/parent.txt" inside space "Shares Jail" should contain a property "oc:favorite" with value "1"
|
||||
And as user "Alice" file "/PARENT/parent.txt" inside space "Personal" should contain a property "oc:favorite" with value "0"
|
||||
@@ -0,0 +1,90 @@
|
||||
@api @skipOnOcV10
|
||||
Feature: lock
|
||||
# Note: This Feature includes all the tests from core (apiWebdavLock suite) related to /Shares since in core no implementation is there for space Shares Jail
|
||||
|
||||
Background:
|
||||
Given these users have been created with default attributes and without skeleton files:
|
||||
| username |
|
||||
| Alice |
|
||||
| Brian |
|
||||
| Carol |
|
||||
And user "Alice" has created folder "PARENT"
|
||||
And user "Brian" has created folder "PARENT"
|
||||
And user "Carol" has created folder "PARENT"
|
||||
And using spaces DAV path
|
||||
|
||||
|
||||
Scenario Outline: lock should propagate correctly when uploaded to a reshare that was locked by the owner
|
||||
Given user "Alice" has shared folder "PARENT" with user "Brian"
|
||||
And user "Brian" has accepted share "/PARENT" offered by user "Alice"
|
||||
And user "Brian" has shared the following entity "PARENT" inside of space "Shares Jail" with user "Carol" with role "editor"
|
||||
And user "Carol" has accepted share "/PARENT" offered by user "Brian"
|
||||
And user "Alice" has locked folder "/PARENT" inside space "Personal" setting the following properties
|
||||
| lockscope | <lock-scope> |
|
||||
When user "Carol" uploads a file inside space "Shares Jail" with content "uploaded by carol" to "PARENT/textfile.txt" using the WebDAV API
|
||||
And user "Brian" uploads a file inside space "Shares Jail" with content "uploaded by brian" to "PARENT/textfile.txt" using the WebDAV API
|
||||
And user "Alice" uploads file "filesForUpload/textfile.txt" to "/PARENT/textfile.txt" using the WebDAV API
|
||||
Then the HTTP status code of responses on all endpoints should be "423"
|
||||
And as "Alice" file "/PARENT/textfile.txt" should not exist
|
||||
Examples:
|
||||
| lock-scope |
|
||||
| shared |
|
||||
| exclusive |
|
||||
|
||||
|
||||
Scenario Outline: lock should propagate correctly when uploaded overwriting to a reshare that was locked by the owner
|
||||
Given user "Alice" has uploaded file with content "ownCloud test text file parent" to "PARENT/parent.txt"
|
||||
And user "Alice" has shared folder "PARENT" with user "Brian"
|
||||
And user "Brian" has accepted share "/PARENT" offered by user "Alice"
|
||||
And user "Brian" has shared the following entity "PARENT" inside of space "Shares Jail" with user "Carol" with role "editor"
|
||||
And user "Carol" has accepted share "/PARENT" offered by user "Brian"
|
||||
And user "Alice" has locked folder "/PARENT" inside space "Personal" setting the following properties
|
||||
| lockscope | <lock-scope> |
|
||||
When user "Carol" uploads a file inside space "Shares Jail" with content "uploaded by carol" to "PARENT/textfile.txt" using the WebDAV API
|
||||
And user "Brian" uploads a file inside space "Shares Jail" with content "uploaded by brian" to "PARENT/textfile.txt" using the WebDAV API
|
||||
And user "Alice" uploads file "filesForUpload/textfile.txt" to "/PARENT/parent.txt" using the WebDAV API
|
||||
Then the HTTP status code of responses on all endpoints should be "423"
|
||||
And the content of file "/PARENT/parent.txt" for user "Alice" should be "ownCloud test text file parent"
|
||||
Examples:
|
||||
| lock-scope |
|
||||
| shared |
|
||||
| exclusive |
|
||||
|
||||
|
||||
Scenario Outline: lock should propagate correctly when the public uploads to a reshared share that was locked by the original owner
|
||||
Given user "Alice" has shared folder "PARENT" with user "Brian"
|
||||
And user "Brian" has accepted share "/PARENT" offered by user "Alice"
|
||||
And user "Brian" has shared the following entity "PARENT" inside of space "Shares Jail" with user "Carol" with role "editor"
|
||||
And user "Carol" has accepted share "/PARENT" offered by user "Brian"
|
||||
And user "Carol" has created a public link share inside of space "Shares Jail" with settings:
|
||||
| path | PARENT |
|
||||
| shareType | 3 |
|
||||
| permissions | 15 |
|
||||
| name | public link |
|
||||
And user "Alice" has locked folder "/PARENT" inside space "Personal" setting the following properties
|
||||
| lockscope | <lock-scope> |
|
||||
When the public uploads file "test.txt" with content "test" using the new public WebDAV API
|
||||
Then the HTTP status code should be "423"
|
||||
And as "Alice" file "/PARENT/test.txt" should not exist
|
||||
Examples:
|
||||
| lock-scope |
|
||||
| shared |
|
||||
| exclusive |
|
||||
|
||||
|
||||
Scenario Outline: lock should propagate correctly when uploaded to a reshare that was locked by the resharing user
|
||||
Given user "Alice" has shared folder "PARENT" with user "Brian"
|
||||
And user "Brian" has accepted share "/PARENT" offered by user "Alice"
|
||||
And user "Brian" has shared the following entity "PARENT" inside of space "Shares Jail" with user "Carol" with role "editor"
|
||||
And user "Carol" has accepted share "/PARENT" offered by user "Brian"
|
||||
And user "Brian" has locked folder "/PARENT" inside space "Shares Jail" setting the following properties
|
||||
| lockscope | <lock-scope> |
|
||||
When user "Carol" uploads a file inside space "Shares Jail" with content "uploaded by carol" to "PARENT/textfile.txt" using the WebDAV API
|
||||
And user "Brian" uploads a file inside space "Shares Jail" with content "uploaded by brian" to "PARENT/textfile.txt" using the WebDAV API
|
||||
And user "Alice" uploads file "filesForUpload/textfile.txt" to "/PARENT/textfile.txt" using the WebDAV API
|
||||
Then the HTTP status code of responses on all endpoints should be "423"
|
||||
And as "Alice" file "/PARENT/textfile.txt" should not exist
|
||||
Examples:
|
||||
| lock-scope |
|
||||
| shared |
|
||||
| exclusive |
|
||||
@@ -198,6 +198,8 @@ Feature: move (rename) file
|
||||
Then the HTTP status code should be "201"
|
||||
And for user "Alice" folder "testshare2" of the space "Shares Jail" should contain these entries:
|
||||
| testshare1.txt |
|
||||
And for user "Alice" folder "testshare1" of the space "Shares Jail" should not contain these entries:
|
||||
| testshare1.txt |
|
||||
And for user "Brian" the space "Personal" should contain these entries:
|
||||
| /testshare2/testshare1.txt |
|
||||
|
||||
|
||||
@@ -536,4 +536,25 @@ class GraphContext implements Context {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^the user "([^"]*)" changes its own password "([^"]*)" to "([^"]*)" using the Graph API$/
|
||||
* @param string $user
|
||||
* @param string $currentPassword
|
||||
* @param string $newPassword
|
||||
*
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userChangesOwnPassword(string $user, string $currentPassword, $newPassword): void {
|
||||
$response = GraphHelper::changeOwnPassword(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user),
|
||||
$currentPassword,
|
||||
$newPassword
|
||||
);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,6 +97,12 @@ class SpacesContext implements Context {
|
||||
*/
|
||||
private $storedEtags = [];
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string[][]
|
||||
*/
|
||||
private $tokenOfLastLock = [];
|
||||
|
||||
private $etagPropfindBody = '<?xml version="1.0"?>'
|
||||
. '<d:propfind xmlns:d="DAV:" '
|
||||
. 'xmlns:oc="http://owncloud.org/ns" '
|
||||
@@ -457,7 +463,7 @@ class SpacesContext implements Context {
|
||||
}
|
||||
$this->sendDeleteSpaceRequest($userName, $value["name"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -589,6 +595,28 @@ class SpacesContext implements Context {
|
||||
return HttpRequestHelper::sendRequest($fullUrl, $xRequestId, $method, $user, $password, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* send proppatch request to url
|
||||
*
|
||||
* @param string $fullUrl
|
||||
* @param string $user
|
||||
* @param string $password
|
||||
* @param string $xRequestId
|
||||
* @param array $headers
|
||||
* @param mixed|null $body
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function sendPropPatchRequest(
|
||||
string $fullUrl,
|
||||
string $user,
|
||||
string $password,
|
||||
string $xRequestId = '',
|
||||
array $headers = [],
|
||||
$body
|
||||
): ResponseInterface {
|
||||
return HttpRequestHelper::sendRequest($fullUrl, $xRequestId, 'PROPPATCH', $user, $password, $headers, $body);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^user "([^"]*)" lists all available spaces via the GraphApi$/
|
||||
* @When /^user "([^"]*)" lists all available spaces via the GraphApi with query "([^"]*)"$/
|
||||
@@ -1245,6 +1273,20 @@ class SpacesContext implements Context {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes the given string for
|
||||
* 1. Space --> %20
|
||||
* 2. Opening Small Bracket --> %28
|
||||
* 3. Closing Small Bracket --> %29
|
||||
*
|
||||
* @param string $path - File path to parse
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function escapePath(string $path): string {
|
||||
return \str_replace([" ", "(", ")"], ["%20", "%28", "%29"], $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* parses a PROPFIND response from $this->response into xml
|
||||
* and returns found search results if found else returns false
|
||||
@@ -1274,6 +1316,9 @@ class SpacesContext implements Context {
|
||||
// trim any leading "/" passed by the caller, we can just match the "raw" name
|
||||
$trimmedEntryNameToSearch = \trim($entryNameToSearch, "/");
|
||||
|
||||
// url encode for spaces and brackets that may appear in the filePath
|
||||
$folderPath = $this->escapePath($folderPath);
|
||||
|
||||
// topWebDavPath should be something like /remote.php/webdav/ or
|
||||
// /remote.php/dav/files/alice/
|
||||
$topWebDavPath = "/" . "dav/spaces/" . $spaceId . "/" . $folderPath;
|
||||
@@ -1727,6 +1772,7 @@ class SpacesContext implements Context {
|
||||
* @param string $spaceName
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userMovesFileWithinSpaceUsingTheWebDAVAPI(
|
||||
string $user,
|
||||
@@ -1741,10 +1787,42 @@ class SpacesContext implements Context {
|
||||
$spaceName
|
||||
);
|
||||
|
||||
$fullUrl = $space["root"]["webDavUrl"] . '/' . \trim($fileSource, "/");
|
||||
$fileSource = $this->escapePath(\trim($fileSource, "/"));
|
||||
$fullUrl = $space["root"]["webDavUrl"] . '/' . $fileSource;
|
||||
$this->moveFilesAndFoldersRequest($user, $fullUrl, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^user "([^"]*)" has moved (?:file|folder) "([^"]*)" to "([^"]*)" in space "([^"]*)"$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $fileSource
|
||||
* @param string $fileDestination
|
||||
* @param string $spaceName
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userHasMovedFileWithinSpaceUsingTheWebDAVAPI(
|
||||
string $user,
|
||||
string $fileSource,
|
||||
string $fileDestination,
|
||||
string $spaceName
|
||||
):void {
|
||||
$this->userMovesFileWithinSpaceUsingTheWebDAVAPI(
|
||||
$user,
|
||||
$fileSource,
|
||||
$fileDestination,
|
||||
$spaceName
|
||||
);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(
|
||||
201,
|
||||
__METHOD__ . "Expected response status code should be 201 (Created)\n" .
|
||||
"Actual response status code was: " . $this->featureContext->getResponse()->getStatusCode() . "\n" .
|
||||
"Actual response body was: " . $this->featureContext->getResponse()->getBody()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* MOVE request for files|folders
|
||||
*
|
||||
@@ -1766,6 +1844,9 @@ class SpacesContext implements Context {
|
||||
$headers,
|
||||
)
|
||||
);
|
||||
$this->featureContext->pushToLastHttpStatusCodesArray(
|
||||
(string)$this->featureContext->getResponse()->getStatusCode()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1830,7 +1911,10 @@ class SpacesContext implements Context {
|
||||
*/
|
||||
public function destinationHeaderValueWithSpaceName(string $user, string $fileDestination, string $spaceName):string {
|
||||
$space = $this->getSpaceByName($user, $spaceName);
|
||||
return $space["root"]["webDavUrl"] . '/' . \ltrim($fileDestination, '/');
|
||||
|
||||
$fileDestination = $this->escapePath(\ltrim($fileDestination, "/"));
|
||||
|
||||
return $space["root"]["webDavUrl"] . '/' . $fileDestination;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1934,7 +2018,7 @@ class SpacesContext implements Context {
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^user "([^"]*)" shares the following entity "([^"]*)" inside of space "([^"]*)" with user "([^"]*)" with role "([^"]*)"$/
|
||||
* Request to send share of resource inside of space
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $entity
|
||||
@@ -1945,13 +2029,7 @@ class SpacesContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function sendShareEntityInsideOfSpaceRequest(
|
||||
string $user,
|
||||
string $entity,
|
||||
string $spaceName,
|
||||
string $userRecipient,
|
||||
string $role
|
||||
): void {
|
||||
public function sendRequestForShareOfEntityInsideOfSpace(string $user, string $entity, string $spaceName, string $userRecipient, string $role):void {
|
||||
$space = $this->getSpaceByName($user, $spaceName);
|
||||
$body = [
|
||||
"space_ref" => $space['id'] . "/" . $entity,
|
||||
@@ -1973,6 +2051,54 @@ class SpacesContext implements Context {
|
||||
$this->setLastShareData();
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^user "([^"]*)" shares the following entity "([^"]*)" inside of space "([^"]*)" with user "([^"]*)" with role "([^"]*)"$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $entity
|
||||
* @param string $spaceName
|
||||
* @param string $userRecipient
|
||||
* @param string $role
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function sharesTheFollowingEntityInsideOfSpace(
|
||||
string $user,
|
||||
string $entity,
|
||||
string $spaceName,
|
||||
string $userRecipient,
|
||||
string $role
|
||||
): void {
|
||||
$this->sendRequestForShareOfEntityInsideOfSpace($user, $entity, $spaceName, $userRecipient, $role);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^user "([^"]*)" has shared the following entity "([^"]*)" inside of space "([^"]*)" with user "([^"]*)" with role "([^"]*)"$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $entity
|
||||
* @param string $spaceName
|
||||
* @param string $userRecipient
|
||||
* @param string $role
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function hasSharedTheFollowingEntityInsideOfSpace(
|
||||
string $user,
|
||||
string $entity,
|
||||
string $spaceName,
|
||||
string $userRecipient,
|
||||
string $role
|
||||
): void {
|
||||
$this->sendRequestForShareOfEntityInsideOfSpace($user, $entity, $spaceName, $userRecipient, $role);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(
|
||||
200,
|
||||
"Expected response status code should be 200"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^user "([^"]*)" creates a public link share inside of space "([^"]*)" with settings:$/
|
||||
*
|
||||
@@ -2807,6 +2933,74 @@ class SpacesContext implements Context {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to lock the resource inside of space
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $resource
|
||||
* @param TableNode $properties
|
||||
* @param string $spaceName
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function sendRequestToLockResouceInsideOfSpace(string $user, string $resource, TableNode $properties, string $spaceName):void {
|
||||
$body
|
||||
= "<?xml version='1.0' encoding='UTF-8'?>" .
|
||||
"<d:lockinfo xmlns:d='DAV:'> ";
|
||||
$headers = [];
|
||||
$this->featureContext->verifyTableNodeRows($properties, [], ['lockscope', 'depth', 'timeout']);
|
||||
$propertiesRows = $properties->getRowsHash();
|
||||
foreach ($propertiesRows as $property => $value) {
|
||||
if ($property === "depth" || $property === "timeout") {
|
||||
//properties that are set in the header not in the xml
|
||||
$headers[$property] = $value;
|
||||
} else {
|
||||
$body .= "<d:$property><d:$value/></d:$property>";
|
||||
}
|
||||
}
|
||||
$body .= "</d:lockinfo>";
|
||||
$space = $this->getSpaceByName($user, $spaceName);
|
||||
$fullUrl = $space['root']['webDavUrl'] . '/' . ltrim($resource, '/');
|
||||
$this->featureContext->setResponse(
|
||||
HttpRequestHelper::sendRequest(
|
||||
$fullUrl,
|
||||
"",
|
||||
'LOCK',
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user),
|
||||
[],
|
||||
$body
|
||||
)
|
||||
);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(
|
||||
200,
|
||||
__METHOD__ . " Failed to lock the resource $resource"
|
||||
);
|
||||
$responseXml = $this->featureContext->getResponseXml(null, __METHOD__);
|
||||
$this->featureContext->setResponseXmlObject($responseXml);
|
||||
$xmlPart = $responseXml->xpath("//d:locktoken/d:href");
|
||||
if (\is_array($xmlPart) && isset($xmlPart[0])) {
|
||||
$this->tokenOfLastLock[$user][$resource] = (string) $xmlPart[0];
|
||||
} else {
|
||||
Assert::fail("could not find lock token after trying to lock '$resource'");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^user "([^"]*)" has locked folder "([^"]*)" inside space "([^"]*)" setting the following properties$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $resource
|
||||
* @param TableNode $properties
|
||||
* @param string $spaceName
|
||||
*
|
||||
* @throws Exception | GuzzleException
|
||||
*/
|
||||
public function userHasLockedResourceOfSpace(string $user, string $resource, TableNode $properties, string $spaceName) {
|
||||
$this->sendRequestToLockResouceInsideOfSpace($user, $resource, $properties, $spaceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^user "([^"]*)" creates a public link share of the space "([^"]*)" with settings:$/
|
||||
*
|
||||
@@ -3015,4 +3209,38 @@ class SpacesContext implements Context {
|
||||
$expectedValue
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^user "([^"]*)" favorites element "([^"]*)" in space "([^"]*)" using the WebDAV API$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $path
|
||||
* @param string $spaceName
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userFavoritesElementInSpaceUsingTheWebdavApi(string $user, string $path, string $spaceName): void {
|
||||
$space = $this->getSpaceByName($user, $spaceName);
|
||||
$fullUrl = $space["root"]["webDavUrl"] . '/' . ltrim($path, "/");
|
||||
$body = '<?xml version="1.0"?>
|
||||
<d:propertyupdate xmlns:d="DAV:"
|
||||
xmlns:oc="http://owncloud.org/ns">
|
||||
<d:set>
|
||||
<d:prop>
|
||||
<oc:favorite xmlns:oc="http://owncloud.org/ns">1</oc:favorite>
|
||||
</d:prop>
|
||||
</d:set>
|
||||
</d:propertyupdate>';
|
||||
$this->featureContext->setResponse(
|
||||
$this->sendProppatchRequest(
|
||||
$fullUrl,
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
[],
|
||||
$body
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user