From fc456bec39446880ca6153ef903b569f041dd087 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Tue, 19 Sep 2017 12:53:35 +0200 Subject: check for encryption state on propfind Signed-off-by: Bjoern Schiessle --- core/js/tests/specs/files/clientSpec.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'core/js/tests') diff --git a/core/js/tests/specs/files/clientSpec.js b/core/js/tests/specs/files/clientSpec.js index 6593372144a..ec0a0fbda40 100644 --- a/core/js/tests/specs/files/clientSpec.js +++ b/core/js/tests/specs/files/clientSpec.js @@ -224,6 +224,7 @@ describe('OC.Files.Client tests', function() { expect(props).toContain('{http://owncloud.org/ns}fileid'); expect(props).toContain('{http://owncloud.org/ns}size'); expect(props).toContain('{http://owncloud.org/ns}permissions'); + expect(props).toContain('{http://nextcloud.org/ns}is-encrypted'); }); it('sends PROPFIND to base url when empty path given', function() { client.getFolderContents(''); @@ -262,6 +263,7 @@ describe('OC.Files.Client tests', function() { expect(info.mtime).toEqual(1436535485000); expect(info.mimetype).toEqual('text/plain'); expect(info.etag).toEqual('559fcabd79a38'); + expect(info.isEncrypted).toEqual(false); // sub entry info = response[1]; @@ -274,6 +276,7 @@ describe('OC.Files.Client tests', function() { expect(info.mtime).toEqual(1436536800000); expect(info.mimetype).toEqual('httpd/unix-directory'); expect(info.etag).toEqual('66cfcabd79abb'); + expect(info.isEncrypted).toEqual(false); }); }); it('returns parent node in result if specified', function() { @@ -303,6 +306,7 @@ describe('OC.Files.Client tests', function() { expect(info.mtime).toEqual(1436522405000); expect(info.mimetype).toEqual('httpd/unix-directory'); expect(info.etag).toEqual('56cfcabd79abb'); + expect(info.isEncrypted).toEqual(false); // the two other entries follow expect(response[1].id).toEqual(51); @@ -422,6 +426,7 @@ describe('OC.Files.Client tests', function() { expect(props).toContain('{http://owncloud.org/ns}fileid'); expect(props).toContain('{http://owncloud.org/ns}size'); expect(props).toContain('{http://owncloud.org/ns}permissions'); + expect(props).toContain('{http://nextcloud.org/ns}is-encrypted'); }); it('parses the result list into a FileInfo array', function() { var promise = client.getFilteredFiles({ @@ -473,7 +478,7 @@ describe('OC.Files.Client tests', function() { describe('file info', function() { var responseXml = dav.Client.prototype.parseMultiStatus( '' + - '' + + '' + makeResponseBlock( '/owncloud/remote.php/webdav/path/to%20space/%E6%96%87%E4%BB%B6%E5%A4%B9/', { @@ -483,7 +488,8 @@ describe('OC.Files.Client tests', function() { 'oc:id': '00000011oc2d13a6a068', 'oc:fileid': '11', 'oc:permissions': 'GRDNVCK', - 'oc:size': '120' + 'oc:size': '120', + 'nc:is-encrypted': '1' }, [ 'd:getcontenttype', @@ -510,6 +516,7 @@ describe('OC.Files.Client tests', function() { expect(props).toContain('{http://owncloud.org/ns}fileid'); expect(props).toContain('{http://owncloud.org/ns}size'); expect(props).toContain('{http://owncloud.org/ns}permissions'); + expect(props).toContain('{http://nextcloud.org/ns}is-encrypted'); }); it('parses the result into a FileInfo', function() { var promise = client.getFileInfo('path/to space/文件夹'); @@ -535,6 +542,7 @@ describe('OC.Files.Client tests', function() { expect(info.mtime).toEqual(1436522405000); expect(info.mimetype).toEqual('httpd/unix-directory'); expect(info.etag).toEqual('56cfcabd79abb'); + expect(info.isEncrypted).toEqual(true); }); }); it('properly parses entry inside root', function() { @@ -583,6 +591,7 @@ describe('OC.Files.Client tests', function() { expect(info.mtime).toEqual(1436522405000); expect(info.mimetype).toEqual('httpd/unix-directory'); expect(info.etag).toEqual('56cfcabd79abb'); + expect(info.isEncrypted).toEqual(false); }); }); it('rejects promise when an error occurred', function() { -- cgit v1.2.3 From 7bc28f14de8c3d77ec611a4ffd8ad48dc6093cea Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Tue, 19 Sep 2017 17:24:53 +0200 Subject: show e2e folder icon on encrypted folders Signed-off-by: Bjoern Schiessle --- apps/files/js/filelist.js | 5 ++++- apps/files/tests/js/filelistSpec.js | 26 ++++++++++++++++++++++++++ core/img/filetypes/folder-encrypted.svg | 1 + core/js/mimetype.js | 2 ++ core/js/mimetypelist.js | 1 + core/js/share.js | 6 +++++- core/js/tests/specs/shareSpec.js | 7 +++++++ 7 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 core/img/filetypes/folder-encrypted.svg (limited to 'core/js/tests') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 217a2f14896..0add41d6419 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -1156,7 +1156,10 @@ if (type === 'dir') { mime = mime || 'httpd/unix-directory'; - if (fileData.mountType && fileData.mountType.indexOf('external') === 0) { + if (fileData.isEncrypted) { + icon = OC.MimeType.getIconUrl('dir-encrypted'); + dataIcon = icon; + } else if (fileData.mountType && fileData.mountType.indexOf('external') === 0) { icon = OC.MimeType.getIconUrl('dir-external'); dataIcon = icon; } diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index e3b5eba3ecb..83926b24fee 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -1455,6 +1455,32 @@ describe('OCA.Files.FileList tests', function() { expect(OC.TestUtil.getImageUrl($td.find('.thumbnail'))).toEqual(OC.webroot + '/core/img/filetypes/folder.svg'); expect(previewLoadStub.notCalled).toEqual(true); }); + it('render encrypted folder icon for encrypted root', function() { + var fileData = { + type: 'dir', + mimetype: 'httpd/unix-directory', + name: 'test dir', + isEncrypted: true + }; + var $tr = fileList.add(fileData); + var $td = $tr.find('td.filename'); + expect(OC.TestUtil.getImageUrl($td.find('.thumbnail'))).toEqual(OC.webroot + '/core/img/filetypes/folder-encrypted.svg'); + expect(previewLoadStub.notCalled).toEqual(true); + }); + it('render encrypted folder icon for encrypted subdir', function() { + var fileData = { + type: 'dir', + mimetype: 'httpd/unix-directory', + name: 'test dir', + isEncrypted: true + }; + var $tr = fileList.add(fileData); + var $td = $tr.find('td.filename'); + expect(OC.TestUtil.getImageUrl($td.find('.thumbnail'))).toEqual(OC.webroot + '/core/img/filetypes/folder-encrypted.svg'); + expect(previewLoadStub.notCalled).toEqual(true); + // default icon override + expect($tr.attr('data-icon')).toEqual(OC.webroot + '/core/img/filetypes/folder-encrypted.svg'); + }); it('render external storage icon for external storage root', function() { var fileData = { type: 'dir', diff --git a/core/img/filetypes/folder-encrypted.svg b/core/img/filetypes/folder-encrypted.svg new file mode 100644 index 00000000000..e2b62a99b05 --- /dev/null +++ b/core/img/filetypes/folder-encrypted.svg @@ -0,0 +1 @@ + diff --git a/core/js/mimetype.js b/core/js/mimetype.js index ed4fedc7f8a..e5a07abc951 100644 --- a/core/js/mimetype.js +++ b/core/js/mimetype.js @@ -44,6 +44,8 @@ OC.MimeType = { // Generate path if (mimeType === 'dir' && $.inArray('folder', files) !== -1) { return 'folder'; + } else if (mimeType === 'dir-encrypted' && $.inArray('folder-encrypted', files) !== -1) { + return 'folder-encrypted'; } else if (mimeType === 'dir-shared' && $.inArray('folder-shared', files) !== -1) { return 'folder-shared'; } else if (mimeType === 'dir-public' && $.inArray('folder-public', files) !== -1) { diff --git a/core/js/mimetypelist.js b/core/js/mimetypelist.js index ea513131d88..13db16c5a21 100644 --- a/core/js/mimetypelist.js +++ b/core/js/mimetypelist.js @@ -104,6 +104,7 @@ OC.MimeTypeList={ "file", "folder", "folder-drag-accept", + "folder-encrypted", "folder-external", "folder-public", "folder-shared", diff --git a/core/js/share.js b/core/js/share.js index 25d59b46fb4..be90c626959 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -276,10 +276,14 @@ OC.Share = _.extend(OC.Share || {}, { $tr.find('.filename .thumbnail').css('background-image', 'url(' + shareFolderIcon + ')'); $tr.attr('data-icon', shareFolderIcon); } else if (type === 'dir') { + var isEncrypted = $tr.attr('data-e2eencrypted'); var mountType = $tr.attr('data-mounttype'); // FIXME: duplicate of FileList._createRow logic for external folder, // need to refactor the icon logic into a single code path eventually - if (mountType && mountType.indexOf('external') === 0) { + if (isEncrypted === 'true') { + shareFolderIcon = OC.MimeType.getIconUrl('dir-encrypted'); + $tr.attr('data-icon', shareFolderIcon); + } else if (mountType && mountType.indexOf('external') === 0) { shareFolderIcon = OC.MimeType.getIconUrl('dir-external'); $tr.attr('data-icon', shareFolderIcon); } else { diff --git a/core/js/tests/specs/shareSpec.js b/core/js/tests/specs/shareSpec.js index 70c698c99a2..127582ace61 100644 --- a/core/js/tests/specs/shareSpec.js +++ b/core/js/tests/specs/shareSpec.js @@ -149,6 +149,13 @@ describe('OC.Share tests', function() { checkIcon('filetypes/folder-external'); }); + it('shows encrypted icon if encrypted folder', function() { + $file.attr('data-type', 'dir'); + $file.attr('data-e2eencrypted', true); + OC.Share.markFileAsShared($file, false, false); + + checkIcon('filetypes/folder-encrypted'); + }); }); describe('displaying the recipients', function() { -- cgit v1.2.3