Skip to content

Commit

Permalink
Merge pull request #35944 from owncloud/stable10-edit-existing-group-…
Browse files Browse the repository at this point in the history
…share-permissions

[stable10] acceptance test for attempt to modify group share permissions when group sharing is off
  • Loading branch information
phil-davis authored Jul 30, 2019
2 parents eca2e63 + bf63318 commit bd3df85
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 35 deletions.
4 changes: 2 additions & 2 deletions tests/acceptance/features/bootstrap/WebUIFilesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ public function theUserTriesToBrowseDirectlyToDetailsTabOfFileInFolder(
}

/**
* @Given the user has browsed directly to display the details of file :fileName in folder :folderName
* @When the user browses directly to display the details of file :fileName in folder :folderName
* @Given the user has browsed directly to display the details of file/folder :fileName in folder :folderName
* @When the user browses directly to display the details of file/folder :fileName in folder :folderName
*
* @param string $fileName
* @param string $folderName
Expand Down
57 changes: 46 additions & 11 deletions tests/acceptance/features/bootstrap/WebUISharingContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,37 @@ public function theUserOpensTheShareDialogForFileFolder($name) {
);
}

/**
* @Then /^group ((?:'[^']*')|(?:"[^"]*")) should (not|)\s?be listed in the shared with list$/
*
* @param string $groupName
* @param string $shouldOrNot
*
* @return void
* @throws \Exception
*/
public function shouldBeListedInTheSharedWithList(
$groupName,
$shouldOrNot
) {
$should = ($shouldOrNot !== "not");
// The capturing groups of the regex include the quotes at each
// end of the captured string, so trim them.
$groupName = \trim($groupName, '""');
$presence = $this->sharingDialog->isGroupPresentInShareWithList($groupName);
if ($should) {
PHPUnit\Framework\Assert::assertTrue(
$presence,
"group $groupName is not listed in share with list"
);
} else {
PHPUnit\Framework\Assert::assertFalse(
$presence,
"group $groupName is listed in share with list"
);
}
}

/**
* @Given the user has opened the public link share tab
* @When the user opens the public link share tab
Expand Down Expand Up @@ -566,9 +597,10 @@ public function theUserTypesInTheShareWithField($input) {
}

/**
* @When the user sets the sharing permissions of :userName for :fileName using the webUI to
* @Given the user has set the sharing permissions of :userName for :fileName using the webUI to
* @When /^the user sets the sharing permissions of (user|group) ((?:[^']*)|(?:[^"]*)) for ((?:'[^']*')|(?:"[^"]*")) using the webUI to$/
* @Given /^the user has set the sharing permissions of (user|group) ((?:'[^']*')|(?:"[^"]*")) for ((?:'[^']*')|(?:"[^"]*")) using the webUI to$/
*
* @param string $userOrGroup
* @param string $userName
* @param string $fileName
* @param TableNode $permissionsTable table with two columns and no heading
Expand All @@ -582,19 +614,22 @@ public function theUserTypesInTheShareWithField($input) {
* @throws \Exception
*/
public function theUserSetsTheSharingPermissionsOfForOnTheWebUI(
$userName, $fileName, TableNode $permissionsTable
$userOrGroup, $userName, $fileName, TableNode $permissionsTable
) {
$userName = $this->featureContext->substituteInLineCodes($userName);
$this->theUserOpensTheShareDialogForFileFolder($fileName);
// The capturing groups of the regex include the quotes at each
// end of the captured string, so trim them.
$userName = $this->featureContext->substituteInLineCodes(\trim($userName, '""'));
$this->theUserOpensTheShareDialogForFileFolder(\trim($fileName, '""'));
$this->sharingDialog->setSharingPermissions(
$userName, $permissionsTable->getRowsHash(), $this->getSession()
$userOrGroup, $userName, $permissionsTable->getRowsHash(), $this->getSession()
);
}

/**
* @Then the following permissions are seen for :fileName in the sharing dialog for user :userName
* @Then /^the following permissions are seen for ((?:[^']*)|(?:[^"]*)) in the sharing dialog for (user|group) ((?:[^']*)|(?:[^"]*))$/
*
* @param string $fileName
* @param string $userOrGroup
* @param string $userName
* @param TableNode $permissionsTable table with two columns and no heading
* first column one of the permissions
Expand All @@ -607,12 +642,12 @@ public function theUserSetsTheSharingPermissionsOfForOnTheWebUI(
* @throws \Exception
*/
public function theFollowingPermissionsAreSeenForInTheSharingDialogFor(
$fileName, $userName, TableNode $permissionsTable
$fileName, $userOrGroup, $userName, TableNode $permissionsTable
) {
$userName = $this->featureContext->substituteInLineCodes($userName);
$this->theUserOpensTheShareDialogForFileFolder($fileName);
$userName = $this->featureContext->substituteInLineCodes(\trim($userName, '""'));
$this->theUserOpensTheShareDialogForFileFolder(\trim($fileName, '""'));
$this->sharingDialog->checkSharingPermissions(
$userName, $permissionsTable->getRowsHash(), $this->getSession()
$userOrGroup, $userName, $permissionsTable->getRowsHash(), $this->getSession()
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/features/lib/FilesPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function getFileNameMatchXpath() {
protected function getEmptyContentXpath() {
return $this->emptyContentXpath;
}

/**
* {@inheritDoc}
*
Expand Down
33 changes: 24 additions & 9 deletions tests/acceptance/features/lib/FilesPageElement/SharingDialog.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class SharingDialog extends OwncloudPage {
private $sharerInformationXpath = ".//*[@class='reshare']";
private $sharedWithAndByRegEx = "^(?:[A-Z]\s)?Shared with you(?: and the group (.*))? by (.*)$";
private $permissionsFieldByUserName = ".//*[@id='shareWithList']//*[@class='has-tooltip username' and .='%s']/..";
private $permissionsFieldByGroupName = ".//*[@id='shareWithList']//*[@class='has-tooltip username' and .='%s (group)']/..";
private $permissionLabelXpath = ".//label[@for='%s']";
private $showCrudsXpath = ".//*[@class='showCruds']";
private $publicLinksShareTabXpath = ".//li[contains(@class,'subtab-publicshare')]";
Expand Down Expand Up @@ -323,6 +324,7 @@ public function shareWithGroup(

/**
*
* @param string $userOrGroup
* @param string $shareReceiverName
* @param array $permissions [['permission' => 'yes|no']]
* @param Session $session
Expand All @@ -331,13 +333,20 @@ public function shareWithGroup(
* @return void
*/
public function setSharingPermissions(
$userOrGroup,
$shareReceiverName,
$permissions,
Session $session
) {
$xpathLocator = \sprintf(
$this->permissionsFieldByUserName, $shareReceiverName
);
if ($userOrGroup == "group") {
$xpathLocator = \sprintf(
$this->permissionsFieldByGroupName, $shareReceiverName
);
} else {
$xpathLocator = \sprintf(
$this->permissionsFieldByUserName, $shareReceiverName
);
}
$permissionsField = $this->waitTillElementIsNotNull($xpathLocator);
$this->assertElementNotNull(
$permissionsField,
Expand Down Expand Up @@ -410,6 +419,7 @@ public function setSharingPermissions(

/**
*
* @param string $userOrGroup
* @param string $shareReceiverName
* @param array $permissions [['permission' => 'yes|no']]
* @param Session $session
Expand All @@ -418,13 +428,20 @@ public function setSharingPermissions(
* @return void
*/
public function checkSharingPermissions(
$userOrGroup,
$shareReceiverName,
$permissions,
Session $session
) {
$xpathLocator = \sprintf(
$this->permissionsFieldByUserName, $shareReceiverName
);
if ($userOrGroup == "group") {
$xpathLocator = \sprintf(
$this->permissionsFieldByGroupName, $shareReceiverName
);
} else {
$xpathLocator = \sprintf(
$this->permissionsFieldByUserName, $shareReceiverName
);
}
$permissionsField = $this->waitTillElementIsNotNull($xpathLocator);
$this->assertElementNotNull(
$permissionsField,
Expand Down Expand Up @@ -718,9 +735,7 @@ public function isGroupPresentInShareWithList($groupName) {
$shareWithList = $this->getShareWithList();
foreach ($shareWithList as $group) {
$actualGroupName = $group->find('xpath', $this->userOrGroupNameSpanXpath);
if ($actualGroupName->getHtml() === \sprintf($this->groupFramework, $groupName)) {
return true;
}
return $actualGroupName->getHtml() === \sprintf($this->groupFramework, $groupName);
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Feature: restrict resharing
Given the setting "Allow resharing" in the section "Sharing" has been enabled
And the user has browsed to the files page
When the user shares folder "simple-folder" with user "User One" using the webUI
And the user sets the sharing permissions of "User One" for "simple-folder" using the webUI to
And the user sets the sharing permissions of user "User One" for "simple-folder" using the webUI to
| share | no |
And the user re-logs in as "user1" using the webUI
Then it should not be possible to share folder "simple-folder (2)" using the webUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,39 @@ Feature: restrict Sharing
When the user shares folder "simple-folder" with user "User One" using the webUI
And the user re-logs in as "user1" using the webUI
Then folder "simple-folder (2)" should be listed on the webUI

Scenario: Editing share permission of existing share when sharing with groups is forbidden
Given the user has shared folder "simple-folder" with group "grp1"
And the setting "Allow sharing with groups" in the section "Sharing" has been disabled
When the user opens the share dialog for folder "simple-folder"
Then group "grp1" should be listed in the shared with list
When the user sets the sharing permissions of group "grp1" for "simple-folder" using the webUI to
| share | no |
Then dialog should be displayed on the webUI
| title | content |
| Error while sharing |Group sharing is not allowed |
When the user reloads the current page of the webUI
Then the following permissions are seen for "simple-folder" in the sharing dialog for group "grp1"
| share | yes |

Scenario: Editing create permission of existing share when sharing with groups is forbidden
Given the user has shared folder "simple-folder" with group "grp1"
And the setting "Allow sharing with groups" in the section "Sharing" has been disabled
When the user opens the share dialog for folder "simple-folder"
Then group "grp1" should be listed in the shared with list
When the user sets the sharing permissions of group "grp1" for "simple-folder" using the webUI to
| create | no |
Then dialog should be displayed on the webUI
| title | content |
| Error while sharing |Group sharing is not allowed |
When the user reloads the current page of the webUI
Then the following permissions are seen for "simple-folder" in the sharing dialog for group "grp1"
| create | yes |

Scenario: Deleting group share when sharing with groups is forbidden
Given the user has shared folder "simple-folder" with group "grp1"
And the setting "Allow sharing with groups" in the section "Sharing" has been disabled
When the user opens the share dialog for folder "simple-folder"
Then group "grp1" should be listed in the shared with list
When the user deletes share with user "grp1 (group)" for the current file
Then group "grp1" should not be listed in the shared with list
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Feature: Federation Sharing - sharing with users on other cloud storages
@skipOnMICROSOFTEDGE
Scenario: share a folder with an remote user and prohibit deleting - local server shares - remote server receives
When the user shares folder "simple-folder" with remote user "user1@%remote_server_without_scheme%" using the webUI
And the user sets the sharing permissions of "user1@%remote_server_without_scheme% (federated)" for "simple-folder" using the webUI to
And the user sets the sharing permissions of user "user1@%remote_server_without_scheme% (federated)" for "simple-folder" using the webUI to
| delete | no |
And user "user1" re-logs in to "%remote_server%" using the webUI
And the user accepts the offered remote shares using the webUI
Expand Down Expand Up @@ -278,7 +278,7 @@ Feature: Federation Sharing - sharing with users on other cloud storages
And user "user1" re-logs in to "%remote_server%" using the webUI
And the user accepts the offered remote shares using the webUI
And user "user1" from server "REMOTE" shares "/simple-folder (2)" with user "user2" from server "LOCAL" using the sharing API
And the user sets the sharing permissions of "user2@%local_server%/ (federated)" for "simple-folder (2)" using the webUI to
And the user sets the sharing permissions of user "user2@%local_server%/ (federated)" for "simple-folder (2)" using the webUI to
| edit | no |
And user "user2" re-logs in to "%local_server%" using the webUI
And the user accepts the offered remote shares using the webUI
Expand All @@ -297,7 +297,7 @@ Feature: Federation Sharing - sharing with users on other cloud storages
And user "user1" from server "REMOTE" shares "/simple-folder (2)" with user "user2" from server "LOCAL" using the sharing API
And user "user1" re-logs in to "%local_server%" using the webUI
And the user opens the share dialog for folder "simple-folder"
And the user sets the sharing permissions of "user2@%local_server% (federated)" for "simple-folder" using the webUI to
And the user sets the sharing permissions of user "user2@%local_server% (federated)" for "simple-folder" using the webUI to
| edit | no |
And user "user2" re-logs in to "%local_server%" using the webUI
And the user accepts the offered remote shares using the webUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Feature: Sharing files and folders with internal users
| user2 |
And user "user2" has logged in using the webUI
When the user shares folder "simple-folder" with user "User One" using the webUI
And the user sets the sharing permissions of "User One" for "simple-folder" using the webUI to
And the user sets the sharing permissions of user "User One" for "simple-folder" using the webUI to
| delete | no |
And the user re-logs in as "user1" using the webUI
And the user opens folder "simple-folder (2)" using the webUI
Expand Down Expand Up @@ -431,7 +431,7 @@ Feature: Sharing files and folders with internal users
And user "user2" has uploaded file "filesForUpload/lorem.txt" to "simple-folder/lorem.txt"
And user "user2" has logged in using the webUI
When the user shares folder "simple-folder" with user "User One" using the webUI
And the user sets the sharing permissions of "User One" for "simple-folder" using the webUI to
And the user sets the sharing permissions of user "User One" for "simple-folder" using the webUI to
| edit | no |
And the user re-logs in as "user1" using the webUI
And the user opens folder "simple-folder" using the webUI
Expand All @@ -455,7 +455,7 @@ Feature: Sharing files and folders with internal users
And user "user2" has uploaded file "filesForUpload/lorem.txt" to "simple-folder/lorem.txt"
And user "user2" has logged in using the webUI
When the user shares folder "simple-folder" with user "User One" using the webUI
And the user sets the sharing permissions of "User One" for "simple-folder" using the webUI to
And the user sets the sharing permissions of user "User One" for "simple-folder" using the webUI to
| change | no |
| delete | no |
And the user re-logs in as "user1" using the webUI
Expand All @@ -475,7 +475,7 @@ Feature: Sharing files and folders with internal users
And user "user2" has uploaded file "filesForUpload/lorem.txt" to "simple-folder/lorem.txt"
And user "user2" has logged in using the webUI
When the user shares folder "simple-folder" with user "User One" using the webUI
And the user sets the sharing permissions of "User One" for "simple-folder" using the webUI to
And the user sets the sharing permissions of user "User One" for "simple-folder" using the webUI to
| create | no |
| delete | no |
And the user re-logs in as "user1" using the webUI
Expand All @@ -495,7 +495,7 @@ Feature: Sharing files and folders with internal users
And user "user2" has uploaded file "filesForUpload/lorem.txt" to "simple-folder/lorem.txt"
And user "user2" has logged in using the webUI
When the user shares folder "simple-folder" with user "User One" using the webUI
And the user sets the sharing permissions of "User One" for "simple-folder" using the webUI to
And the user sets the sharing permissions of user "User One" for "simple-folder" using the webUI to
| change | no |
| create | no |
And the user re-logs in as "user1" using the webUI
Expand All @@ -515,7 +515,7 @@ Feature: Sharing files and folders with internal users
And user "user2" has uploaded file "filesForUpload/lorem.txt" to "simple-folder/lorem.txt"
And user "user2" has logged in using the webUI
When the user shares folder "simple-folder" with user "User One" using the webUI
And the user sets the sharing permissions of "User One" for "simple-folder" using the webUI to
And the user sets the sharing permissions of user "User One" for "simple-folder" using the webUI to
| share | no |
And the user re-logs in as "user1" using the webUI
And the user opens folder "simple-folder" using the webUI
Expand Down Expand Up @@ -628,7 +628,7 @@ Feature: Sharing files and folders with internal users
When the administrator disables permission delete for default user and group share using the webUI
And the user re-logs in as "user2" using the webUI
And the user shares folder "simple-folder" with user "User One" using the webUI
And the user sets the sharing permissions of "User One" for "simple-folder" using the webUI to
And the user sets the sharing permissions of user "User One" for "simple-folder" using the webUI to
| delete | yes |
And the user re-logs in as "user1" using the webUI
And the user opens folder "simple-folder" using the webUI
Expand All @@ -650,7 +650,7 @@ Feature: Sharing files and folders with internal users
And the administrator disables permission share for default user and group share using the webUI
And the user re-logs in as "user2" using the webUI
And the user shares folder "simple-folder" with user "User One" using the webUI
And the user sets the sharing permissions of "User One" for "simple-folder" using the webUI to
And the user sets the sharing permissions of user "User One" for "simple-folder" using the webUI to
| share | yes |
And the user re-logs in as "user1" using the webUI
And the user opens folder "simple-folder" using the webUI
Expand Down

0 comments on commit bd3df85

Please sign in to comment.