Merge pull request #24042 from nextcloud/fix-sharing-tab-state-not-matching-resharing-admin-settings

This commit is contained in:
Julius Härtl 2020-11-11 09:28:23 +01:00 committed by GitHub
commit cdfad9aaac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 347 additions and 3 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -70,6 +70,7 @@
<!-- reshare permission -->
<ActionCheckbox
v-if="config.isResharingAllowed"
ref="canReshare"
:checked.sync="canReshare"
:value="permissionsShare"

View File

@ -90,6 +90,7 @@ import { generateOcsUrl } from '@nextcloud/router'
import Avatar from '@nextcloud/vue/dist/Components/Avatar'
import axios from '@nextcloud/axios'
import Config from '../services/ConfigService'
import { shareWithTitle } from '../utils/SharedWithMe'
import Share from '../models/Share'
import ShareTypes from '../mixins/ShareTypes'
@ -119,6 +120,8 @@ export default {
data() {
return {
config: new Config(),
error: '',
expirationInterval: null,
loading: true,
@ -147,7 +150,7 @@ export default {
canReshare() {
return !!(this.fileInfo.permissions & OC.PERMISSION_SHARE)
|| !!(this.reshare && this.reshare.hasSharePermission)
|| !!(this.reshare && this.reshare.hasSharePermission && this.config.isResharingAllowed)
},
},

View File

@ -37,6 +37,7 @@ class SharingContext implements Context, SnippetAcceptingContext {
use CommandLine;
protected function resetAppConfigs() {
$this->modifyServerConfig('core', 'shareapi_default_permissions', '31');
$this->modifyServerConfig('sharebymail', 'enforcePasswordProtection', 'no');
}
}

View File

@ -357,6 +357,40 @@ Feature: sharing
| url | AN_URL |
| mimetype | httpd/unix-directory |
Scenario: Creating a new share of a file with default permissions
Given user "user0" exists
And user "user1" exists
And As an "user0"
And parameter "shareapi_default_permissions" of app "core" is set to "7"
When creating a share with
| path | welcome.txt |
| shareWith | user1 |
| shareType | 0 |
And the OCS status code should be "100"
And the HTTP status code should be "200"
And Getting info of last share
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And Share fields of last share match with
| permissions | 3 |
Scenario: Creating a new share of a folder with default permissions
Given user "user0" exists
And user "user1" exists
And As an "user0"
And parameter "shareapi_default_permissions" of app "core" is set to "7"
When creating a share with
| path | FOLDER |
| shareWith | user1 |
| shareType | 0 |
And the OCS status code should be "100"
And the HTTP status code should be "200"
And Getting info of last share
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And Share fields of last share match with
| permissions | 7 |
Scenario: getting all shares of a user using that user
Given user "user0" exists
And user "user1" exists

View File

@ -166,3 +166,83 @@ Feature: app-files-sharing-link
And I authenticate with password "abcdef"
# download starts no page redirection
And I see that the current page is the Authenticate page for the direct download shared link I wrote down
Scenario: sharee can not reshare by link if resharing is disabled in the settings after the share is created
Given I act as John
And I am logged in as the admin
And I act as Jane
And I am logged in
And I act as John
And I rename "welcome.txt" to "farewell.txt"
And I see that the file list contains a file named "farewell.txt"
And I share "farewell.txt" with "user0"
And I see that the file is shared with "user0"
And I visit the settings page
And I open the "Sharing" section of the "Administration" group
And I disable resharing
And I see that resharing is disabled
When I act as Jane
# The Files app is open again to reload the file list
And I open the Files app
Then I see that the file list contains a file named "farewell.txt"
And I open the details view for "farewell.txt"
And I see that the details view is open
And I open the "Sharing" tab in the details view
And I see that the "Sharing" tab in the details view is eventually loaded
And I see that the file is shared with me by "admin"
And I see that resharing the file by link is not available
Scenario: sharee can unshare a reshare by link if resharing is disabled in the settings after the reshare is created
Given I act as John
And I am logged in as the admin
And I act as Jane
And I am logged in
And I act as John
And I rename "welcome.txt" to "farewell.txt"
And I see that the file list contains a file named "farewell.txt"
And I share "farewell.txt" with "user0"
And I see that the file is shared with "user0"
And I act as Jane
# The Files app is open again to reload the file list
And I open the Files app
And I share the link for "farewell.txt"
And I write down the shared link
And I act as John
And I visit the settings page
And I open the "Sharing" section of the "Administration" group
And I disable resharing
And I see that resharing is disabled
When I act as Jane
# The Files app is open again to reload the file list
And I open the Files app
And I open the details view for "farewell.txt"
And I see that the details view is open
And I open the "Sharing" tab in the details view
And I see that the "Sharing" tab in the details view is eventually loaded
And I unshare the link share
Then I see that resharing the file by link is not available
Scenario: reshare by link can be accessed if resharing is disabled in the settings after the reshare is created
Given I act as John
And I am logged in as the admin
And I act as Jane
And I am logged in
And I act as John
And I rename "welcome.txt" to "farewell.txt"
And I see that the file list contains a file named "farewell.txt"
And I share "farewell.txt" with "user0"
And I see that the file is shared with "user0"
And I act as Jane
# The Files app is open again to reload the file list
And I open the Files app
And I share the link for "farewell.txt"
And I write down the shared link
And I act as John
And I visit the settings page
And I open the "Sharing" section of the "Administration" group
And I disable resharing
And I see that resharing is disabled
When I act as Jim
And I visit the shared link I wrote down
Then I see that the current page is the shared link I wrote down
And I see that the shared file preview shows the text "Welcome to your Nextcloud account!"

View File

@ -246,6 +246,110 @@ Feature: app-files-sharing
And I enter in the folder named "Shared folder"
Then I see that the file list contains a file named "Subfolder"
Scenario: sharer does not see resharing option for a folder if resharing is disabled in the settings after the share is created
Given I am logged in as the admin
And I create a new folder named "Shared folder"
And I see that the file list contains a file named "Shared folder"
And I share "Shared folder" with "user0"
And I see that the file is shared with "user0"
When I visit the settings page
And I open the "Sharing" section of the "Administration" group
And I disable resharing
And I see that resharing is disabled
Then I open the Files app
And I open the details view for "Shared folder"
And I see that the details view is open
And I open the "Sharing" tab in the details view
And I see that the "Sharing" tab in the details view is eventually loaded
And I see that resharing for "user0" is not available
Scenario: sharee can not reshare a folder if resharing is disabled in the settings after the share is created
Given I act as John
And I am logged in as the admin
And I act as Jane
And I am logged in
And I act as John
And I create a new folder named "Shared folder"
And I see that the file list contains a file named "Shared folder"
And I share "Shared folder" with "user0"
And I see that the file is shared with "user0"
And I visit the settings page
And I open the "Sharing" section of the "Administration" group
And I disable resharing
And I see that resharing is disabled
When I act as Jane
# The Files app is open again to reload the file list
And I open the Files app
Then I see that the file list contains a file named "Shared folder"
And I open the details view for "Shared folder"
And I see that the details view is open
And I open the "Sharing" tab in the details view
And I see that the "Sharing" tab in the details view is eventually loaded
And I see that the file is shared with me by "admin"
And I see that resharing the file is not allowed
Scenario: sharee can unshare a folder if resharing is disabled in the settings after the share is created
Given I act as John
And I am logged in as the admin
And I act as Jane
And I am logged in
And I act as John
And I create a new folder named "Shared folder"
And I see that the file list contains a file named "Shared folder"
And I share "Shared folder" with "user0"
And I see that the file is shared with "user0"
And I act as Jane
# The Files app is open again to reload the file list
And I open the Files app
And I share "Shared folder" with "user1"
And I act as John
And I visit the settings page
And I open the "Sharing" section of the "Administration" group
And I disable resharing
And I see that resharing is disabled
When I act as Jane
# The Files app is open again to reload the file list
And I open the Files app
Then I see that the file list contains a file named "Shared folder"
And I open the details view for "Shared folder"
And I see that the details view is open
And I open the "Sharing" tab in the details view
And I see that the "Sharing" tab in the details view is eventually loaded
And I see that the file is shared with me by "admin"
And I unshare the share with "user1"
And I see that the file is not shared with "user1"
Scenario: resharee sees a folder created by the owner in a shared folder if resharing is disabled in the settings after the share is created
Given I act as John
And I am logged in as the admin
And I act as Jane
And I am logged in
And I act as Jim
And I am logged in as "user1"
And I act as John
And I create a new folder named "Shared folder"
And I see that the file list contains a file named "Shared folder"
And I share "Shared folder" with "user0"
And I see that the file is shared with "user0"
And I act as Jane
# The Files app is open again to reload the file list
And I open the Files app
And I share "Shared folder" with "user1"
And I act as John
And I visit the settings page
And I open the "Sharing" section of the "Administration" group
And I disable resharing
And I see that resharing is disabled
And I open the Files app
And I enter in the folder named "Shared folder"
And I create a new folder named "Subfolder"
And I see that the file list contains a file named "Subfolder"
When I act as Jim
# The Files app is open again to reload the file list
And I open the Files app
And I enter in the folder named "Shared folder"
Then I see that the file list contains a file named "Subfolder"
Scenario: sharee can not reshare a folder if the sharer disables it
Given I act as John
And I am logged in as the admin

View File

@ -171,6 +171,15 @@ class FilesAppSharingContext implements Context, ActorAwareInterface {
return self::permissionCheckboxInputFor($sharedWithName, $shareWithMenuTriggerElement, 'Allow resharing');
}
/**
* @return Locator
*/
public static function unshareButton($sharedWithName, $shareWithMenuTriggerElement) {
return Locator::forThe()->xpath("//li[contains(concat(' ', normalize-space(@class), ' '), ' action ')]//button[normalize-space() = 'Unshare']")->
descendantOf(self::shareWithMenu($sharedWithName, $shareWithMenuTriggerElement))->
describedAs("Unshare button in the share with $sharedWithName menu in the details view in Files app");
}
/**
* @return Locator
*/
@ -317,6 +326,15 @@ class FilesAppSharingContext implements Context, ActorAwareInterface {
describedAs("Password protect by Talk checkbox input in the details view in Files app");
}
/**
* @return Locator
*/
public static function unshareLinkButton($shareLinkMenuTriggerElement) {
return Locator::forThe()->xpath("//li[contains(concat(' ', normalize-space(@class), ' '), ' action ')]//button[normalize-space() = 'Unshare']")->
descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))->
describedAs("Unshare link button in the details view in Files app");
}
/**
* @Given I share the link for :fileName
*/
@ -471,6 +489,26 @@ class FilesAppSharingContext implements Context, ActorAwareInterface {
$this->actor->find(self::canReshareCheckbox($shareWithName, $shareWithMenuTriggerElement), 2)->click();
}
/**
* @When I unshare the share with :shareWithName
*/
public function iUnshareTheFileWith($shareWithName) {
$this->showShareWithMenuIfNeeded($shareWithName);
$shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($shareWithName), 2);
$this->actor->find(self::unshareButton($shareWithName, $shareWithMenuTriggerElement), 2)->click();
}
/**
* @When I unshare the link share
*/
public function iUnshareTheLink() {
$this->showShareLinkMenuIfNeeded();
$shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2);
$this->actor->find(self::unshareLinkButton($shareLinkMenuTriggerElement), 2)->click();
}
/**
* @Then I see that the file is shared with me by :sharedByName
*/
@ -487,6 +525,18 @@ class FilesAppSharingContext implements Context, ActorAwareInterface {
$this->actor->find(self::sharedWithRow($sharedWithName), 10)->isVisible());
}
/**
* @Then I see that the file is not shared with :sharedWithName
*/
public function iSeeThatTheFileIsNotSharedWith($sharedWithName) {
if (!WaitFor::elementToBeEventuallyNotShown(
$this->actor,
self::sharedWithRow($sharedWithName),
$timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
PHPUnit_Framework_Assert::fail("The shared with $sharedWithName row is still shown after $timeout seconds");
}
}
/**
* @Then I see that resharing the file is not allowed
*/
@ -497,6 +547,18 @@ class FilesAppSharingContext implements Context, ActorAwareInterface {
$this->actor->find(self::shareWithInput(), 10)->getWrappedElement()->getAttribute("placeholder"), "Resharing is not allowed");
}
/**
* @Then I see that resharing the file by link is not available
*/
public function iSeeThatResharingTheFileByLinkIsNotAvailable() {
if (!WaitFor::elementToBeEventuallyNotShown(
$this->actor,
self::shareLinkAddNewButton(),
$timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
PHPUnit_Framework_Assert::fail("The add new share link button is still shown after $timeout seconds");
}
}
/**
* @Then I see that :sharedWithName can not be allowed to edit the share
*/
@ -563,6 +625,21 @@ class FilesAppSharingContext implements Context, ActorAwareInterface {
$this->actor->find(self::canCreateCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked());
}
/**
* @Then I see that resharing for :sharedWithName is not available
*/
public function iSeeThatResharingForIsNotAvailable($sharedWithName) {
$this->showShareWithMenuIfNeeded($sharedWithName);
$shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10);
if (!WaitFor::elementToBeEventuallyNotShown(
$this->actor,
self::canReshareCheckbox($sharedWithName, $shareWithMenuTriggerElement),
$timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
PHPUnit_Framework_Assert::fail("The resharing checkbox for $sharedWithName is still shown after $timeout seconds");
}
}
/**
* @Then I see that :sharedWithName can reshare the share
*/

View File

@ -45,6 +45,25 @@ class SettingsContext implements Context, ActorAwareInterface {
describedAs("Accept shares by default checkbox input in Sharing section in Personal Sharing Settings");
}
/**
* @return Locator
*/
public static function allowResharingCheckbox() {
// forThe()->checkbox("Allow resharing") can not be used here; that
// would return the checkbox itself, but the element that the user
// interacts with is the label.
return Locator::forThe()->xpath("//label[normalize-space() = 'Allow resharing']")->
describedAs("Allow resharing checkbox in Sharing section in Administration Sharing Settings");
}
/**
* @return Locator
*/
public static function allowResharingCheckboxInput() {
return Locator::forThe()->checkbox("Allow resharing")->
describedAs("Allow resharing checkbox input in Sharing section in Administration Sharing Settings");
}
/**
* @return Locator
*/
@ -130,6 +149,15 @@ class SettingsContext implements Context, ActorAwareInterface {
$this->actor->find(self::acceptSharesByDefaultCheckbox(), 2)->click();
}
/**
* @When I disable resharing
*/
public function iDisableResharing() {
$this->iSeeThatResharingIsEnabled();
$this->actor->find(self::allowResharingCheckbox(), 2)->click();
}
/**
* @When I enable restricting username autocompletion to groups
*/
@ -156,6 +184,22 @@ class SettingsContext implements Context, ActorAwareInterface {
$this->actor->find(self::acceptSharesByDefaultCheckboxInput(), 10)->isChecked());
}
/**
* @Then I see that resharing is enabled
*/
public function iSeeThatResharingIsEnabled() {
PHPUnit_Framework_Assert::assertTrue(
$this->actor->find(self::allowResharingCheckboxInput(), 10)->isChecked());
}
/**
* @Then I see that resharing is disabled
*/
public function iSeeThatResharingIsDisabled() {
PHPUnit_Framework_Assert::assertFalse(
$this->actor->find(self::allowResharingCheckboxInput(), 10)->isChecked());
}
/**
* @Then I see that username autocompletion is restricted to groups
*/