Skip to content

Commit

Permalink
Add tests for to check reshare behaviour inside blacklisted from shar…
Browse files Browse the repository at this point in the history
…ing group
  • Loading branch information
paurakhsharma committed Dec 14, 2018
1 parent 98d8d44 commit 034104d
Show file tree
Hide file tree
Showing 7 changed files with 178 additions and 16 deletions.
1 change: 1 addition & 0 deletions tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ default:
- WebUIGeneralContext:
- WebUILoginContext:
- WebUISharingContext:
- WebUIAdminSharingSettingsContext:

webUISharingNotifications:
paths:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ public function theAdminRestrictsUsersToOnlyShareWithTheirGroupMemberUsingTheWeb

/**
* @When the administrator enables exclude groups from sharing using the webUI
* @Given the administrator has enabled exclude groups from sharing from admin sharing settings page
*
* @return void
*/
Expand All @@ -221,6 +222,7 @@ public function theAdministratorEnablesExcludeGroupsFromSharingUsingTheWebui() {

/**
* @When the administrator adds group :group to the group sharing blacklist using the webUI
* @Given the administrator has added group :group to the group sharing blacklist from the admin sharing settings page
*
* @param string $group
*
Expand Down
28 changes: 28 additions & 0 deletions tests/acceptance/features/bootstrap/WebUIFilesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,20 @@ public function theShareWithFieldShouldBeVisibleInTheDetailsPanel() {
);
}

/**
* @Then the share-with field should not be visible in the details panel
*
* @return void
* @throws Exception
*/
public function theShareWithFieldShouldNotBeVisibleInTheDetailsPanel() {
$sharingDialog = $this->filesPage->getSharingDialog();
PHPUnit_Framework_Assert::assertFalse(
$sharingDialog->isShareWithFieldVisible(),
'the share-with field is visible in the details panel'
);
}

/**
* @When the user browses to the trashbin page
* @Given the user has browsed to the trashbin page
Expand Down Expand Up @@ -1031,6 +1045,20 @@ public function theDeletedMovedElementsShouldBeListedOnTheWebUIAfterPageReload(
$this->theDeletedMovedElementsShouldBeListedOnTheWebUI($shouldOrNot);
}

/**
* @When the user opens sharing tab from file action menu of file/folder :entryName using the webUI
*
* @param string $entryName
*
* @return void
*/
public function theUserOpensSharingTabFromDetailsDialogOfFileUsingTheWebui($entryName) {
$this->theUserOpensTheFileActionMenuOfFileFolderInTheWebui($entryName);
$this->theUserClicksTheFileActionInTheWebui("details");
$this->theUserSwitchesToTabInDetailsPanelUsingTheWebui("sharing");
$this->filesPage->waitForAjaxCallsToStartAndFinish($this->getSession());
}

/**
* @Then the deleted elements should be listed in the trashbin on the webUI
*
Expand Down
15 changes: 15 additions & 0 deletions tests/acceptance/features/bootstrap/WebUISharingContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,21 @@ public function theEmailAddressShouldHaveReceivedAnEmailContainingSharedPublicLi
PHPUnit_Framework_Assert::assertContains($lastCreatedPublicLink["url"], $content);
}

/**
* @Then the user should see a error message on the share dialog saying :message
*
* @param string $message
*
* @return void
*/
public function theUserShouldSeeAErrorMessageOnTheShareDialogSaying($message) {
$sharingDialog = $this->filesPage->getSharingDialog();
$actualMessage = $sharingDialog->noSharingMessageXpath(
$this->getSession()
);
PHPUnit_Framework_Assert::assertEquals($message, $actualMessage);
}

/**
* This will run before EVERY scenario.
* It will set the properties for this object.
Expand Down
19 changes: 19 additions & 0 deletions tests/acceptance/features/lib/FilesPageElement/SharingDialog.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class SharingDialog extends OwncloudPage {
private $showCrudsXpath = ".//*[@class='showCruds']";
private $publicLinksShareTabXpath = ".//li[contains(@class,'subtab-publicshare')]";
private $publicLinksTabContentXpath = "//div[@id='shareDialogLinkList']";
private $noSharingMessageXpath = "//div[@class='noSharingPlaceholder']";

private $sharedWithGroupAndSharerName = null;

Expand Down Expand Up @@ -104,6 +105,24 @@ public function fillShareWithField(
return $this->getAutocompleteNodeElement();
}

/**
* get no sharing message
*
* @param Session $session
*
* @return string
*/
public function noSharingMessageXpath(Session $session) {
$noSharingMessage = $this->find("xpath", $this->noSharingMessageXpath);
$this->assertElementNotNull(
$noSharingMessage,
__METHOD__ .
" xpath $this->noSharingMessageXpath " .
"could not find no sharing message"
);
return $this->getTrimmedText($noSharingMessage);
}

/**
* gets the NodeElement of the autocomplete list
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,6 @@ Feature: Sharing files and folders with internal groups
Then file "lorem.txt" should be listed on the webUI
And the content of "lorem.txt" should be the same as the original "simple-folder/lorem.txt"

Scenario: user tries to share a file in a group which is blacklisted from sharing
Given the administrator has browsed to the admin sharing settings page
When the administrator enables exclude groups from sharing using the webUI
And the administrator adds group "grp1" to the group sharing blacklist using the webUI
Then user "user1" should not be able to share file "lorem.txt" with user "user3" using the sharing API

Scenario: user tries to share a folder in a group which is blacklisted from sharing
Given the administrator has browsed to the admin sharing settings page
When the administrator enables exclude groups from sharing using the webUI
And the administrator adds group "grp1" to the group sharing blacklist using the webUI
Then user "user1" should not be able to share folder "simple-folder" with user "user3" using the sharing API

Scenario: user tries to share a file in a group which is excluded from receiving share
Given group "system-group" has been created
And the administrator has browsed to the admin sharing settings page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ Feature: Sharing files and folders with internal users
| username |
| user1 |
| user2 |
And user "user2" has logged in using the webUI

@TestAlsoOnExternalUserBackend
@smokeTest
Scenario: share a file & folder with another internal user
Given 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 shares file "testimage.jpg" with user "User One" using the webUI
And the user re-logs in as "user1" using the webUI
Expand All @@ -27,6 +27,7 @@ Feature: Sharing files and folders with internal users

@TestAlsoOnExternalUserBackend
Scenario: share a file with another internal user who overwrites and unshares the file
Given user "user2" has logged in using the webUI
When the user renames file "lorem.txt" to "new-lorem.txt" using the webUI
And the user shares file "new-lorem.txt" with user "User One" using the webUI
And the user re-logs in as "user1" using the webUI
Expand All @@ -44,6 +45,7 @@ Feature: Sharing files and folders with internal users

@TestAlsoOnExternalUserBackend
Scenario: share a folder with another internal user who uploads, overwrites and deletes files
Given user "user2" has logged in using the webUI
When the user renames folder "simple-folder" to "new-simple-folder" using the webUI
And the user shares folder "new-simple-folder" with user "User One" using the webUI
And the user re-logs in as "user1" using the webUI
Expand All @@ -70,6 +72,7 @@ Feature: Sharing files and folders with internal users

@TestAlsoOnExternalUserBackend
Scenario: share a folder with another internal user who unshares the folder
Given user "user2" has logged in using the webUI
When the user renames folder "simple-folder" to "new-simple-folder" using the webUI
And the user shares folder "new-simple-folder" with user "User One" using the webUI
# unshare the received shared folder and check it is gone
Expand All @@ -85,6 +88,7 @@ Feature: Sharing files and folders with internal users

@skipOnMICROSOFTEDGE @TestAlsoOnExternalUserBackend
Scenario: share a folder with another internal user and prohibit deleting
Given 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
| delete | no |
Expand All @@ -93,7 +97,8 @@ Feature: Sharing files and folders with internal users
Then it should not be possible to delete file "lorem.txt" using the webUI

Scenario: share a folder with other user and then it should be listed on Shared with You for other user
Given the user has renamed folder "simple-folder" to "new-simple-folder" using the webUI
Given user "user2" has logged in using the webUI
And the user has renamed folder "simple-folder" to "new-simple-folder" using the webUI
And the user has renamed file "lorem.txt" to "ipsum.txt" using the webUI
And the user has shared file "ipsum.txt" with user "User One" using the webUI
And the user has shared folder "new-simple-folder" with user "User One" using the webUI
Expand All @@ -103,16 +108,120 @@ Feature: Sharing files and folders with internal users
And folder "new-simple-folder" should be listed on the webUI

Scenario: share a folder with other user and then it should be listed on Shared with Others page
Given the user has shared file "lorem.txt" with user "User One" using the webUI
Given user "user2" has logged in using the webUI
And the user has shared file "lorem.txt" with user "User One" using the webUI
And the user has shared folder "simple-folder" with user "User One" using the webUI
When the user browses to the shared-with-others page
Then file "lorem.txt" should be listed on the webUI
And folder "simple-folder" should be listed on the webUI

Scenario: share two file with same name but different paths
Given the user has shared file "lorem.txt" with user "User One" using the webUI
Given user "user2" has logged in using the webUI
And the user has shared file "lorem.txt" with user "User One" using the webUI
When the user opens folder "simple-folder" using the webUI
And the user shares file "lorem.txt" with user "User One" using the webUI
And the user browses to the shared-with-others page
Then file "lorem.txt" with path "" should be listed in the shared with others page on the webUI
And file "lorem.txt" with path "/simple-folder" should be listed in the shared with others page on the webUI

Scenario: user tries to share a file from a group which is blacklisted from sharing
Given group "grp1" has been created
And user "user1" has been added to group "grp1"
And user "user3" has been created with default attributes
And the administrator has browsed to the admin sharing settings page
When the administrator enables exclude groups from sharing using the webUI
And the administrator adds group "grp1" to the group sharing blacklist using the webUI
Then user "user1" should not be able to share file "testimage.jpg" with user "user3" using the sharing API

Scenario: user tries to share a folder from a group which is blacklisted from sharing
Given group "grp1" has been created
And user "user1" has been added to group "grp1"
And user "user3" has been created with default attributes
And the administrator has browsed to the admin sharing settings page
When the administrator enables exclude groups from sharing using the webUI
And the administrator adds group "grp1" to the group sharing blacklist using the webUI
Then user "user1" should not be able to share folder "simple-folder" with user "User Three" using the sharing API

Scenario: member of a blacklisted from sharing group tries to re-share a file received as a share
Given these users have been created with default attributes:
| username |
| user3 |
| user4 |
And group "grp1" has been created
And user "user1" has been added to group "grp1"
And the administrator has browsed to the admin sharing settings page
And user "user3" has shared file "/testimage.jpg" with user "user1"
And the administrator has enabled exclude groups from sharing from admin sharing settings page
When the administrator adds group "grp1" to the group sharing blacklist using the webUI
Then user "user1" should not be able to share file "/testimage (2).jpg" with user "User Four" using the sharing API

Scenario: member of a blacklisted from sharing group tries to re-share a folder received as a share
Given these users have been created with default attributes:
| username |
| user3 |
| user4 |
And group "grp1" has been created
And user "user1" has been added to group "grp1"
And user "user3" has been created with default attributes
And the administrator has browsed to the admin sharing settings page
And user "user3" has created folder "/common"
And user "user3" has shared folder "/common" with user "user1"
And the administrator has enabled exclude groups from sharing from admin sharing settings page
When the administrator adds group "grp1" to the group sharing blacklist using the webUI
Then user "user1" should not be able to share folder "/common" with user "User Four" using the sharing API

Scenario: member of a blacklisted from sharing group tries to re-share a file inside a folder received as a share
Given these users have been created with default attributes:
| username |
| user3 |
| user4 |
And group "grp1" has been created
And user "user1" has been added to group "grp1"
And the administrator has browsed to the admin sharing settings page
And user "user3" has created folder "/common"
And user "user3" has moved file "/testimage.jpg" to "/common/testimage.jpg"
And user "user3" has shared folder "/common" with user "user1"
And the administrator has enabled exclude groups from sharing from admin sharing settings page
When the administrator adds group "grp1" to the group sharing blacklist using the webUI
Then user "user1" should not be able to share file "/common/testimage.jpg" with user "User Four" using the sharing API

Scenario: member of a blacklisted from sharing group tries to re-share a folder inside a folder received as a share
Given these users have been created with default attributes:
| username |
| user3 |
| user4 |
And the administrator has browsed to the admin sharing settings page
And user "user3" has created folder "/common"
And user "user3" has created folder "/common/inside-common"
And user "user3" has shared folder "/common" with user "user1"
And the administrator has enabled exclude groups from sharing from admin sharing settings page
When the administrator adds group "grp1" to the group sharing blacklist using the webUI
Then user "user1" should not be able to share folder "/common/inside-common" with user "User Four" using the sharing API

Scenario: user tries to share a file from a group which is blacklisted from sharing using webUI from files page
Given group "grp1" has been created
And user "user1" has been added to group "grp1"
And user "user3" has been created with default attributes
And the administrator has browsed to the admin sharing settings page
And the administrator has enabled exclude groups from sharing from admin sharing settings page
When the administrator adds group "grp1" to the group sharing blacklist using the webUI
And the user re-logs in as "user1" using the webUI
And the user opens sharing tab from file action menu of file "testimage.jpg" using the webUI
Then the user should see a error message on the share dialog saying "Sharing is not allowed"
And the share-with field should not be visible in the details panel

@enterprise-issue-3037 # after the issue is fixed the issue remove the comments on two lines and remove last line
Scenario: user tries to re-share a file from a group which is blacklisted from sharing using webUI from shared with you page
Given group "grp1" has been created
And user "user1" has been added to group "grp1"
And user "user3" has been created with default attributes
And user "user2" has shared file "/testimage.jpg" with user "user1"
And the administrator has browsed to the admin sharing settings page
And the administrator has enabled exclude groups from sharing from admin sharing settings page
When the administrator adds group "grp1" to the group sharing blacklist using the webUI
And the user re-logs in as "user1" using the webUI
And the user browses to the shared-with-you page
And the user opens sharing tab from file action menu of file "testimage (2).jpg" using the webUI
#Then the user should see a error message on the share dialog saying "Sharing is not allowed"
#And the share-with field should not be visible in the details panel
Then the share-with field should be visible in the details panel

0 comments on commit 034104d

Please sign in to comment.