Skip to content

Commit

Permalink
More flexible tests for share ids
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed May 24, 2022
1 parent cd82c08 commit 4f5c8e4
Show file tree
Hide file tree
Showing 19 changed files with 347 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -831,10 +831,9 @@ Feature: a default expiration date can be specified for shares with users or gro
| path | /textfile0.txt |
| shareWith | brand-new-group |
| expireDate | +15 days |
And the administrator has expired the last created share using the testing API
And the administrator has expired the last created public link share using the testing API
When the public accesses the preview of file "textfile0.txt" from the last shared public link using the sharing API
Then the HTTP status code should be "404"
And user "Alice" should not see the share id of the last share
And as "Alice" file "/textfile0.txt" should exist


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Feature: sharing
And user "Alice" has created folder "PARENT"
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "/PARENT/parent.txt"
And user "Alice" has shared entry "<entry_to_share>" with group "grp1"
When user "Brian" deletes the last share using the sharing API
When user "Brian" deletes the last share of user "Alice" using the sharing API
Then the OCS status code should be "404"
And the HTTP status code should be "<http_status_code>"
And as "Alice" entry "<entry_to_share>" should exist
Expand All @@ -149,7 +149,7 @@ Feature: sharing
And user "Alice" has created folder "PARENT"
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "/PARENT/parent.txt"
And user "Alice" has shared entry "<entry_to_share>" with user "Brian"
When user "Brian" deletes the last share using the sharing API
When user "Brian" deletes the last share of user "Alice" using the sharing API
Then the OCS status code should be "404"
And the HTTP status code should be "<http_status_code>"
And as "Alice" entry "<entry_to_share>" should exist
Expand All @@ -165,7 +165,7 @@ Feature: sharing
Given using OCS API version "<ocs_api_version>"
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "fileToShare.txt"
And user "Alice" has shared file "fileToShare.txt" with user "Brian"
When user "Brian" tries to delete the last share using the sharing API
When user "Brian" tries to delete the last share of user "Alice" using the sharing API
Then the OCS status code should be "<ocs_status_code>"
And the HTTP status code should be "<http_status_code>"
Examples:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ Feature: sharing
And user "Alice" has shared entry "<entry_to_share>" with group "grp1"
And user "Brian" has accepted share "<pending_entry>" offered by user "Alice"
And user "Carol" has accepted share "<pending_entry>" offered by user "Alice"
When user "Brian" deletes the last share using the sharing API
When user "Brian" deletes the last share of user "Alice" using the sharing API
Then the OCS status code should be "404"
And the HTTP status code should be "<http_status_code>"
And as "Alice" entry "<entry_to_share>" should exist
Expand Down Expand Up @@ -201,7 +201,7 @@ Feature: sharing
And user "Alice" has moved file "/textfile0.txt" to "/shared/shared_file.txt"
And user "Alice" has shared entry "<entry_to_share>" with user "Brian"
And user "Brian" has accepted share "<pending_entry>" offered by user "Alice"
When user "Brian" deletes the last share using the sharing API
When user "Brian" deletes the last share of user "Alice" using the sharing API
Then the OCS status code should be "404"
And the HTTP status code should be "<http_status_code>"
And as "Alice" entry "<entry_to_share>" should exist
Expand Down Expand Up @@ -242,7 +242,7 @@ Feature: sharing
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 "Brian" tries to delete the last share using the sharing API
When user "Brian" tries to delete the last share of user "Alice" using the sharing API
Then the OCS status code should be "<ocs_status_code>"
And the HTTP status code should be "<http_status_code>"
Examples:
Expand Down
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 @@ -541,7 +541,7 @@ Feature: create a public link share
| permissions | read |
| uid_owner | %username% |
| expiration | +7 days |
When user "Alice" gets the info of the last share using the sharing API
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>"
And the HTTP status code should be "<http_status_code>"
And the fields of the last response to user "Alice" should include
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,9 +51,9 @@ 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 share using the sharing API
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>"
And the HTTP status code should be "200"
And the fields of the last response to user "Alice" should include
Expand Down Expand Up @@ -86,7 +86,7 @@ Feature: update a public link share
And user "Alice" has created a public link share with settings
| path | FOLDER |
And user "Alice" has moved folder "/FOLDER" to "/RENAMED_FOLDER"
When user "Alice" gets the info of the last share using the sharing API
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>"
And the HTTP status code should be "200"
And the fields of the last response to user "Alice" should include
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,9 +153,9 @@ 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 share using the sharing API
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>"
And the HTTP status code should be "200"
And the fields of the last response to user "Alice" should include
Expand Down Expand Up @@ -186,9 +186,9 @@ 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 share using the sharing API
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>"
And the HTTP status code should be "200"
And the fields of the last response to user "Alice" should include
Expand Down Expand Up @@ -218,9 +218,9 @@ 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 share using the sharing API
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>"
And the HTTP status code should be "200"
And the fields of the last response to user "Alice" should include
Expand Down Expand Up @@ -250,9 +250,9 @@ 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 share using the sharing API
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>"
And the HTTP status code should be "200"
And the fields of the last response to user "Alice" should include
Expand Down Expand Up @@ -282,9 +282,9 @@ 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 share using the sharing API
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>"
And the HTTP status code should be "200"
And the fields of the last response to user "Alice" should include
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 Expand Up @@ -493,7 +493,7 @@ Feature: update a public link share
And user "Alice" has created a public link share with settings
| path | FOLDER |
And user "Alice" has moved folder "/FOLDER" to "/RENAMED_FOLDER"
When user "Alice" gets the info of the last share using the sharing API
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>"
And the HTTP status code should be "200"
And the fields of the last response to user "Alice" should include
Expand Down Expand Up @@ -539,7 +539,7 @@ Feature: update a public link share
And user "Alice" has created a public link share with settings
| path | lorem.txt |
And user "Alice" has moved file "/lorem.txt" to "/new-lorem.txt"
When user "Alice" gets the info of the last share using the sharing API
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>"
And the HTTP status code should be "200"
And the fields of the last response to user "Alice" should include
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,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 |
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 OCS status message should be ""
Expand Down
47 changes: 44 additions & 3 deletions tests/acceptance/features/bootstrap/AppConfigurationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -576,21 +576,36 @@ public function theTrustedServerListShouldBeEmpty():void {
);
}

/**
* Expires last created public link share using the testing API
*
* @return void
* @throws GuzzleException
*/
public function expireLastCreatedPublicLinkShare():void {
$shareId = $this->featureContext->getLastPublicLinkShareId();
$this->expireLastCreatedUserShare($shareId);
}

/**
* Expires last created share using the testing API
*
* @param string|null $shareId optional share id
*
* @return void
* @throws GuzzleException
*/
public function expireLastCreatedUserShare():void {
public function expireLastCreatedUserShare(string $shareId = null):void {
$adminUser = $this->featureContext->getAdminUsername();
$share_id = $this->featureContext->getLastShareId();
if ($shareId === null) {
$shareId = $this->featureContext->getLastShareId();
}
$response = OcsApiHelper::sendRequest(
$this->featureContext->getBaseUrl(),
$adminUser,
$this->featureContext->getAdminPassword(),
'POST',
"/apps/testing/api/v1/expire-share/{$share_id}",
"/apps/testing/api/v1/expire-share/{$shareId}",
$this->featureContext->getStepLineRef(),
[],
$this->featureContext->getOcsApiVersion()
Expand All @@ -613,6 +628,22 @@ public function theAdministratorHasExpiredTheLastCreatedShare():void {
);
}

/**
* @Given the administrator has expired the last created public link share using the testing API
*
* @return void
* @throws GuzzleException
*/
public function theAdministratorHasExpiredTheLastCreatedPublicLinkShare():void {
// pdd
$this->expireLastCreatedPublicLinkShare();
Assert::assertSame(
200,
$this->featureContext->getResponse()->getStatusCode(),
"Request to expire last public link share failed."
);
}

/**
* @When the administrator expires the last created share using the testing API
*
Expand All @@ -623,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
4 changes: 2 additions & 2 deletions tests/acceptance/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -3176,10 +3176,10 @@ public function substituteInLineCodes(
"parameter" => []
],
[
"code" => "%last_share_token%",
"code" => "%last_public_share_token%",
"function" => [
$this,
"getLastSharetoken"
"getLastPublicShareToken"
],
"parameter" => []
]
Expand Down
Loading

0 comments on commit 4f5c8e4

Please sign in to comment.