Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test deleting remote shares #34650

Merged
merged 1 commit into from
Mar 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions tests/acceptance/features/apiFederation/federated.feature
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,76 @@ Feature: federated
And the content of file "/PARENT (2)/textfile0.txt" for user "user1" should be "AAAAABBBBBCCCCC"
And the content of file "/PARENT/textfile0.txt" for user "user0" on server "REMOTE" should be "AAAAABBBBBCCCCC"

Scenario: Remote sharee deletes an accepted federated share
Given user "user0" from server "REMOTE" has shared "/textfile0.txt" with user "user1" from server "LOCAL"
And user "user1" from server "LOCAL" has accepted the last pending share
When user "user1" deletes the last federated cloud share using the sharing API
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And user "user1" should not see the following elements
| /textfile0%20(2).txt |
When user "user1" gets the list of federated cloud shares using the sharing API
Then the response should contain 0 entries
When user "user1" gets the list of pending federated cloud shares using the sharing API
Then the response should contain 0 entries

Scenario: Remote sharee tries to delete an accepted federated share sending wrong password
Given user "user0" from server "REMOTE" has shared "/textfile0.txt" with user "user1" from server "LOCAL"
And user "user1" from server "LOCAL" has accepted the last pending share
When user "user1" deletes the last federated cloud share with password "invalid" using the sharing API
Then the OCS status code should be "997"
And the HTTP status code should be "401"
And user "user1" should see the following elements
| /textfile0%20(2).txt |
When user "user1" gets the list of federated cloud shares using the sharing API
Then the fields of the last response should include
| id | A_NUMBER |
| remote | REMOTE |
| remote_id | A_NUMBER |
| share_token | A_TOKEN |
| name | /textfile0.txt |
| owner | user0 |
| user | user1 |
| mountpoint | /textfile0 (2).txt |
| accepted | 1 |
| type | file |
| permissions | 27 |
When user "user1" gets the list of pending federated cloud shares using the sharing API
Then the response should contain 0 entries

Scenario: Remote sharee deletes a pending federated share
Given user "user0" from server "REMOTE" has shared "/textfile0.txt" with user "user1" from server "LOCAL"
When user "user1" deletes the last pending federated cloud share using the sharing API
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And user "user1" should not see the following elements
| /textfile0%20(2).txt |
When user "user1" gets the list of federated cloud shares using the sharing API
Then the response should contain 0 entries
When user "user1" gets the list of pending federated cloud shares using the sharing API
Then the response should contain 0 entries

Scenario: Remote sharee tries to delete a pending federated share sending wrong password
Given user "user0" from server "REMOTE" has shared "/textfile0.txt" with user "user1" from server "LOCAL"
When user "user1" deletes the last pending federated cloud share with password "invalid" using the sharing API
Then the OCS status code should be "997"
And the HTTP status code should be "401"
And user "user1" should not see the following elements
| /textfile0%20(2).txt |
When user "user1" gets the list of pending federated cloud shares using the sharing API
Then the fields of the last response should include
| id | A_NUMBER |
| remote | REMOTE |
| remote_id | A_NUMBER |
| share_token | A_TOKEN |
| name | /textfile0.txt |
| owner | user0 |
| user | user1 |
| mountpoint | {{TemporaryMountPointName#/textfile0.txt}} |
| accepted | 0 |
When user "user1" gets the list of federated cloud shares using the sharing API
Then the response should contain 0 entries

Scenario: Trusted server handshake does not require authenticated requests - we force 403 by sending an empty body
Given using server "LOCAL"
And using OCS API version "2"
Expand Down
55 changes: 49 additions & 6 deletions tests/acceptance/features/bootstrap/FederationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,7 @@ public function userFromServerHasAcceptedLastPendingShare($user, $server) {
* @return void
*/
public function userRetrievesInformationOfLastFederatedShare($user) {
$this->featureContext->userSendsHTTPMethodToOcsApiEndpointWithBody(
$user,
'GET',
"/apps/files_sharing/api/v1/remote_shares",
null
);
$this->userGetsTheListOfFederatedCloudShares($user);
$this->featureContext->theHTTPStatusCodeShouldBe('200');
$this->featureContext->theOCSStatusCodeShouldBe('100');
$share_id = SharingHelper::getLastShareIdFromResponse(
Expand Down Expand Up @@ -199,6 +194,54 @@ public function userGetsTheListOfPendingFederatedCloudShares($user) {
);
}

/**
* @When /^user "([^"]*)" gets the list of federated cloud shares using the sharing API$/
*
* @param string $user
*
* @return void
*/
public function userGetsTheListOfFederatedCloudShares($user) {
$this->featureContext->userSendsHTTPMethodToOcsApiEndpointWithBody(
$user, 'GET', "/apps/files_sharing/api/v1/remote_shares"
);
}

/**
*
* @When /^user "([^"]*)" deletes the last (pending|)\s?federated cloud share using the sharing API$/
* @When /^user "([^"]*)" deletes the last (pending|)\s?federated cloud share with password "([^"]*)" using the sharing API$/
*
* @param string $user
* @param string $shareType "pending" or empty string
* @param string $password
*
* @return void
*/
public function userDeletesLastFederatedCloudShare(
$user, $shareType, $password = null
) {
if ($shareType === "pending") {
$this->userGetsTheListOfPendingFederatedCloudShares($user);
} else {
$this->userGetsTheListOfFederatedCloudShares($user);
}
$this->featureContext->theHTTPStatusCodeShouldBe('200');
$this->featureContext->theOCSStatusCodeShouldBe('100');
$share_id = SharingHelper::getLastShareIdFromResponse(
$this->featureContext->getResponseXml()
);
if ($shareType === "pending") {
$url = "/apps/files_sharing/api/v1/remote_shares/pending/$share_id";
} else {
$url = "/apps/files_sharing/api/v1/remote_shares/$share_id";
}

$this->featureContext->userSendsHTTPMethodToOcsApiEndpointWithBody(
$user, 'DELETE', $url, null, $password
);
}

/**
* @When /^user "([^"]*)" requests shared secret using the federation API$/
*
Expand Down