Skip to content

Commit

Permalink
More share update rfefactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed May 24, 2022
1 parent cd4a8df commit efe18af
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ Feature: create a public link share
| path | /afolder |
| permissions | read |
And parameter "shareapi_allow_public_upload" of app "core" has been set to "no"
When user "Alice" tries to update the last share using the sharing API with
When user "Alice" tries to update the last public link share using the sharing API with
| permissions | read,create |
Then the OCS status code should be "<ocs_status_code>"

Expand Down Expand Up @@ -684,7 +684,7 @@ Feature: create a public link share
| path | /textfile0.txt |
| name | link2 |
| expireDateAsString | +5 days |
And the administrator expires the last created share using the testing API
And the administrator expires the last created public link share using the testing API
Then the HTTP status code should be "<http_status_code>"
When user "Alice" gets all the shares from the file "textfile0.txt" using the sharing API
Then the HTTP status code should be "<http_status_code>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Feature: multilinksharing
| publicUpload | true |
| permissions | change |
| name | sharedlink3 |
When user "Alice" updates the last share using the sharing API with
When user "Alice" updates the last public link share using the sharing API with
| permissions | read |
Then the OCS status code should be "<ocs_status_code>"
And the HTTP status code should be "200"
Expand Down Expand Up @@ -64,7 +64,7 @@ Feature: multilinksharing
| expireDate | +3 days |
| permissions | read |
| name | sharedlink3 |
When user "Alice" updates the last share using the sharing API with
When user "Alice" updates the last public link share using the sharing API with
| permissions | read |
Then the OCS status code should be "<ocs_status_code>"
And the HTTP status code should be "200"
Expand Down Expand Up @@ -95,7 +95,7 @@ Feature: multilinksharing
| publicUpload | true |
| permissions | change |
| name | sharedlink2 |
When user "Alice" updates the last share using the sharing API with
When user "Alice" updates the last public link share using the sharing API with
| password | %alt1% |
Then the OCS status code should be "<ocs_status_code>"
And the HTTP status code should be "200"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Feature: public share sharers groups setting
| permissions | read |
And parameter "public_share_sharers_groups_allowlist_enabled" of app "files_sharing" has been set to "yes"
And parameter "public_share_sharers_groups_allowlist" of app "files_sharing" has been set to '["grp1"]'
When user "Alice" updates the last share using the sharing API with
When user "Alice" updates the last public link share using the sharing API with
| expireDate | +3 days |
Then the HTTP status code should be "200"
And the OCS status code should be "100"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Feature: update a public link share
And user "Alice" has created folder "FOLDER"
And user "Alice" has created a public link share with settings
| path | FOLDER |
And user "Alice" has updated the last share with
And user "Alice" has updated the last public link share with
| expireDate | +3 days |
When user "Alice" gets the info of the last public link share using the sharing API
Then the OCS status code should be "<ocs_status_code>"
Expand Down Expand Up @@ -129,7 +129,7 @@ Feature: update a public link share
And user "Alice" has created a public link share with settings
| path | randomfile.txt |
| password | %public% |
When user "Alice" updates the last share using the sharing API with
When user "Alice" updates the last public link share using the sharing API with
| expireDate | +3 days |
Then the OCS status code should be "<ocs_status_code>"
And the HTTP status code should be "200"
Expand All @@ -153,7 +153,7 @@ Feature: update a public link share
And user "Alice" has created folder "FOLDER"
And user "Alice" has created a public link share with settings
| path | FOLDER |
And user "Alice" has updated the last share with
And user "Alice" has updated the last public link share with
| expireDate | +3 days |
When user "Alice" gets the info of the last public link share using the sharing API
Then the OCS status code should be "<ocs_status_code>"
Expand Down Expand Up @@ -186,7 +186,7 @@ Feature: update a public link share
And user "Alice" has created folder "FOLDER"
And user "Alice" has created a public link share with settings
| path | FOLDER |
And user "Alice" has updated the last share with
And user "Alice" has updated the last public link share with
| password | %public% |
When user "Alice" gets the info of the last public link share using the sharing API
Then the OCS status code should be "<ocs_status_code>"
Expand Down Expand Up @@ -218,7 +218,7 @@ Feature: update a public link share
And user "Alice" has created folder "FOLDER"
And user "Alice" has created a public link share with settings
| path | FOLDER |
And user "Alice" has updated the last share with
And user "Alice" has updated the last public link share with
| permissions | read,update,create,delete |
When user "Alice" gets the info of the last public link share using the sharing API
Then the OCS status code should be "<ocs_status_code>"
Expand Down Expand Up @@ -250,7 +250,7 @@ Feature: update a public link share
And user "Alice" has created folder "FOLDER"
And user "Alice" has created a public link share with settings
| path | FOLDER |
And user "Alice" has updated the last share with
And user "Alice" has updated the last public link share with
| permissions | read,update,create,delete |
When user "Alice" gets the info of the last public link share using the sharing API
Then the OCS status code should be "<ocs_status_code>"
Expand Down Expand Up @@ -282,7 +282,7 @@ Feature: update a public link share
And user "Alice" has created folder "FOLDER"
And user "Alice" has created a public link share with settings
| path | FOLDER |
And user "Alice" has updated the last share with
And user "Alice" has updated the last public link share with
| publicUpload | true |
When user "Alice" gets the info of the last public link share using the sharing API
Then the OCS status code should be "<ocs_status_code>"
Expand Down Expand Up @@ -350,7 +350,7 @@ Feature: update a public link share
And user "Brian" has created a public link share with settings
| path | /Shares/test |
| publicUpload | false |
When user "Brian" updates the last share using the sharing API with
When user "Brian" updates the last public link share using the sharing API with
| publicUpload | true |
Then the OCS status code should be "<ocs_status_code>"
And the HTTP status code should be "200"
Expand Down Expand Up @@ -410,7 +410,7 @@ Feature: update a public link share
And user "Brian" has created a public link share with settings
| path | /Shares/test |
| permissions | read |
When user "Brian" updates the last share using the sharing API with
When user "Brian" updates the last public link share using the sharing API with
| permissions | read,update,create,delete |
Then the OCS status code should be "<ocs_status_code>"
And the HTTP status code should be "200"
Expand All @@ -437,7 +437,7 @@ Feature: update a public link share
And user "Alice" has created a public link share with settings
| path | /PARENT |
| permissions | read,update,create,delete |
And user "Alice" has updated the last share with
And user "Alice" has updated the last public link share with
| permissions | read |
When the public deletes file "CHILD/child.txt" from the last public share using the <public-webdav-api-version> public WebDAV API
Then the HTTP status code should be "403"
Expand Down Expand Up @@ -465,7 +465,7 @@ Feature: update a public link share
And user "Alice" has created a public link share with settings
| path | /PARENT |
| permissions | read |
And user "Alice" has updated the last share with
And user "Alice" has updated the last public link share with
| permissions | read,update,create,delete |
When the public deletes file "CHILD/child.txt" from the last public share using the <public-webdav-api-version> public WebDAV API
And the public deletes file "parent.txt" from the last public share using the <public-webdav-api-version> public WebDAV API
Expand Down
10 changes: 10 additions & 0 deletions tests/acceptance/features/bootstrap/AppConfigurationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,16 @@ public function theAdministratorExpiresTheLastCreatedShare():void {
$this->expireLastCreatedUserShare();
}

/**
* @When the administrator expires the last created public link share using the testing API
*
* @return void
* @throws GuzzleException
*/
public function theAdministratorExpiresTheLastCreatedPublicLinkShare():void {
$this->expireLastCreatedPublicLinkShare();
}

/**
* @BeforeScenario
*
Expand Down
68 changes: 62 additions & 6 deletions tests/acceptance/features/bootstrap/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,17 @@ public function getLastShareData():SimpleXMLElement {
}

/**
* @param string $user
* @param string|null $user
*
* @return SimpleXMLElement
* @throws Exception
*/
public function getLastShareDataForUser(string $user):SimpleXMLElement {
public function getLastShareDataForUser(?string $user):SimpleXMLElement {
if ($user === null) {
throw new Exception(
__METHOD__ . " user not specified. Probably no user or group shares have been created yet in the test scenario."
);
}
if (isset($this->lastShareDataByUser[$user])) {
return $this->lastShareDataByUser[$user];
} else {
Expand Down Expand Up @@ -922,17 +927,27 @@ public function theUserHasUpdatedTheLastShareWith(?TableNode $body):void {
* @param string $user
* @param TableNode|null $body
* @param string|null $shareOwner
* @param bool $updateLastPublicLink
*
* @return void
* @throws Exception
*/
public function updateLastShareWithSettings(string $user, ?TableNode $body, ?string $shareOwner = null):void {
public function updateLastShareWithSettings(
string $user,
?TableNode $body,
?string $shareOwner = null,
?bool $updateLastPublicLink = false
):void {
$user = $this->getActualUsername($user);

if ($shareOwner === null) {
$share_id = $this->getLastShareData()->data[0]->id;
if ($updateLastPublicLink) {
$share_id = $this->getLastPublicLinkShareId();
} else {
$share_id = $this->getLastShareIdOf($shareOwner);
if ($shareOwner === null) {
$share_id = $this->getLastShareData()->data[0]->id;
} else {
$share_id = $this->getLastShareIdOf($shareOwner);
}
}

$this->verifyTableNodeRows(
Expand Down Expand Up @@ -983,6 +998,20 @@ public function userUpdatesTheLastShareWith(string $user, ?TableNode $body):void
$this->pushToLastStatusCodesArrays();
}

/**
* @When /^user "([^"]*)" updates the last public link share using the sharing API with$/
*
* @param string $user
* @param TableNode|null $body
*
* @return void
* @throws Exception
*/
public function userUpdatesTheLastPublicLinkShareWith(string $user, ?TableNode $body):void {
$this->updateLastShareWithSettings($user, $body, null, true);
$this->pushToLastStatusCodesArrays();
}

/**
* @Given /^user "([^"]*)" has updated the last share with$/
*
Expand All @@ -997,6 +1026,20 @@ public function userHasUpdatedTheLastShareWith(string $user, ?TableNode $body):v
$this->theHTTPStatusCodeShouldBeSuccess();
}

/**
* @Given /^user "([^"]*)" has updated the last public link share with$/
*
* @param string $user
* @param TableNode|null $body
*
* @return void
* @throws Exception
*/
public function userHasUpdatedTheLastPublicLinkShareWith(string $user, ?TableNode $body):void {
$this->updateLastShareWithSettings($user, $body, null, true);
$this->theHTTPStatusCodeShouldBeSuccess();
}

/**
* @Given /^user "([^"]*)" has updated the last share of "([^"]*)" with$/
*
Expand Down Expand Up @@ -1806,6 +1849,19 @@ public function userTriesToUpdateTheLastShareUsingTheSharingApiWith(string $user
$this->updateLastShareWithSettings($user, $body);
}

/**
* @When /^user "([^"]*)" tries to update the last public link share using the sharing API with$/
*
* @param string $user
* @param TableNode|null $body
*
* @return void
* @throws Exception
*/
public function userTriesToUpdateTheLastPublicLinkShareUsingTheSharingApiWith(string $user, ?TableNode $body):void {
$this->updateLastShareWithSettings($user, $body, null, true);
}

/**
* @Then /^user "([^"]*)" should not be able to share (file|folder|entry) "([^"]*)" with (user|group) "([^"]*)"(?: with permissions (\d+))? using the sharing API$/
* @Then /^user "([^"]*)" should not be able to share (file|folder|entry) "([^"]*)" with (user|group) "([^"]*)" with permissions "([^"]*)" using the sharing API$/
Expand Down

0 comments on commit efe18af

Please sign in to comment.