Skip to content

Commit 742ac0f

Browse files
authored
Merge pull request #24045 from nextcloud/backport/24042/stable19
[stable19] Fix sharing tab state not matching resharing admin settings
2 parents b1efe18 + 3af171d commit 742ac0f

File tree

10 files changed

+344
-3
lines changed

10 files changed

+344
-3
lines changed

apps/files_sharing/js/dist/files_sharing_tab.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/files_sharing/js/dist/files_sharing_tab.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/files_sharing/src/components/SharingEntry.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666

6767
<!-- reshare permission -->
6868
<ActionCheckbox
69+
v-if="config.isResharingAllowed"
6970
ref="canReshare"
7071
:checked.sync="canReshare"
7172
:value="permissionsShare"

apps/files_sharing/src/views/SharingTab.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ import Avatar from '@nextcloud/vue/dist/Components/Avatar'
9494
import axios from '@nextcloud/axios'
9595
import Tab from '@nextcloud/vue/dist/Components/AppSidebarTab'
9696
97+
import Config from '../services/ConfigService'
9798
import { shareWithTitle } from '../utils/SharedWithMe'
9899
import Share from '../models/Share'
99100
import ShareTypes from '../mixins/ShareTypes'
@@ -132,6 +133,8 @@ export default {
132133
133134
data() {
134135
return {
136+
config: new Config(),
137+
135138
error: '',
136139
expirationInterval: null,
137140
icon: 'icon-share',
@@ -178,7 +181,7 @@ export default {
178181
179182
canReshare() {
180183
return !!(this.fileInfo.permissions & OC.PERMISSION_SHARE)
181-
|| !!(this.reshare && this.reshare.hasSharePermission)
184+
|| !!(this.reshare && this.reshare.hasSharePermission && this.config.isResharingAllowed)
182185
},
183186
},
184187

build/integration/features/bootstrap/SharingContext.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class SharingContext implements Context, SnippetAcceptingContext {
3636
use CommandLine;
3737

3838
protected function resetAppConfigs() {
39+
$this->modifyServerConfig('core', 'shareapi_default_permissions', '31');
3940
$this->modifyServerConfig('sharebymail', 'enforcePasswordProtection', 'no');
4041
}
4142
}

build/integration/sharing_features/sharing-v1.feature

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,40 @@ Feature: sharing
357357
| url | AN_URL |
358358
| mimetype | httpd/unix-directory |
359359

360+
Scenario: Creating a new share of a file with default permissions
361+
Given user "user0" exists
362+
And user "user1" exists
363+
And As an "user0"
364+
And parameter "shareapi_default_permissions" of app "core" is set to "7"
365+
When creating a share with
366+
| path | welcome.txt |
367+
| shareWith | user1 |
368+
| shareType | 0 |
369+
And the OCS status code should be "100"
370+
And the HTTP status code should be "200"
371+
And Getting info of last share
372+
Then the OCS status code should be "100"
373+
And the HTTP status code should be "200"
374+
And Share fields of last share match with
375+
| permissions | 3 |
376+
377+
Scenario: Creating a new share of a folder with default permissions
378+
Given user "user0" exists
379+
And user "user1" exists
380+
And As an "user0"
381+
And parameter "shareapi_default_permissions" of app "core" is set to "7"
382+
When creating a share with
383+
| path | FOLDER |
384+
| shareWith | user1 |
385+
| shareType | 0 |
386+
And the OCS status code should be "100"
387+
And the HTTP status code should be "200"
388+
And Getting info of last share
389+
Then the OCS status code should be "100"
390+
And the HTTP status code should be "200"
391+
And Share fields of last share match with
392+
| permissions | 7 |
393+
360394
Scenario: getting all shares of a user using that user
361395
Given user "user0" exists
362396
And user "user1" exists

tests/acceptance/features/app-files-sharing-link.feature

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,83 @@ Feature: app-files-sharing-link
166166
And I authenticate with password "abcdef"
167167
# download starts no page redirection
168168
And I see that the current page is the Authenticate page for the direct download shared link I wrote down
169+
170+
Scenario: sharee can not reshare by link if resharing is disabled in the settings after the share is created
171+
Given I act as John
172+
And I am logged in as the admin
173+
And I act as Jane
174+
And I am logged in
175+
And I act as John
176+
And I rename "welcome.txt" to "farewell.txt"
177+
And I see that the file list contains a file named "farewell.txt"
178+
And I share "farewell.txt" with "user0"
179+
And I see that the file is shared with "user0"
180+
And I visit the settings page
181+
And I open the "Sharing" section of the "Administration" group
182+
And I disable resharing
183+
And I see that resharing is disabled
184+
When I act as Jane
185+
# The Files app is open again to reload the file list
186+
And I open the Files app
187+
Then I see that the file list contains a file named "farewell.txt"
188+
And I open the details view for "farewell.txt"
189+
And I see that the details view is open
190+
And I open the "Sharing" tab in the details view
191+
And I see that the "Sharing" tab in the details view is eventually loaded
192+
And I see that the file is shared with me by "admin"
193+
And I see that resharing the file by link is not available
194+
195+
Scenario: sharee can unshare a reshare by link if resharing is disabled in the settings after the reshare is created
196+
Given I act as John
197+
And I am logged in as the admin
198+
And I act as Jane
199+
And I am logged in
200+
And I act as John
201+
And I rename "welcome.txt" to "farewell.txt"
202+
And I see that the file list contains a file named "farewell.txt"
203+
And I share "farewell.txt" with "user0"
204+
And I see that the file is shared with "user0"
205+
And I act as Jane
206+
# The Files app is open again to reload the file list
207+
And I open the Files app
208+
And I share the link for "farewell.txt"
209+
And I write down the shared link
210+
And I act as John
211+
And I visit the settings page
212+
And I open the "Sharing" section of the "Administration" group
213+
And I disable resharing
214+
And I see that resharing is disabled
215+
When I act as Jane
216+
# The Files app is open again to reload the file list
217+
And I open the Files app
218+
And I open the details view for "farewell.txt"
219+
And I see that the details view is open
220+
And I open the "Sharing" tab in the details view
221+
And I see that the "Sharing" tab in the details view is eventually loaded
222+
And I unshare the link share
223+
Then I see that resharing the file by link is not available
224+
225+
Scenario: reshare by link can be accessed if resharing is disabled in the settings after the reshare is created
226+
Given I act as John
227+
And I am logged in as the admin
228+
And I act as Jane
229+
And I am logged in
230+
And I act as John
231+
And I rename "welcome.txt" to "farewell.txt"
232+
And I see that the file list contains a file named "farewell.txt"
233+
And I share "farewell.txt" with "user0"
234+
And I see that the file is shared with "user0"
235+
And I act as Jane
236+
# The Files app is open again to reload the file list
237+
And I open the Files app
238+
And I share the link for "farewell.txt"
239+
And I write down the shared link
240+
And I act as John
241+
And I visit the settings page
242+
And I open the "Sharing" section of the "Administration" group
243+
And I disable resharing
244+
And I see that resharing is disabled
245+
When I act as Jim
246+
And I visit the shared link I wrote down
247+
Then I see that the current page is the shared link I wrote down
248+
And I see that the shared file preview shows the text "Welcome to your Nextcloud account!"

tests/acceptance/features/app-files-sharing.feature

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,110 @@ Feature: app-files-sharing
246246
And I enter in the folder named "Shared folder"
247247
Then I see that the file list contains a file named "Subfolder"
248248

249+
Scenario: sharer does not see resharing option for a folder if resharing is disabled in the settings after the share is created
250+
Given I am logged in as the admin
251+
And I create a new folder named "Shared folder"
252+
And I see that the file list contains a file named "Shared folder"
253+
And I share "Shared folder" with "user0"
254+
And I see that the file is shared with "user0"
255+
When I visit the settings page
256+
And I open the "Sharing" section of the "Administration" group
257+
And I disable resharing
258+
And I see that resharing is disabled
259+
Then I open the Files app
260+
And I open the details view for "Shared folder"
261+
And I see that the details view is open
262+
And I open the "Sharing" tab in the details view
263+
And I see that the "Sharing" tab in the details view is eventually loaded
264+
And I see that resharing for "user0" is not available
265+
266+
Scenario: sharee can not reshare a folder if resharing is disabled in the settings after the share is created
267+
Given I act as John
268+
And I am logged in as the admin
269+
And I act as Jane
270+
And I am logged in
271+
And I act as John
272+
And I create a new folder named "Shared folder"
273+
And I see that the file list contains a file named "Shared folder"
274+
And I share "Shared folder" with "user0"
275+
And I see that the file is shared with "user0"
276+
And I visit the settings page
277+
And I open the "Sharing" section of the "Administration" group
278+
And I disable resharing
279+
And I see that resharing is disabled
280+
When I act as Jane
281+
# The Files app is open again to reload the file list
282+
And I open the Files app
283+
Then I see that the file list contains a file named "Shared folder"
284+
And I open the details view for "Shared folder"
285+
And I see that the details view is open
286+
And I open the "Sharing" tab in the details view
287+
And I see that the "Sharing" tab in the details view is eventually loaded
288+
And I see that the file is shared with me by "admin"
289+
And I see that resharing the file is not allowed
290+
291+
Scenario: sharee can unshare a folder if resharing is disabled in the settings after the share is created
292+
Given I act as John
293+
And I am logged in as the admin
294+
And I act as Jane
295+
And I am logged in
296+
And I act as John
297+
And I create a new folder named "Shared folder"
298+
And I see that the file list contains a file named "Shared folder"
299+
And I share "Shared folder" with "user0"
300+
And I see that the file is shared with "user0"
301+
And I act as Jane
302+
# The Files app is open again to reload the file list
303+
And I open the Files app
304+
And I share "Shared folder" with "user1"
305+
And I act as John
306+
And I visit the settings page
307+
And I open the "Sharing" section of the "Administration" group
308+
And I disable resharing
309+
And I see that resharing is disabled
310+
When I act as Jane
311+
# The Files app is open again to reload the file list
312+
And I open the Files app
313+
Then I see that the file list contains a file named "Shared folder"
314+
And I open the details view for "Shared folder"
315+
And I see that the details view is open
316+
And I open the "Sharing" tab in the details view
317+
And I see that the "Sharing" tab in the details view is eventually loaded
318+
And I see that the file is shared with me by "admin"
319+
And I unshare the share with "user1"
320+
And I see that the file is not shared with "user1"
321+
322+
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
323+
Given I act as John
324+
And I am logged in as the admin
325+
And I act as Jane
326+
And I am logged in
327+
And I act as Jim
328+
And I am logged in as "user1"
329+
And I act as John
330+
And I create a new folder named "Shared folder"
331+
And I see that the file list contains a file named "Shared folder"
332+
And I share "Shared folder" with "user0"
333+
And I see that the file is shared with "user0"
334+
And I act as Jane
335+
# The Files app is open again to reload the file list
336+
And I open the Files app
337+
And I share "Shared folder" with "user1"
338+
And I act as John
339+
And I visit the settings page
340+
And I open the "Sharing" section of the "Administration" group
341+
And I disable resharing
342+
And I see that resharing is disabled
343+
And I open the Files app
344+
And I enter in the folder named "Shared folder"
345+
And I create a new folder named "Subfolder"
346+
And I see that the file list contains a file named "Subfolder"
347+
When I act as Jim
348+
# The Files app is open again to reload the file list
349+
And I open the Files app
350+
And I enter in the folder named "Shared folder"
351+
Then I see that the file list contains a file named "Subfolder"
352+
249353
Scenario: sharee can not reshare a folder if the sharer disables it
250354
Given I act as John
251355
And I am logged in as the admin

tests/acceptance/features/bootstrap/FilesAppSharingContext.php

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,15 @@ public static function canReshareCheckboxInput($sharedWithName) {
163163
return self::permissionCheckboxInputFor($sharedWithName, 'Allow resharing');
164164
}
165165

166+
/**
167+
* @return Locator
168+
*/
169+
public static function unshareButton($sharedWithName) {
170+
return Locator::forThe()->xpath("//li//button[normalize-space() = 'Unshare']")->
171+
descendantOf(self::shareWithMenu($sharedWithName))->
172+
describedAs("Unshare button in the share with $sharedWithName menu in the details view in Files app");
173+
}
174+
166175
/**
167176
* @return Locator
168177
*/
@@ -301,6 +310,15 @@ public static function passwordProtectByTalkCheckboxInput() {
301310
describedAs("Password protect by Talk checkbox input in the details view in Files app");
302311
}
303312

313+
/**
314+
* @return Locator
315+
*/
316+
public static function unshareLinkButton() {
317+
return Locator::forThe()->xpath("//li//button[normalize-space() = 'Unshare']")->
318+
descendantOf(self::shareLinkMenu())->
319+
describedAs("Unshare link button in the details view in Files app");
320+
}
321+
304322
/**
305323
* @Given I share the link for :fileName
306324
*/
@@ -433,6 +451,24 @@ public function iSetTheShareWithAsNotReshareable($shareWithName) {
433451
$this->actor->find(self::canReshareCheckbox($shareWithName), 2)->click();
434452
}
435453

454+
/**
455+
* @When I unshare the share with :shareWithName
456+
*/
457+
public function iUnshareTheFileWith($shareWithName) {
458+
$this->showShareWithMenuIfNeeded($shareWithName);
459+
460+
$this->actor->find(self::unshareButton($shareWithName), 2)->click();
461+
}
462+
463+
/**
464+
* @When I unshare the link share
465+
*/
466+
public function iUnshareTheLink() {
467+
$this->showShareLinkMenuIfNeeded();
468+
469+
$this->actor->find(self::unshareLinkButton(), 2)->click();
470+
}
471+
436472
/**
437473
* @Then I see that the file is shared with me by :sharedByName
438474
*/
@@ -449,6 +485,18 @@ public function iSeeThatTheFileIsSharedWith($sharedWithName) {
449485
$this->actor->find(self::sharedWithRow($sharedWithName), 10)->isVisible());
450486
}
451487

488+
/**
489+
* @Then I see that the file is not shared with :sharedWithName
490+
*/
491+
public function iSeeThatTheFileIsNotSharedWith($sharedWithName) {
492+
if (!WaitFor::elementToBeEventuallyNotShown(
493+
$this->actor,
494+
self::sharedWithRow($sharedWithName),
495+
$timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
496+
PHPUnit_Framework_Assert::fail("The shared with $sharedWithName row is still shown after $timeout seconds");
497+
}
498+
}
499+
452500
/**
453501
* @Then I see that resharing the file is not allowed
454502
*/
@@ -459,6 +507,18 @@ public function iSeeThatResharingTheFileIsNotAllowed() {
459507
$this->actor->find(self::shareWithInput(), 10)->getWrappedElement()->getAttribute("placeholder"), "Resharing is not allowed");
460508
}
461509

510+
/**
511+
* @Then I see that resharing the file by link is not available
512+
*/
513+
public function iSeeThatResharingTheFileByLinkIsNotAvailable() {
514+
if (!WaitFor::elementToBeEventuallyNotShown(
515+
$this->actor,
516+
self::shareLinkAddNewButton(),
517+
$timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
518+
PHPUnit_Framework_Assert::fail("The add new share link button is still shown after $timeout seconds");
519+
}
520+
}
521+
462522
/**
463523
* @Then I see that :sharedWithName can not be allowed to edit the share
464524
*/
@@ -519,6 +579,20 @@ public function iSeeThatCanNotCreateInTheShare($sharedWithName) {
519579
$this->actor->find(self::canCreateCheckboxInput($sharedWithName), 10)->isChecked());
520580
}
521581

582+
/**
583+
* @Then I see that resharing for :sharedWithName is not available
584+
*/
585+
public function iSeeThatResharingForIsNotAvailable($sharedWithName) {
586+
$this->showShareWithMenuIfNeeded($sharedWithName);
587+
588+
if (!WaitFor::elementToBeEventuallyNotShown(
589+
$this->actor,
590+
self::canReshareCheckbox($sharedWithName),
591+
$timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
592+
PHPUnit_Framework_Assert::fail("The resharing checkbox for $sharedWithName is still shown after $timeout seconds");
593+
}
594+
}
595+
522596
/**
523597
* @Then I see that :sharedWithName can reshare the share
524598
*/

0 commit comments

Comments
 (0)