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

API test for disableSharing #31674

Merged
merged 1 commit into from
Jun 7, 2018
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
69 changes: 69 additions & 0 deletions tests/acceptance/features/apiSharing-v1/disableSharing.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
@api
Feature: sharing
As an admin
I want to be able to disable sharing functionality
So that ownCloud users cannot share file or folder

Background:
Given using API version "1"
And using old DAV path

Scenario: user tries to share a file with another user when the sharing api has been disabled
Given as user "admin"
And user "user0" has been created
And user "user1" has been created
And as user "admin"
When parameter "shareapi_enabled" of app "core" has been set to "no"
Then user "user0" should not be able to share file "welcome.txt" with user "user1" using the API
And the OCS status code should be "404"
And the HTTP status code should be "200"

Scenario: user tries to share a folder with another user when the sharing api has been disabled
Given as user "admin"
And user "user0" has been created
And user "user1" has been created
And as user "admin"
When parameter "shareapi_enabled" of app "core" has been set to "no"
Then user "user0" should not be able to share folder "/FOLDER" with user "user1" using the API
And the OCS status code should be "404"
And the HTTP status code should be "200"

Scenario: user tries to share a file with group when the sharing api has been disabled
Given as user "admin"
And user "user0" has been created
And user "user1" has been created
And group "sharinggroup" has been created
And user "user1" has been added to group "sharinggroup"
And as user "admin"
When parameter "shareapi_enabled" of app "core" has been set to "no"
Then user "user0" should not be able to share file "welcome.txt" with group "sharinggroup" using the API
And the OCS status code should be "404"
And the HTTP status code should be "200"

Scenario: user tries to share a folder with group when the sharing api has been disabled
Given as user "admin"
And user "user0" has been created
And user "user1" has been created
And group "sharinggroup" has been created
And user "user1" has been added to group "sharinggroup"
And as user "admin"
When parameter "shareapi_enabled" of app "core" has been set to "no"
Then user "user0" should not be able to share folder "/FOLDER" with group "sharinggroup" using the API
And the OCS status code should be "404"
And the HTTP status code should be "200"

Scenario: user tries to create public share of a file when the sharing api has been disabled
Given user "user0" has been created
And as user "admin"
When parameter "shareapi_enabled" of app "core" has been set to "no"
Then user "user0" should not be able to create public share of file "welcome.txt" using the API
Then the OCS status code should be "404"
And the HTTP status code should be "200"

Scenario: user tries to create public share of a folder when the sharing api has been disabled
Given user "user0" has been created
And as user "admin"
When parameter "shareapi_enabled" of app "core" has been set to "no"
Then user "user0" should not be able to create public share of folder "/FOLDER" using the API
Then the OCS status code should be "404"
And the HTTP status code should be "200"
45 changes: 45 additions & 0 deletions tests/acceptance/features/bootstrap/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,22 @@ public function publiclyUploadingContentAutorename($filename, $body = 'test') {
$this->publicUploadContent($filename, '', $body, true);
}

/**
* @Then /^user "([^"]*)" should not be able to create public share of (?:file|folder) "([^"]*)" using the API$/
*
* @param string $sharer
* @param string $filepath
*
* @return void
*/
public function shouldNotBeAbleToCreatePublicShare($sharer, $filepath) {
$this->createAPublicShare($sharer, $filepath);
PHPUnit_Framework_Assert::assertEquals(
404,
$this->getOCSResponseStatusCode($this->response)
);
}

/**
* @Then publicly uploading a file should not work
*
Expand Down Expand Up @@ -847,6 +863,35 @@ public function userSharesFileWithGroupUsingTheAPI(
);
}

/**
* @Then /^user "([^"]*)" should not be able to share (?:file|folder|entry) "([^"]*)" with (?:user|group) "([^"]*)"(?: with permissions ([\d]*))? using the API$/
*
* @param string $sharer
* @param string $filepath
* @param string $sharee
* @param int $permissions
*
* @return void
*/
public function userTriesToShareFileWithUserUsingTheApi($sharer, $filepath, $sharee, $permissions = null) {
$time = \time();
if ($this->lastShareTime !== null && $time - $this->lastShareTime < 1) {
// prevent creating two shares with the same "stime" which is
// based on seconds, this affects share merging order and could
// affect expected test result order
\sleep(1);
}
$this->lastShareTime = $time;
$this->createShare(
$sharer, $filepath, 0, $sharee, null, null, $permissions
);
$responseMessage = \json_decode(\json_encode($this->response->xml()->meta->message), 1);
PHPUnit_Framework_Assert::assertEquals(
404,
$this->getOCSResponseStatusCode($this->response)
);
}

/**
* @When /^the user deletes the last share using the API$/
* @Given /^the user has deleted the last share$/
Expand Down