From 270558807309025a01ff456b94d3350eaab1ac41 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 9 Sep 2014 16:41:49 +0200 Subject: Dont' use mountpoint permissions as share permissions for external storages --- apps/files_sharing/js/share.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js index eccd21c9248..dd950e9b42b 100644 --- a/apps/files_sharing/js/share.js +++ b/apps/files_sharing/js/share.js @@ -19,6 +19,10 @@ OCA.Files.FileList.prototype._createRow = function(fileData) { var tr = oldCreateRow.apply(this, arguments); var sharePermissions = fileData.permissions; + if (fileData.mountType && fileData.mountType === "external-root"){ + // for external storages we cant use the permissions of the mountpoint + sharePermissions = OC.PERMISSION_ALL; + } if (fileData.type === 'file') { // files can't be shared with delete permissions sharePermissions = sharePermissions & ~OC.PERMISSION_DELETE; -- cgit v1.2.3 From 307071cfec088c2690c12a686578b49647ba5840 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 16 Sep 2014 20:54:11 +0200 Subject: Keep the share permissions from mountpoints --- apps/files_sharing/js/share.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js index dd950e9b42b..853e9f689f6 100644 --- a/apps/files_sharing/js/share.js +++ b/apps/files_sharing/js/share.js @@ -21,7 +21,8 @@ var sharePermissions = fileData.permissions; if (fileData.mountType && fileData.mountType === "external-root"){ // for external storages we cant use the permissions of the mountpoint - sharePermissions = OC.PERMISSION_ALL; + // instead we show all permissions and only use the share permissions from the mountpoint to handle resharing + sharePermissions = sharePermissions | (OC.PERMISSION_ALL & ~OC.PERMISSION_SHARE); } if (fileData.type === 'file') { // files can't be shared with delete permissions -- cgit v1.2.3 From 83126ab67596a29200e1624088801312935e4580 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 31 Oct 2014 15:22:08 +0100 Subject: Add unit tests --- apps/files_sharing/tests/js/sharedfilelistSpec.js | 85 +++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/apps/files_sharing/tests/js/sharedfilelistSpec.js b/apps/files_sharing/tests/js/sharedfilelistSpec.js index 41c8a1f05d8..812f30d75db 100644 --- a/apps/files_sharing/tests/js/sharedfilelistSpec.js +++ b/apps/files_sharing/tests/js/sharedfilelistSpec.js @@ -551,4 +551,89 @@ describe('OCA.Sharing.FileList tests', function() { expect($tr.find('.nametext').text().trim()).toEqual('local name.txt'); }); }); + describe('setting share permissions for files', function () { + beforeEach(function () { + + var $content = $('
'); + $('#testArea').append($content); + // dummy file list + var $div = $( + '
' + + '' + + '' + + '' + + '
' + + '
'); + $('#content').append($div); + + fileList = new OCA.Files.FileList( + $div, { + fileActions: fileActions + } + ); + }); + + it('external storage root folder', function () { + var $tr; + OC.Share.statuses = {1: {link: false, path: '/subdir'}}; + fileList.setFiles([{ + id: 1, + type: 'dir', + name: 'One.txt', + path: '/subdir', + mimetype: 'text/plain', + size: 12, + permissions: OC.PERMISSION_READ, + etag: 'abc', + shareOwner: 'User One', + recipients: 'User Two', + mountType: 'external-root' + }]); + $tr = fileList.$el.find('tr:first'); + + expect(parseInt($tr.attr('data-share-permissions'), 10)).toEqual(OC.PERMISSION_ALL - OC.PERMISSION_SHARE); + }); + + it('external storage root folder reshare', function () { + var $tr; + OC.Share.statuses = {1: {link: false, path: '/subdir'}}; + fileList.setFiles([{ + id: 1, + type: 'dir', + name: 'One.txt', + path: '/subdir', + mimetype: 'text/plain', + size: 12, + permissions: OC.PERMISSION_READ + OC.PERMISSION_SHARE, + etag: 'abc', + shareOwner: 'User One', + recipients: 'User Two', + mountType: 'external-root' + }]); + $tr = fileList.$el.find('tr:first'); + + expect(parseInt($tr.attr('data-share-permissions'), 10)).toEqual(OC.PERMISSION_ALL); + }); + + it('external storage root folder file', function () { + var $tr; + OC.Share.statuses = {1: {link: false, path: '/subdir'}}; + fileList.setFiles([{ + id: 1, + type: 'file', + name: 'One.txt', + path: '/subdir', + mimetype: 'text/plain', + size: 12, + permissions: OC.PERMISSION_READ, + etag: 'abc', + shareOwner: 'User One', + recipients: 'User Two', + mountType: 'external-root' + }]); + $tr = fileList.$el.find('tr:first'); + + expect(parseInt($tr.attr('data-share-permissions'), 10)).toEqual(OC.PERMISSION_ALL - OC.PERMISSION_SHARE - OC.PERMISSION_DELETE); + }); + }); }); -- cgit v1.2.3