mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-04 07:41:48 -04:00
[tests-only] [full-ci] Refactoring unshare step definition code (#6608)
* added unshare scenerio * remove unshare keyword from step definition * refactoring of step definition codes * refactor
This commit is contained in:
@@ -158,7 +158,6 @@ class SharingHelper {
|
||||
$fd['expireDate'] = $expireDate;
|
||||
}
|
||||
$headers = ['OCS-APIREQUEST' => 'true'];
|
||||
|
||||
return HttpRequestHelper::post(
|
||||
$fullUrl,
|
||||
$xRequestId,
|
||||
|
||||
@@ -642,7 +642,7 @@ Not everything needs to be implemented for ocis. While the oc10 testsuite covers
|
||||
- [coreApiCapabilities/capabilities.feature:136](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiCapabilities/capabilities.feature#L136)
|
||||
- [coreApiCapabilities/capabilities.feature:175](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiCapabilities/capabilities.feature#L175)
|
||||
|
||||
#### [Sharing of project space root via public link does no longer work](https://github.com/owncloud/ocis/issues/6278)
|
||||
#### [sharing the shares folder to users exits with different status code than in oc10 backend](https://github.com/owncloud/ocis/issues/2215)
|
||||
- [coreApiShareCreateSpecialToShares2/createShareDefaultFolderForReceivedShares.feature:23](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiShareCreateSpecialToShares2/createShareDefaultFolderForReceivedShares.feature#L23)
|
||||
- [coreApiShareCreateSpecialToShares2/createShareDefaultFolderForReceivedShares.feature:24](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiShareCreateSpecialToShares2/createShareDefaultFolderForReceivedShares.feature#L24)
|
||||
|
||||
|
||||
@@ -3529,6 +3529,25 @@ trait Sharing {
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function userHasUnsharedResourceSharedTo(string $sharer, string $path, string $sharee): void {
|
||||
$this->userUnsharesResourceSharedTo($sharer, $path, $sharee);
|
||||
$this->ocsContext->assertOCSResponseIndicatesSuccess(
|
||||
'The ocs share response does not indicate success.',
|
||||
);
|
||||
$this->emptyLastHTTPStatusCodesArray();
|
||||
$this->emptyLastOCSStatusCodesArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^user "([^"]*)" unshares (?:folder|file|entity) "([^"]*)" shared to "([^"]*)"$/
|
||||
*
|
||||
* @param string $sharer
|
||||
* @param string $path
|
||||
* @param string $sharee
|
||||
*
|
||||
* @return void
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function userUnsharesResourceSharedTo(string $sharer, string $path, string $sharee): void {
|
||||
$sharer = $this->getActualUsername($sharer);
|
||||
$sharee = $this->getActualUsername($sharee);
|
||||
|
||||
@@ -3550,12 +3569,6 @@ trait Sharing {
|
||||
'DELETE',
|
||||
'/apps/files_sharing/api/v' . $this->sharingApiVersion . '/shares/' . $shareId
|
||||
);
|
||||
|
||||
$this->ocsContext->assertOCSResponseIndicatesSuccess(
|
||||
'The ocs share response does not indicate success.',
|
||||
);
|
||||
$this->emptyLastHTTPStatusCodesArray();
|
||||
$this->emptyLastOCSStatusCodesArray();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3340,78 +3340,71 @@ trait WebDav {
|
||||
* @return void
|
||||
*/
|
||||
public function fileHasBeenDeleted(string $file, string $user):void {
|
||||
$this->userHasDeletedFile($user, "deleted", "file", $file);
|
||||
$this->userHasDeletedResource($user, "deleted", "file", $file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^user "([^"]*)" (?:deletes|unshares) (?:file|folder) "([^"]*)" using the WebDAV API$/
|
||||
* @When user :user deletes file/folder :resource using the WebDAV API
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $file
|
||||
* @param string $resource
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userDeletesFile(string $user, string $file):void {
|
||||
public function userDeletesFile(string $user, string $resource):void {
|
||||
$user = $this->getActualUsername($user);
|
||||
$this->pauseUploadDelete();
|
||||
$this->response = $this->makeDavRequest($user, 'DELETE', $file, []);
|
||||
$this->response = $this->makeDavRequest($user, 'DELETE', $resource, []);
|
||||
$this->lastUploadDeleteTime = \time();
|
||||
$this->pushToLastHttpStatusCodesArray((string) $this->getResponse()->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^user "([^"]*)" has (deleted|unshared) (?:file|folder|entity) "([^"]*)"$/
|
||||
* @Given /^user "([^"]*)" has deleted (?:file|folder|entity) "([^"]*)"$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $deletedOrUnshared
|
||||
* @param string $entry
|
||||
* @param string $resource
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userHasDeletedFile(string $user, string $deletedOrUnshared, string $entry):void {
|
||||
public function userHasDeletedResource(string $user, string $resource):void {
|
||||
$user = $this->getActualUsername($user);
|
||||
$this->userDeletesFile($user, $entry);
|
||||
$this->userDeletesFile($user, $resource);
|
||||
// If the file or folder was there and got deleted then we get a 204
|
||||
// That is good and the expected status
|
||||
// If the file or folder was already not there then we get a 404
|
||||
// That is not expected. Scenarios that use "Given user has deleted..."
|
||||
// should only be using such steps when it is a file that exists and needs
|
||||
// to be deleted.
|
||||
if ($deletedOrUnshared === "deleted") {
|
||||
$deleteText = "delete";
|
||||
} else {
|
||||
$deleteText = "unshare";
|
||||
}
|
||||
|
||||
$this->theHTTPStatusCodeShouldBe(
|
||||
["204"],
|
||||
"HTTP status code was not 204 while trying to $deleteText resource '$entry' for user '$user'"
|
||||
"HTTP status code was not 204 while trying to delete resource '$resource' for user '$user'"
|
||||
);
|
||||
$this->emptyLastHTTPStatusCodesArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^user "([^"]*)" has (deleted|unshared) the following (?:files|folders|resources)$/
|
||||
* @Given /^user "([^"]*)" has deleted the following (?:files|folders|resources)$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $deletedOrUnshared
|
||||
* @param TableNode $table
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userHasDeletedFollowingFiles(string $user, string $deletedOrUnshared, TableNode $table):void {
|
||||
public function userHasDeletedFollowingFiles(string $user, TableNode $table):void {
|
||||
$this->verifyTableNodeColumns($table, ["path"]);
|
||||
$paths = $table->getHash();
|
||||
|
||||
foreach ($paths as $file) {
|
||||
$this->userHasDeletedFile($user, $deletedOrUnshared, $file["path"]);
|
||||
$this->userHasDeletedResource($user, $file["path"]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^user "([^"]*)" (?:deletes|unshares) the following (?:files|folders)$/
|
||||
* @When /^user "([^"]*)" deletes the following (?:files|folders)$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param TableNode $table
|
||||
@@ -3431,7 +3424,7 @@ trait WebDav {
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^the user (?:deletes|unshares) (?:file|folder) "([^"]*)" using the WebDAV API$/
|
||||
* @When /^the user deletes (?:file|folder) "([^"]*)" using the WebDAV API$/
|
||||
*
|
||||
* @param string $file
|
||||
*
|
||||
@@ -3442,20 +3435,19 @@ trait WebDav {
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^the user has (deleted|unshared) (file|folder) "([^"]*)"$/
|
||||
* @Given /^the user has deleted (file|folder) "([^"]*)"$/
|
||||
*
|
||||
* @param string $deletedOrUnshared
|
||||
* @param string $fileOrFolder
|
||||
* @param string $file
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function theUserHasDeletedFile(string $deletedOrUnshared, string $fileOrFolder, string $file):void {
|
||||
$this->userHasDeletedFile($this->getCurrentUser(), $deletedOrUnshared, $fileOrFolder, $file);
|
||||
public function theUserHasDeletedFile(string $fileOrFolder, string $file):void {
|
||||
$this->userHasDeletedResource($this->getCurrentUser(), $fileOrFolder, $file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^user "([^"]*)" (?:deletes|unshares) these (?:files|folders|entries) without delays using the WebDAV API$/
|
||||
* @When /^user "([^"]*)" deletes these (?:files|folders|entries) without delays using the WebDAV API$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param TableNode $table of files or folders to delete
|
||||
@@ -3475,7 +3467,7 @@ trait WebDav {
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^the user (?:deletes|unshares) these (?:files|folders|entries) without delays using the WebDAV API$/
|
||||
* @When /^the user deletes these (?:files|folders|entries) without delays using the WebDAV API$/
|
||||
*
|
||||
* @param TableNode $table of files or folders to delete
|
||||
*
|
||||
@@ -3487,7 +3479,7 @@ trait WebDav {
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^user "([^"]*)" on "(LOCAL|REMOTE)" (?:deletes|unshares) (?:file|folder) "([^"]*)" using the WebDAV API$/
|
||||
* @When /^user "([^"]*)" on "(LOCAL|REMOTE)" deletes (?:file|folder) "([^"]*)" using the WebDAV API$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $server
|
||||
@@ -3502,30 +3494,24 @@ trait WebDav {
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^user "([^"]*)" on "(LOCAL|REMOTE)" has (deleted|unshared) (file|folder) "([^"]*)"$/
|
||||
* @Given /^user "([^"]*)" on "(LOCAL|REMOTE)" has deleted (file|folder) "([^"]*)"$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $server
|
||||
* @param string $deletedOrUnshared
|
||||
* @param string $fileOrFolder
|
||||
* @param string $entry
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userOnHasDeletedFile(string $user, string $server, string $deletedOrUnshared, string $fileOrFolder, string $entry):void {
|
||||
public function userOnHasDeletedFile(string $user, string $server, string $fileOrFolder, string $entry):void {
|
||||
$this->userOnDeletesFile($user, $server, $entry);
|
||||
// If the file was there and got deleted then we get a 204
|
||||
// If the file was already not there then we get a 404
|
||||
// Either way, the outcome of the "given" step is OK
|
||||
if ($deletedOrUnshared === "deleted") {
|
||||
$deleteText = "delete";
|
||||
} else {
|
||||
$deleteText = "unshare";
|
||||
}
|
||||
|
||||
$this->theHTTPStatusCodeShouldBe(
|
||||
["204", "404"],
|
||||
"HTTP status code was not 204 or 404 while trying to $deleteText $fileOrFolder '$entry' for user '$user' on server '$server'"
|
||||
"HTTP status code was not 204 or 404 while trying to delete $fileOrFolder '$entry' for user '$user' on server '$server'"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4456,7 +4442,7 @@ trait WebDav {
|
||||
foreach ($elementList as $element) {
|
||||
$element = \substr((string)$element, \strlen($davPrefix));
|
||||
if ($checkEachDelete) {
|
||||
$this->userHasDeletedFile($user, "deleted", "file", $element);
|
||||
$this->userHasDeletedResource($user, "deleted", "file", $element);
|
||||
} else {
|
||||
$this->userDeletesFile($user, $element);
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ Feature: shares are received in the default folder for received shares
|
||||
And user "Alice" has created folder "FOLDER"
|
||||
When user "Alice" shares folder "/FOLDER" with user "Brian" using the sharing API
|
||||
And user "Brian" accepts share "/FOLDER" offered by user "Alice" using the sharing API
|
||||
And user "Brian" unshares folder "Shares/FOLDER" using the WebDAV API
|
||||
And user "Brian" declines share "/Shares/FOLDER" offered by user "Alice" using the sharing API
|
||||
And user "Brian" shares folder "/Shares" with user "Alice" using the sharing API
|
||||
Then the OCS status code of responses on each endpoint should be "<ocs_status_code>" respectively
|
||||
And the HTTP status code of responses on each endpoint should be "<http_status_code>" respectively
|
||||
Examples:
|
||||
| ocs_api_version | ocs_status_code | http_status_code |
|
||||
| 1 | 100, 100, 400 | 200, 200, 204, 200 |
|
||||
| 2 | 200, 200, 400 | 200, 200, 204, 400 |
|
||||
| ocs_api_version | ocs_status_code | http_status_code |
|
||||
| 1 | 100, 100, 100, 400 | 200, 200, 200, 200 |
|
||||
| 2 | 200, 200, 200, 400 | 200, 200, 200, 400 |
|
||||
|
||||
@@ -74,7 +74,7 @@ Feature: sharing
|
||||
And as "Alice" file "/shared_file.txt" should exist in the trashbin
|
||||
And as "Brian" file "/shared_file.txt" should exist in the trashbin
|
||||
|
||||
|
||||
|
||||
Scenario: deleting a folder out of a share as recipient creates a backup for the owner
|
||||
Given using OCS API version "1"
|
||||
And user "Alice" has created folder "/shared"
|
||||
@@ -106,8 +106,8 @@ Feature: sharing
|
||||
And user "Carol" has stored etag of element "/PARENT"
|
||||
And user "Brian" has stored etag of element "/"
|
||||
And user "Brian" has stored etag of element "/Shares"
|
||||
When user "Brian" unshares file "/Shares/parent.txt" using the WebDAV API
|
||||
Then the HTTP status code should be "204"
|
||||
When user "Brian" declines share "/Shares/parent.txt" offered by user "Carol" using the sharing API
|
||||
Then the HTTP status code should be "200"
|
||||
And the etag of element "/" of user "Brian" should have changed
|
||||
And the etag of element "/Shares" of user "Brian" should have changed
|
||||
And the etag of element "/PARENT" of user "Carol" should not have changed
|
||||
@@ -226,3 +226,17 @@ Feature: sharing
|
||||
| ocs_api_version | ocs_status_code | http_status_code |
|
||||
| 1 | 404 | 200 |
|
||||
| 2 | 404 | 404 |
|
||||
|
||||
|
||||
Scenario Outline: unshare a shared resources
|
||||
Given using OCS API version "<ocs_api_version>"
|
||||
And user "Alice" has shared file "textfile0.txt" with user "Brian"
|
||||
And user "Brian" has accepted share "/textfile0.txt" offered by user "Alice"
|
||||
When user "Alice" unshares file "textfile0.txt" shared to "Brian"
|
||||
Then the OCS status code should be "<ocs_status_code>"
|
||||
And the HTTP status code should be "<http_status_code>"
|
||||
And as "Brian" file "/Shares/textfile0.txt" should not exist
|
||||
Examples:
|
||||
| ocs_api_version | ocs_status_code | http_status_code |
|
||||
| 1 | 100 | 200 |
|
||||
| 2 | 200 | 200 |
|
||||
|
||||
@@ -421,7 +421,7 @@ Feature: dav-versions
|
||||
| new | Brian | /testshare |
|
||||
|
||||
|
||||
Scenario: receiver tries to get file versions of unshared file from the sharer
|
||||
Scenario: sharee tries to get file versions of file not shared by the sharer
|
||||
Given user "Brian" has been created with default attributes and without skeleton files
|
||||
And user "Alice" has uploaded file with content "textfile0" to "textfile0.txt"
|
||||
And user "Alice" has uploaded file with content "textfile1" to "textfile1.txt"
|
||||
|
||||
Reference in New Issue
Block a user