Skip to content

Commit

Permalink
Merge pull request #35197 from owncloud/update-permission-and-behavio…
Browse files Browse the repository at this point in the history
…ur-release-10.2.0

[10.2.0] Backport of Fix permission and update behaviour for public link
  • Loading branch information
Vincent Petry authored May 10, 2019
2 parents 6237fae + d588b4a commit 6551672
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 28 deletions.
5 changes: 5 additions & 0 deletions apps/files/js/file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,11 @@ OC.Uploader.prototype = _.extend({
}
var fileInfo = fileList.findFile(file.name);
if (fileInfo) {
var sharePermission = parseInt($("#sharePermission").val());
if (sharePermission === (OC.PERMISSION_READ | OC.PERMISSION_CREATE)) {
OC.Notification.show(t('files', 'The file {file} already exists', {file: fileInfo.name}), {type: 'error'});
return false;
}
conflicts.push([
// original
_.extend(fileInfo, {
Expand Down
3 changes: 2 additions & 1 deletion apps/files_sharing/lib/Controller/Share20OcsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ public function createShare() {
);
} elseif ($permissions === \OCP\Constants::PERMISSION_CREATE ||
$permissions === (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE) ||
$permissions === (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_CREATE)) {
$permissions === (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE)) {
$share->setPermissions($permissions);
} else {
// because when "publicUpload" is passed usually no permissions are set,
Expand Down Expand Up @@ -772,6 +772,7 @@ public function updateShare($id) {
if ($newPermissions !== null &&
$newPermissions !== Constants::PERMISSION_READ &&
$newPermissions !== Constants::PERMISSION_CREATE &&
$newPermissions !== (Constants::PERMISSION_READ | Constants::PERMISSION_CREATE) &&
// legacy
$newPermissions !== (Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE) &&
// correct
Expand Down
4 changes: 2 additions & 2 deletions core/js/sharedialoglinkshareview.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@

publicUploadWriteLabel : t('core', 'Download / View / Upload'),
publicUploadWriteDescription : t('core', 'Recipients can view, download and upload contents.'),
publicUploadWriteValue : OC.PERMISSION_READ | OC.PERMISSION_UPDATE | OC.PERMISSION_CREATE,
publicUploadWriteSelected : this.model.get('permissions') === (OC.PERMISSION_READ | OC.PERMISSION_UPDATE | OC.PERMISSION_CREATE),
publicUploadWriteValue : OC.PERMISSION_READ | OC.PERMISSION_CREATE,
publicUploadWriteSelected : this.model.get('permissions') === (OC.PERMISSION_READ | OC.PERMISSION_CREATE),

publicReadWriteLabel : t('core', 'Download / View / Edit'),
publicReadWriteDescription : t('core', 'Recipients can view, download and edit contents.'),
Expand Down
4 changes: 2 additions & 2 deletions tests/TestHelpers/SharingHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SharingHelper {
* 1 = read; 2 = update; 4 = create;
* 8 = delete; 16 = share; 31 = all
* 15 = change
* 7 = uploadwriteonly
* 5 = uploadwriteonly
* (default: 31, for public shares: 1)
* Pass either the (total) number,
* or the keyword,
Expand Down Expand Up @@ -171,7 +171,7 @@ public static function getPermissionSum($permissions) {
'read' => 1,
'update' => 2,
'create' => 4,
'uploadwriteonly' => 7,
'uploadwriteonly' => 5,
'delete' => 8,
'change' => 15,
'share' => 16,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,13 @@ Feature: sharing
And user "user0" has created folder "/afolder"
When user "user0" creates a public link share using the sharing API with settings
| path | /afolder |
| permissions | 7 |
| permissions | 5 |
Then the OCS status code should be "<ocs_status_code>"
And the HTTP status code should be "200"
And the share fields of the last share should include
| id | A_NUMBER |
| share_type | 3 |
| permissions | 7 |
| permissions | 5 |
Examples:
| ocs_api_version | ocs_status_code |
| 1 | 100 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,5 @@ Feature: sharing
| path | FOLDER |
| permissions | uploadwriteonly |
When the public uploads file "test.txt" with content "test" using the public WebDAV API
And the public uploads file "test.txt" with content "test2" with autorename mode using the public WebDAV API
And the public uploads file "test.txt" with content "test3" with autorename mode using the public WebDAV API
And the public uploads file "test.txt" with content "test2" using the public WebDAV API
Then the content of file "/FOLDER/test.txt" for user "user0" should be "test"
And the content of file "/FOLDER/test (2).txt" for user "user0" should be "test2"
And the content of file "/FOLDER/test (3).txt" for user "user0" should be "test3"
6 changes: 2 additions & 4 deletions tests/acceptance/features/bootstrap/WebUIFilesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -1003,18 +1003,16 @@ public function theUserChoosesToInTheUploadDialog($label) {
}

/**
* @When the user uploads file :name and clicks :label button :number_of times using webUI
* @When the user uploads file :name :number_of times using webUI
*
* @param string $name
* @param string $label
* @param int $number_of
*
* @return void
*/
public function theUserClicksUploadAndCancelMultipleTimes($name, $label, $number_of) {
public function theUserClicksUploadAndCancelMultipleTimes($name, $number_of) {
for ($i = 0; $i < $number_of; $i++) {
$this->theUserUploadsFileUsingTheWebUI($name);
$this->theUserChoosesToInTheUploadDialog($label);
\usleep(STANDARD_SLEEP_TIME_MICROSEC);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,22 +373,17 @@ Feature: Share by public link
And the public accesses the last created public link using the webUI
Then it should not be possible to delete file "lorem.txt" using the webUI

Scenario: user edits the permission of an already existing public link from read-write to upload-write-without-overwrite
Given the user has created a new public link for folder "simple-folder" using the webUI with
| permission | read-write |
When the user changes the permission of the public link named "Public link" to "upload-write-without-modify"
And the public accesses the last created public link using the webUI
When the user uploads file "lorem.txt" keeping both new and existing files using the webUI
Then file "lorem.txt" should be listed on the webUI
And file "lorem (2).txt" should be listed on the webUI

Scenario: user creates public link with view download and upload feature and uploads and cancels same file multiple times to verify the conflict dialog exits after clicking cancel button
Scenario: user creates public link with view download and upload feature and uploads same file name and verifies no auto-renamed file seen in UI
Given the user has created a new public link for folder "simple-folder" using the webUI with
| permission | upload-write-without-modify |
And the public accesses the last created public link using the webUI
When the user uploads file "lorem.txt" and clicks "Cancel" button 10 times using webUI
Then no dialog should be displayed on the webUI
And no notification should be displayed on the webUI
When the user uploads file "lorem.txt" 5 times using webUI
Then notifications should be displayed on the webUI with the text
| The file lorem.txt already exists |
| The file lorem.txt already exists |
| The file lorem.txt already exists |
| The file lorem.txt already exists |
| The file lorem.txt already exists |
And file "lorem.txt" should be listed on the webUI
And the content of "lorem.txt" should not have changed
And file "lorem (2).txt" should not be listed on the webUI

0 comments on commit 6551672

Please sign in to comment.