Skip to content

Commit

Permalink
API test for disableSharing
Browse files Browse the repository at this point in the history
  • Loading branch information
paurakhsharma committed Jun 7, 2018
1 parent 031fded commit 6fad514
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/acceptance/features/apiSharing-v1/disableSharing.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
@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"
29 changes: 29 additions & 0 deletions tests/acceptance/features/bootstrap/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,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

0 comments on commit 6fad514

Please sign in to comment.