summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/comments/appinfo/app.php1
-rw-r--r--apps/comments/appinfo/info.xml3
-rw-r--r--apps/comments/css/comments.css31
-rw-r--r--apps/comments/js/commentcollection.js61
-rw-r--r--apps/comments/js/commentmodel.js16
-rw-r--r--apps/comments/js/commentstabview.js225
-rw-r--r--apps/comments/js/commentsummarymodel.js65
-rw-r--r--apps/comments/js/filesplugin.js84
-rw-r--r--apps/comments/tests/js/commentscollectionSpec.js44
-rw-r--r--apps/comments/tests/js/commentstabviewSpec.js176
-rw-r--r--apps/comments/tests/js/filespluginSpec.js102
-rw-r--r--apps/dav/appinfo/info.xml1
-rw-r--r--apps/dav/appinfo/register_command.php2
-rw-r--r--apps/dav/command/createcalendar.php15
-rw-r--r--apps/dav/lib/caldav/caldavbackend.php90
-rw-r--r--apps/dav/lib/caldav/calendar.php102
-rw-r--r--apps/dav/lib/caldav/calendarhome.php78
-rw-r--r--apps/dav/lib/caldav/calendarroot.php10
-rw-r--r--apps/dav/lib/carddav/addressbook.php29
-rw-r--r--apps/dav/lib/carddav/carddavbackend.php29
-rw-r--r--apps/dav/lib/dav/sharing/backend.php33
-rw-r--r--apps/dav/lib/dav/sharing/plugin.php27
-rw-r--r--apps/dav/lib/dav/sharing/xml/invite.php149
-rw-r--r--apps/dav/lib/rootcollection.php4
-rw-r--r--apps/dav/tests/travis/caldav/install.sh1
-rw-r--r--apps/dav/tests/travis/caldav/script.sh4
-rw-r--r--apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/1.xml8
-rw-r--r--apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/4.xml8
-rw-r--r--apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/5.ics29
-rw-r--r--apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/5.xml6
-rw-r--r--apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/6.ics29
-rw-r--r--apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/7.ics29
-rw-r--r--apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/8.ics29
-rw-r--r--apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/9.ics29
-rw-r--r--apps/dav/tests/travis/caldavtest/tests/CalDAV/sharing-calendars.xml180
-rw-r--r--apps/dav/tests/travis/caldavtest/tests/CardDAV/sharing-addressbooks.xml65
-rw-r--r--apps/dav/tests/unit/caldav/caldavbackendtest.php132
-rw-r--r--apps/dav/tests/unit/caldav/calendartest.php64
-rw-r--r--apps/dav/tests/unit/carddav/addressbooktest.php64
-rw-r--r--apps/dav/tests/unit/carddav/carddavbackendtest.php33
-rw-r--r--apps/encryption/appinfo/info.xml2
-rw-r--r--apps/files/appinfo/info.xml1
-rw-r--r--apps/files_external/l10n/it.js1
-rw-r--r--apps/files_external/l10n/it.json1
-rw-r--r--apps/files_external/l10n/pt_PT.js1
-rw-r--r--apps/files_external/l10n/pt_PT.json1
-rw-r--r--apps/files_sharing/api/share20ocs.php85
-rw-r--r--apps/files_sharing/js/public.js6
-rw-r--r--apps/files_sharing/lib/controllers/sharecontroller.php16
-rw-r--r--apps/files_sharing/tests/api/share20ocstest.php146
-rw-r--r--apps/files_sharing/tests/controller/sharecontroller.php42
-rw-r--r--apps/files_sharing/tests/js/publicAppSpec.js8
-rw-r--r--apps/systemtags/appinfo/info.xml3
-rw-r--r--core/img/actions/comment.pngbin0 -> 169 bytes
-rw-r--r--core/img/actions/comment.svg4
-rw-r--r--core/js/js.js21
-rw-r--r--core/shipped.json1
-rw-r--r--lib/private/files/cache/cache.php91
-rw-r--r--lib/private/files/cache/wrapper/cachejail.php7
-rw-r--r--lib/private/files/cache/wrapper/cachewrapper.php23
-rw-r--r--lib/private/server.php3
-rw-r--r--lib/private/share20/defaultshareprovider.php133
-rw-r--r--lib/private/share20/manager.php118
-rw-r--r--lib/private/share20/share.php9
-rw-r--r--lib/private/user/manager.php4
-rw-r--r--lib/public/files/cache/icache.php13
-rw-r--r--lib/public/share/imanager.php20
-rw-r--r--lib/public/share/ishare.php12
-rw-r--r--lib/public/share/ishareprovider.php22
-rw-r--r--resources/codesigning/core.crt48
-rw-r--r--resources/codesigning/core.key51
-rw-r--r--resources/codesigning/root.crt62
-rw-r--r--resources/codesigning/root.key51
-rw-r--r--tests/karma.config.js3
-rw-r--r--tests/lib/appframework/AppTest.php6
-rw-r--r--tests/lib/share20/defaultshareprovidertest.php341
-rw-r--r--tests/lib/share20/managertest.php346
77 files changed, 2693 insertions, 1096 deletions
diff --git a/apps/comments/appinfo/app.php b/apps/comments/appinfo/app.php
index c6f36567c51..a1eb4f6899d 100644
--- a/apps/comments/appinfo/app.php
+++ b/apps/comments/appinfo/app.php
@@ -27,6 +27,7 @@ $eventDispatcher->addListener(
\OCP\Util::addScript('comments', 'app');
\OCP\Util::addScript('comments', 'commentmodel');
\OCP\Util::addScript('comments', 'commentcollection');
+ \OCP\Util::addScript('comments', 'commentsummarymodel');
\OCP\Util::addScript('comments', 'commentstabview');
\OCP\Util::addScript('comments', 'filesplugin');
\OCP\Util::addStyle('comments', 'comments');
diff --git a/apps/comments/appinfo/info.xml b/apps/comments/appinfo/info.xml
index 550c79448cf..f3693150639 100644
--- a/apps/comments/appinfo/info.xml
+++ b/apps/comments/appinfo/info.xml
@@ -10,7 +10,4 @@
<dependencies>
<owncloud min-version="9.0" max-version="9.0" />
</dependencies>
- <documentation>
- <user>user-comments</user>
- </documentation>
</info>
diff --git a/apps/comments/css/comments.css b/apps/comments/css/comments.css
index c1624dcc57b..b86ed38efe7 100644
--- a/apps/comments/css/comments.css
+++ b/apps/comments/css/comments.css
@@ -49,3 +49,34 @@
position: absolute;
right: 0;
}
+
+#commentsTabView .comment .action {
+ opacity: 0;
+ vertical-align: middle;
+ display: inline-block;
+}
+
+#commentsTabView .comment:hover .action {
+ opacity: 0.3;
+}
+
+#commentsTabView .comment .action:hover {
+ opacity: 1;
+}
+
+#commentsTabView .comment .action.delete {
+ position: absolute;
+ right: 0;
+}
+
+#commentsTabView .comment.disabled {
+ opacity: 0.3;
+}
+
+#commentsTabView .comment.disabled .action {
+ visibility: hidden;
+}
+
+.app-files .action-comment>img {
+ margin-right: 5px;
+}
diff --git a/apps/comments/js/commentcollection.js b/apps/comments/js/commentcollection.js
index d10e5e00865..a15039cf484 100644
--- a/apps/comments/js/commentcollection.js
+++ b/apps/comments/js/commentcollection.js
@@ -10,8 +10,6 @@
(function(OC, OCA) {
- var NS_OWNCLOUD = 'http://owncloud.org/ns';
-
/**
* @class OCA.Comments.CommentCollection
* @classdesc
@@ -26,12 +24,40 @@
model: OCA.Comments.CommentModel,
+ /**
+ * Object type
+ *
+ * @type string
+ */
_objectType: 'files',
+
+ /**
+ * Object id
+ *
+ * @type string
+ */
_objectId: null,
+ /**
+ * True if there are no more page results left to fetch
+ *
+ * @type bool
+ */
_endReached: false,
+
+ /**
+ * Number of comments to fetch per page
+ *
+ * @type int
+ */
_limit : 20,
+ /**
+ * Initializes the collection
+ *
+ * @param {string} [options.objectType] object type
+ * @param {string} [options.objectId] object id
+ */
initialize: function(models, options) {
options = options || {};
if (options.objectType) {
@@ -58,6 +84,7 @@
reset: function() {
this._endReached = false;
+ this._summaryModel = null;
return OC.Backbone.Collection.prototype.reset.apply(this, arguments);
},
@@ -81,6 +108,7 @@
var success = options.success;
options = _.extend({
remove: false,
+ parse: true,
data: body,
davProperties: CommentCollection.prototype.model.prototype.davProperties,
success: function(resp) {
@@ -102,6 +130,35 @@
}, options);
return this.sync('REPORT', this, options);
+ },
+
+ /**
+ * Returns the matching summary model
+ *
+ * @return {OCA.Comments.CommentSummaryModel} summary model
+ */
+ getSummaryModel: function() {
+ if (!this._summaryModel) {
+ this._summaryModel = new OCA.Comments.CommentSummaryModel({
+ id: this._objectId,
+ objectType: this._objectType
+ });
+ }
+ return this._summaryModel;
+ },
+
+ /**
+ * Updates the read marker for this comment thread
+ *
+ * @param {Date} [date] optional date, defaults to now
+ * @param {Object} [options] backbone options
+ */
+ updateReadMarker: function(date, options) {
+ options = options || {};
+
+ return this.getSummaryModel().save({
+ readMarker: (date || new Date()).toUTCString()
+ }, options);
}
});
diff --git a/apps/comments/js/commentmodel.js b/apps/comments/js/commentmodel.js
index b945f71fdd2..89492707b61 100644
--- a/apps/comments/js/commentmodel.js
+++ b/apps/comments/js/commentmodel.js
@@ -34,12 +34,22 @@
'actorDisplayName': '{' + NS_OWNCLOUD + '}actorDisplayName',
'creationDateTime': '{' + NS_OWNCLOUD + '}creationDateTime',
'objectType': '{' + NS_OWNCLOUD + '}objectType',
- 'objectId': '{' + NS_OWNCLOUD + '}objectId'
+ 'objectId': '{' + NS_OWNCLOUD + '}objectId',
+ 'isUnread': '{' + NS_OWNCLOUD + '}isUnread'
},
parse: function(data) {
- // TODO: parse non-string values
- return data;
+ return {
+ id: data.id,
+ message: data.message,
+ actorType: data.actorType,
+ actorId: data.actorId,
+ actorDisplayName: data.actorDisplayName,
+ creationDateTime: data.creationDateTime,
+ objectType: data.objectType,
+ objectId: data.objectId,
+ isUnread: (data.isUnread === 'true')
+ };
}
});
diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js
index 463ac2d76ef..2c5e9414751 100644
--- a/apps/comments/js/commentstabview.js
+++ b/apps/comments/js/commentstabview.js
@@ -8,35 +8,48 @@
*
*/
+/* global Handlebars */
+
(function(OC, OCA) {
var TEMPLATE =
- '<div class="newCommentRow comment">' +
+ '<ul class="comments">' +
+ '</ul>' +
+ '<div class="empty hidden">{{emptyResultLabel}}</div>' +
+ '<input type="button" class="showMore hidden" value="{{moreLabel}}"' +
+ ' name="show-more" id="show-more" />' +
+ '<div class="loading hidden" style="height: 50px"></div>';
+
+ var EDIT_COMMENT_TEMPLATE =
+ '<div class="newCommentRow comment" data-id="{{id}}">' +
' <div class="authorRow">' +
' {{#if avatarEnabled}}' +
- ' <div class="avatar" data-username="{{userId}}"></div>' +
+ ' <div class="avatar" data-username="{{actorId}}"></div>' +
' {{/if}}' +
- ' <div class="author">{{userDisplayName}}</div>' +
+ ' <div class="author">{{actorDisplayName}}</div>' +
+ '{{#if isEditMode}}' +
+ ' <a href="#" class="action delete icon icon-delete has-tooltip" title="{{deleteTooltip}}"></a>' +
+ '{{/if}}' +
' </div>' +
' <form class="newCommentForm">' +
- ' <textarea class="message" placeholder="{{newMessagePlaceholder}}"></textarea>' +
+ ' <textarea class="message" placeholder="{{newMessagePlaceholder}}">{{{message}}}</textarea>' +
' <input class="submit" type="submit" value="{{submitText}}" />' +
+ '{{#if isEditMode}}' +
+ ' <input class="cancel" type="button" value="{{cancelText}}" />' +
+ '{{/if}}' +
' <div class="submitLoading icon-loading-small hidden"></div>'+
' </form>' +
- ' <ul class="comments">' +
- ' </ul>' +
- '</div>' +
- '<div class="empty hidden">{{emptyResultLabel}}</div>' +
- '<input type="button" class="showMore hidden" value="{{moreLabel}}"' +
- ' name="show-more" id="show-more" />' +
- '<div class="loading hidden" style="height: 50px"></div>';
+ '</div>';
var COMMENT_TEMPLATE =
- '<li class="comment">' +
+ '<li class="comment{{#if isUnread}} unread{{/if}}" data-id="{{id}}">' +
' <div class="authorRow">' +
' {{#if avatarEnabled}}' +
' <div class="avatar" data-username="{{actorId}}"> </div>' +
' {{/if}}' +
' <div class="author">{{actorDisplayName}}</div>' +
+ '{{#if isUserAuthor}}' +
+ ' <a href="#" class="action edit icon icon-rename has-tooltip" title="{{editTooltip}}"></a>' +
+ '{{/if}}' +
' <div class="date has-tooltip" title="{{altDate}}">{{date}}</div>' +
' </div>' +
' <div class="message">{{{formattedMessage}}}</div>' +
@@ -52,7 +65,10 @@
events: {
'submit .newCommentForm': '_onSubmitComment',
- 'click .showMore': '_onClickShowMore'
+ 'click .showMore': '_onClickShowMore',
+ 'click .action.edit': '_onClickEditComment',
+ 'click .action.delete': '_onClickDeleteComment',
+ 'click .cancel': '_onClickCloseComment'
},
initialize: function() {
@@ -65,7 +81,6 @@
this._avatarsEnabled = !!OC.config.enable_avatars;
// TODO: error handling
- _.bindAll(this, '_onSubmitComment');
},
template: function(params) {
@@ -75,10 +90,24 @@
var currentUser = OC.getCurrentUser();
return this._template(_.extend({
avatarEnabled: this._avatarsEnabled,
- userId: currentUser.uid,
- userDisplayName: currentUser.displayName,
+ actorId: currentUser.uid,
+ actorDisplayName: currentUser.displayName
+ }, params));
+ },
+
+ editCommentTemplate: function(params) {
+ if (!this._editCommentTemplate) {
+ this._editCommentTemplate = Handlebars.compile(EDIT_COMMENT_TEMPLATE);
+ }
+ var currentUser = OC.getCurrentUser();
+ return this._editCommentTemplate(_.extend({
+ avatarEnabled: this._avatarsEnabled,
+ actorId: currentUser.uid,
+ actorDisplayName: currentUser.displayName,
newMessagePlaceholder: t('comments', 'Type in a new comment...'),
- submitText: t('comments', 'Post')
+ deleteTooltip: t('comments', 'Delete comment'),
+ submitText: t('comments', 'Post'),
+ cancelText: t('comments', 'Cancel')
}, params));
},
@@ -87,7 +116,9 @@
this._commentTemplate = Handlebars.compile(COMMENT_TEMPLATE);
}
return this._commentTemplate(_.extend({
- avatarEnabled: this._avatarsEnabled
+ avatarEnabled: this._avatarsEnabled,
+ editTooltip: t('comments', 'Edit comment'),
+ isUserAuthor: OC.getCurrentUser().uid === params.actorId
}, params));
},
@@ -97,12 +128,14 @@
setFileInfo: function(fileInfo) {
if (fileInfo) {
+ this.model = fileInfo;
this.render();
this.collection.setObjectId(fileInfo.id);
// reset to first page
this.collection.reset([], {silent: true});
this.nextPage();
} else {
+ this.model = null;
this.render();
this.collection.reset();
}
@@ -113,6 +146,7 @@
emptyResultLabel: t('comments', 'No other comments available'),
moreLabel: t('comments', 'More comments...')
}));
+ this.$el.find('.comments').before(this.editCommentTemplate({}));
this.$el.find('.has-tooltip').tooltip();
this.$container = this.$el.find('ul.comments');
this.$el.find('.avatar').avatar(OC.getCurrentUser().uid, 28);
@@ -134,15 +168,36 @@
this.$el.find('.loading').toggleClass('hidden', !state);
},
- _onRequest: function() {
- this._toggleLoading(true);
- this.$el.find('.showMore').addClass('hidden');
+ _onRequest: function(type) {
+ if (type === 'REPORT') {
+ this._toggleLoading(true);
+ this.$el.find('.showMore').addClass('hidden');
+ }
},
- _onEndRequest: function() {
+ _onEndRequest: function(type) {
+ var fileInfoModel = this.model;
this._toggleLoading(false);
this.$el.find('.empty').toggleClass('hidden', !!this.collection.length);
this.$el.find('.showMore').toggleClass('hidden', !this.collection.hasMoreResults());
+
+ if (type !== 'REPORT') {
+ return;
+ }
+
+ // find first unread comment
+ var firstUnreadComment = this.collection.findWhere({isUnread: true});
+ if (firstUnreadComment) {
+ // update read marker
+ this.collection.updateReadMarker(
+ null,
+ {
+ success: function() {
+ fileInfoModel.set('commentsUnread', 0);
+ }
+ }
+ );
+ }
},
_onAddModel: function(model, collection, options) {
@@ -182,13 +237,69 @@
this.collection.fetchNext();
},
+ _onClickEditComment: function(ev) {
+ ev.preventDefault();
+ var $comment = $(ev.target).closest('.comment');
+ var commentId = $comment.data('id');
+ var commentToEdit = this.collection.get(commentId);
+ var $formRow = $(this.editCommentTemplate(_.extend({
+ isEditMode: true,
+ submitText: t('comments', 'Save')
+ }, commentToEdit.attributes)));
+
+ $comment.addClass('hidden');
+ // spawn form
+ $comment.after($formRow);
+ $formRow.data('commentEl', $comment);
+
+ // copy avatar element from original to avoid flickering
+ $formRow.find('.avatar').replaceWith($comment.find('.avatar').clone());
+ $formRow.find('.has-tooltip').tooltip();
+
+ return false;
+ },
+
+ _onClickCloseComment: function(ev) {
+ ev.preventDefault();
+ var $row = $(ev.target).closest('.comment');
+ $row.data('commentEl').removeClass('hidden');
+ $row.remove();
+ return false;
+ },
+
+ _onClickDeleteComment: function(ev) {
+ ev.preventDefault();
+ var $comment = $(ev.target).closest('.comment');
+ var commentId = $comment.data('id');
+ var $loading = $comment.find('.submitLoading');
+
+ $comment.addClass('disabled');
+ $loading.removeClass('hidden');
+ this.collection.get(commentId).destroy({
+ success: function() {
+ $comment.data('commentEl').remove();
+ $comment.remove();
+ },
+ error: function(msg) {
+ $loading.addClass('hidden');
+ $comment.removeClass('disabled');
+ OC.Notification.showTemporary(msg);
+ }
+ });
+
+
+ return false;
+ },
+
_onClickShowMore: function(ev) {
ev.preventDefault();
this.nextPage();
},
_onSubmitComment: function(e) {
+ var self = this;
var $form = $(e.target);
+ var commentId = $form.closest('.comment').data('id');
var currentUser = OC.getCurrentUser();
var $submit = $form.find('.submit');
var $loading = $form.find('.submitLoading');
@@ -204,28 +315,56 @@
$submit.addClass('hidden');
$loading.removeClass('hidden');
- this.collection.create({
- actorId: currentUser.uid,
- actorDisplayName: currentUser.displayName,
- actorType: 'users',
- verb: 'comment',
- message: $textArea.val(),
- creationDateTime: (new Date()).getTime()
- }, {
- at: 0,
- success: function() {
- $submit.removeClass('hidden');
- $loading.addClass('hidden');
- $textArea.val('').prop('disabled', false);
- },
- error: function(msg) {
- $submit.removeClass('hidden');
- $loading.addClass('hidden');
- $textArea.prop('disabled', false);
+ if (commentId) {
+ // edit mode
+ var comment = this.collection.get(commentId);
+ comment.save({
+ message: $textArea.val()
+ }, {
+ success: function(model) {
+ var $row = $form.closest('.comment');
+ $submit.removeClass('hidden');
+ $loading.addClass('hidden');
+ $row.data('commentEl')
+ .removeClass('hidden')
+ .find('.message')
+ .html(self._formatMessage(model.get('message')));
+ $row.remove();
+ },
+ error: function(msg) {
+ $submit.removeClass('hidden');
+ $loading.addClass('hidden');
+ $textArea.prop('disabled', false);
- OC.Notification.showTemporary(msg);
- }
- });
+ OC.Notification.showTemporary(msg);
+ }
+ });
+ } else {
+ this.collection.create({
+ actorId: currentUser.uid,
+ actorDisplayName: currentUser.displayName,
+ actorType: 'users',
+ verb: 'comment',
+ message: $textArea.val(),
+ creationDateTime: (new Date()).toUTCString()
+ }, {
+ at: 0,
+ // wait for real creation before adding
+ wait: true,
+ success: function() {
+ $submit.removeClass('hidden');
+ $loading.addClass('hidden');
+ $textArea.val('').prop('disabled', false);
+ },
+ error: function(msg) {
+ $submit.removeClass('hidden');
+ $loading.addClass('hidden');
+ $textArea.prop('disabled', false);
+
+ OC.Notification.showTemporary(msg);
+ }
+ });
+ }
return false;
}
diff --git a/apps/comments/js/commentsummarymodel.js b/apps/comments/js/commentsummarymodel.js
new file mode 100644
index 00000000000..d405315ca1f
--- /dev/null
+++ b/apps/comments/js/commentsummarymodel.js
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2016
+ *
+ * This file is licensed under the Affero General Public License version 3
+ * or later.
+ *
+ * See the COPYING-README file.
+ *
+ */
+
+(function(OC, OCA) {
+ var NS_OWNCLOUD = 'http://owncloud.org/ns';
+ /**
+ * @class OCA.Comments.CommentSummaryModel
+ * @classdesc
+ *
+ * Model containing summary information related to comments
+ * like the read marker.
+ *
+ */
+ var CommentSummaryModel = OC.Backbone.Model.extend(
+ /** @lends OCA.Comments.CommentSummaryModel.prototype */ {
+ sync: OC.Backbone.davSync,
+
+ /**
+ * Object type
+ *
+ * @type string
+ */
+ _objectType: 'files',
+
+ /**
+ * Object id
+ *
+ * @type string
+ */
+ _objectId: null,
+
+ davProperties: {
+ 'readMarker': '{' + NS_OWNCLOUD + '}readMarker'
+ },
+
+ /**
+ * Initializes the summary model
+ *
+ * @param {string} [options.objectType] object type
+ * @param {string} [options.objectId] object id
+ */
+ initialize: function(attrs, options) {
+ options = options || {};
+ if (options.objectType) {
+ this._objectType = options.objectType;
+ }
+ },
+
+ url: function() {
+ return OC.linkToRemote('dav') + '/comments/' +
+ encodeURIComponent(this._objectType) + '/' +
+ encodeURIComponent(this.id) + '/';
+ }
+ });
+
+ OCA.Comments.CommentSummaryModel = CommentSummaryModel;
+})(OC, OCA);
+
diff --git a/apps/comments/js/filesplugin.js b/apps/comments/js/filesplugin.js
index c8d91e0ede3..bf6bb05146b 100644
--- a/apps/comments/js/filesplugin.js
+++ b/apps/comments/js/filesplugin.js
@@ -8,7 +8,15 @@
*
*/
+/* global Handlebars */
+
(function() {
+ var TEMPLATE_COMMENTS_UNREAD =
+ '<a class="action action-comment permanent" title="{{countMessage}}" href="#">' +
+ '<img class="svg" src="{{iconUrl}}"/>' +
+ '{{count}}' +
+ '</a>';
+
OCA.Comments = _.extend({}, OCA.Comments);
if (!OCA.Comments) {
/**
@@ -26,12 +34,88 @@
'favorites'
],
+ _formatCommentCount: function(count) {
+ if (!this._commentsUnreadTemplate) {
+ this._commentsUnreadTemplate = Handlebars.compile(TEMPLATE_COMMENTS_UNREAD);
+ }
+ return this._commentsUnreadTemplate({
+ count: count,
+ countMessage: t('comments', '{count} unread comments', {count: count}),
+ iconUrl: OC.imagePath('core', 'actions/comment')
+ });
+ },
+
attach: function(fileList) {
+ var self = this;
if (this.allowedLists.indexOf(fileList.id) < 0) {
return;
}
fileList.registerTabView(new OCA.Comments.CommentsTabView('commentsTabView'));
+
+ var NS_OC = 'http://owncloud.org/ns';
+
+ var oldGetWebdavProperties = fileList._getWebdavProperties;
+ fileList._getWebdavProperties = function() {
+ var props = oldGetWebdavProperties.apply(this, arguments);
+ props.push('{' + NS_OC + '}comments-unread');
+ return props;
+ };
+
+ fileList.filesClient.addFileInfoParser(function(response) {
+ var data = {};
+ var props = response.propStat[0].properties;
+ var commentsUnread = props['{' + NS_OC + '}comments-unread'];
+ if (!_.isUndefined(commentsUnread) && commentsUnread !== '') {
+ data.commentsUnread = parseInt(commentsUnread, 10);
+ }
+ return data;
+ });
+
+ fileList.$el.addClass('has-comments');
+ var oldCreateRow = fileList._createRow;
+ fileList._createRow = function(fileData) {
+ var $tr = oldCreateRow.apply(this, arguments);
+ if (fileData.commentsUnread) {
+ $tr.attr('data-comments-unread', fileData.commentsUnread);
+ }
+ return $tr;
+ };
+
+ // register "comment" action for reading comments
+ fileList.fileActions.registerAction({
+ name: 'Comment',
+ displayName: t('comments', 'Comment'),
+ mime: 'all',
+ permissions: OC.PERMISSION_READ,
+ type: OCA.Files.FileActions.TYPE_INLINE,
+ render: function(actionSpec, isDefault, context) {
+ var $file = context.$file;
+ var unreadComments = $file.data('comments-unread');
+ if (unreadComments) {
+ var $actionLink = $(self._formatCommentCount(unreadComments));
+ context.$file.find('a.name>span.fileactions').append($actionLink);
+ return $actionLink;
+ }
+ return '';
+ },
+ actionHandler: function(fileName, context) {
+ context.$file.find('.action-comment').tooltip('hide');
+ // open sidebar in comments section
+ context.fileList.showDetailsView(fileName, 'commentsTabView');
+ }
+ });
+
+ // add attribute to "elementToFile"
+ var oldElementToFile = fileList.elementToFile;
+ fileList.elementToFile = function($el) {
+ var fileInfo = oldElementToFile.apply(this, arguments);
+ var commentsUnread = $el.data('comments-unread');
+ if (commentsUnread) {
+ fileInfo.commentsUnread = commentsUnread;
+ }
+ return fileInfo;
+ };
}
};
diff --git a/apps/comments/tests/js/commentscollectionSpec.js b/apps/comments/tests/js/commentscollectionSpec.js
index 0dc68cc167c..2f41a272f67 100644
--- a/apps/comments/tests/js/commentscollectionSpec.js
+++ b/apps/comments/tests/js/commentscollectionSpec.js
@@ -100,5 +100,49 @@ describe('OCA.Comments.CommentCollection', function() {
expect(collection.hasMoreResults()).toEqual(true);
});
+ describe('resetting read marker', function() {
+ var updateStub;
+ var clock;
+
+ beforeEach(function() {
+ updateStub = sinon.stub(OCA.Comments.CommentSummaryModel.prototype, 'save');
+ clock = sinon.useFakeTimers(Date.UTC(2016, 1, 3, 10, 5, 9));
+ });
+ afterEach(function() {
+ updateStub.restore();
+ clock.restore();
+ });
+
+ it('resets read marker to the default date', function() {
+ var successStub = sinon.stub();
+ collection.updateReadMarker(null, {
+ success: successStub
+ });
+
+ expect(updateStub.calledOnce).toEqual(true);
+ expect(updateStub.lastCall.args[0]).toEqual({
+ readMarker: new Date(Date.UTC(2016, 1, 3, 10, 5, 9)).toUTCString()
+ });
+
+ updateStub.yieldTo('success');
+
+ expect(successStub.calledOnce).toEqual(true);
+ });
+ it('resets read marker to the given date', function() {
+ var successStub = sinon.stub();
+ collection.updateReadMarker(new Date(Date.UTC(2016, 1, 2, 3, 4, 5)), {
+ success: successStub
+ });
+
+ expect(updateStub.calledOnce).toEqual(true);
+ expect(updateStub.lastCall.args[0]).toEqual({
+ readMarker: new Date(Date.UTC(2016, 1, 2, 3, 4, 5)).toUTCString()
+ });
+
+ updateStub.yieldTo('success');
+
+ expect(successStub.calledOnce).toEqual(true);
+ });
+ });
});
diff --git a/apps/comments/tests/js/commentstabviewSpec.js b/apps/comments/tests/js/commentstabviewSpec.js
index 0fb5eec0653..4c3d38290ba 100644
--- a/apps/comments/tests/js/commentstabviewSpec.js
+++ b/apps/comments/tests/js/commentstabviewSpec.js
@@ -48,7 +48,7 @@ describe('OCA.Comments.CommentsTabView tests', function() {
objectType: 'files',
objectId: 5,
message: 'First',
- creationDateTime: Date.UTC(2016, 1, 3, 10, 5, 0)
+ creationDateTime: new Date(Date.UTC(2016, 1, 3, 10, 5, 0)).toUTCString()
});
var comment2 = new OCA.Comments.CommentModel({
id: 2,
@@ -58,7 +58,7 @@ describe('OCA.Comments.CommentsTabView tests', function() {
objectType: 'files',
objectId: 5,
message: 'Second\nNewline',
- creationDateTime: Date.UTC(2016, 1, 3, 10, 0, 0)
+ creationDateTime: new Date(Date.UTC(2016, 1, 3, 10, 0, 0)).toUTCString()
});
testComments = [comment1, comment2];
@@ -142,7 +142,7 @@ describe('OCA.Comments.CommentsTabView tests', function() {
objectType: 'files',
objectId: 5,
message: 'Third',
- creationDateTime: Date.UTC(2016, 1, 3, 5, 0, 0)
+ creationDateTime: new Date(Date.UTC(2016, 1, 3, 5, 0, 0)).toUTCString()
});
view.collection.add(comment3);
@@ -184,7 +184,7 @@ describe('OCA.Comments.CommentsTabView tests', function() {
actorType: 'users',
verb: 'comment',
message: 'New message',
- creationDateTime: Date.UTC(2016, 1, 3, 10, 5, 9)
+ creationDateTime: new Date(Date.UTC(2016, 1, 3, 10, 5, 9)).toUTCString()
});
});
it('does not create a comment if the field is empty', function() {
@@ -195,4 +195,172 @@ describe('OCA.Comments.CommentsTabView tests', function() {
});
});
+ describe('editing comments', function() {
+ var saveStub;
+ var currentUserStub;
+
+ beforeEach(function() {
+ saveStub = sinon.stub(OCA.Comments.CommentModel.prototype, 'save');
+ currentUserStub = sinon.stub(OC, 'getCurrentUser');
+ currentUserStub.returns({
+ uid: 'testuser',
+ displayName: 'Test User'
+ });
+ view.collection.add({
+ id: 1,
+ actorId: 'testuser',
+ actorDisplayName: 'Test User',
+ actorType: 'users',
+ verb: 'comment',
+ message: 'New message',
+ creationDateTime: new Date(Date.UTC(2016, 1, 3, 10, 5, 9)).toUTCString()
+ });
+ view.collection.add({
+ id: 2,
+ actorId: 'anotheruser',
+ actorDisplayName: 'Another User',
+ actorType: 'users',
+ verb: 'comment',
+ message: 'New message from another user',
+ creationDateTime: new Date(Date.UTC(2016, 1, 3, 10, 5, 9)).toUTCString()
+ });
+ });
+ afterEach(function() {
+ saveStub.restore();
+ currentUserStub.restore();
+ });
+
+ it('shows edit link for owner comments', function() {
+ var $comment = view.$el.find('.comment[data-id=1]');
+ expect($comment.length).toEqual(1);
+ expect($comment.find('.action.edit').length).toEqual(1);
+ });
+
+ it('does not show edit link for other user\'s comments', function() {
+ var $comment = view.$el.find('.comment[data-id=2]');
+ expect($comment.length).toEqual(1);
+ expect($comment.find('.action.edit').length).toEqual(0);
+ });
+
+ it('shows edit form when clicking edit', function() {
+ var $comment = view.$el.find('.comment[data-id=1]');
+ $comment.find('.action.edit').click();
+
+ expect($comment.hasClass('hidden')).toEqual(true);
+ var $formRow = view.$el.find('.newCommentRow.comment[data-id=1]');
+ expect($formRow.length).toEqual(1);
+ });
+
+ it('saves message and updates comment item when clicking save', function() {
+ var $comment = view.$el.find('.comment[data-id=1]');
+ $comment.find('.action.edit').click();
+
+ var $formRow = view.$el.find('.newCommentRow.comment[data-id=1]');
+ expect($formRow.length).toEqual(1);
+
+ $formRow.find('textarea').val('modified\nmessage');
+ $formRow.find('form').submit();
+
+ expect(saveStub.calledOnce).toEqual(true);
+ expect(saveStub.lastCall.args[0]).toEqual({
+ message: 'modified\nmessage'
+ });
+
+ var model = view.collection.get(1);
+ // simulate the fact that save sets the attribute
+ model.set('message', 'modified\nmessage');
+ saveStub.yieldTo('success', model);
+
+ // original comment element is visible again
+ expect($comment.hasClass('hidden')).toEqual(false);
+ // and its message was updated
+ expect($comment.find('.message').html()).toEqual('modified<br>message');
+
+ // form row is gone
+ $formRow = view.$el.find('.newCommentRow.comment[data-id=1]');
+ expect($formRow.length).toEqual(0);
+ });
+
+ it('restores original comment when cancelling', function() {
+ var $comment = view.$el.find('.comment[data-id=1]');
+ $comment.find('.action.edit').click();
+
+ var $formRow = view.$el.find('.newCommentRow.comment[data-id=1]');
+ expect($formRow.length).toEqual(1);
+
+ $formRow.find('textarea').val('modified\nmessage');
+ $formRow.find('.cancel').click();
+
+ expect(saveStub.notCalled).toEqual(true);
+
+ // original comment element is visible again
+ expect($comment.hasClass('hidden')).toEqual(false);
+ // and its message was not updated
+ expect($comment.find('.message').html()).toEqual('New message');
+
+ // form row is gone
+ $formRow = view.$el.find('.newCommentRow.comment[data-id=1]');
+ expect($formRow.length).toEqual(0);
+ });
+
+ it('destroys model when clicking delete', function() {
+ var destroyStub = sinon.stub(OCA.Comments.CommentModel.prototype, 'destroy');
+ var $comment = view.$el.find('.comment[data-id=1]');
+ $comment.find('.action.edit').click();
+
+ var $formRow = view.$el.find('.newCommentRow.comment[data-id=1]');
+ expect($formRow.length).toEqual(1);
+
+ $formRow.find('.delete').click();
+
+ expect(destroyStub.calledOnce).toEqual(true);
+ expect(destroyStub.thisValues[0].id).toEqual(1);
+
+ destroyStub.yieldTo('success');
+
+ // original comment element is gone
+ $comment = view.$el.find('.comment[data-id=1]');
+ expect($comment.length).toEqual(0);
+
+ // form row is gone
+ $formRow = view.$el.find('.newCommentRow.comment[data-id=1]');
+ expect($formRow.length).toEqual(0);
+
+ destroyStub.restore();
+ });
+ });
+ describe('read marker', function() {
+ var updateMarkerStub;
+
+ beforeEach(function() {
+ updateMarkerStub = sinon.stub(OCA.Comments.CommentCollection.prototype, 'updateReadMarker');
+ });
+ afterEach(function() {
+ updateMarkerStub.restore();
+ });
+
+ it('resets the read marker after REPORT', function() {
+ testComments[0].set('isUnread', true, {silent: true});
+ testComments[1].set('isUnread', true, {silent: true});
+ view.collection.set(testComments);
+ view.collection.trigger('sync', 'REPORT');
+
+ expect(updateMarkerStub.calledOnce).toEqual(true);
+ expect(updateMarkerStub.lastCall.args[0]).toBeFalsy();
+ });
+ it('does not reset the read marker if there was no unread comments', function() {
+ view.collection.set(testComments);
+ view.collection.trigger('sync', 'REPORT');
+
+ expect(updateMarkerStub.notCalled).toEqual(true);
+ });
+ it('does not reset the read marker when posting comments', function() {
+ testComments[0].set('isUnread', true, {silent: true});
+ testComments[1].set('isUnread', true, {silent: true});
+ view.collection.set(testComments);
+ view.collection.trigger('sync', 'POST');
+
+ expect(updateMarkerStub.notCalled).toEqual(true);
+ });
+ });
});
diff --git a/apps/comments/tests/js/filespluginSpec.js b/apps/comments/tests/js/filespluginSpec.js
new file mode 100644
index 00000000000..78becc5af09
--- /dev/null
+++ b/apps/comments/tests/js/filespluginSpec.js
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2016 Vincent Petry <pvince81@owncloud.com>
+ *
+ * This file is licensed under the Affero General Public License version 3
+ * or later.
+ *
+ * See the COPYING-README file.
+ *
+ */
+
+describe('OCA.Comments.FilesPlugin tests', function() {
+ var fileList;
+ var testFiles;
+
+ beforeEach(function() {
+ var $content = $('<div id="content"></div>');
+ $('#testArea').append($content);
+ // dummy file list
+ var $div = $(
+ '<div>' +
+ '<table id="filestable">' +
+ '<thead></thead>' +
+ '<tbody id="fileList"></tbody>' +
+ '</table>' +
+ '</div>');
+ $('#content').append($div);
+
+ fileList = new OCA.Files.FileList($div);
+ OCA.Comments.FilesPlugin.attach(fileList);
+
+ testFiles = [{
+ id: 1,
+ type: 'file',
+ name: 'One.txt',
+ path: '/subdir',
+ mimetype: 'text/plain',
+ size: 12,
+ permissions: OC.PERMISSION_ALL,
+ etag: 'abc',
+ shareOwner: 'User One',
+ isShareMountPoint: false,
+ commentsUnread: 3
+ }];
+ });
+ afterEach(function() {
+ fileList.destroy();
+ fileList = null;
+ });
+
+ describe('Comment icon', function() {
+ it('does not render icon when no unread comments available', function() {
+ testFiles[0].commentsUnread = 0;
+ fileList.setFiles(testFiles);
+ var $tr = fileList.findFileEl('One.txt');
+ expect($tr.find('.action-comment').length).toEqual(0);
+ });
+ it('renders comment icon and extra data', function() {
+ var $action, $tr;
+ fileList.setFiles(testFiles);
+ $tr = fileList.findFileEl('One.txt');
+ $action = $tr.find('.action-comment');
+ expect($action.length).toEqual(1);
+ expect($action.hasClass('permanent')).toEqual(true);
+
+ expect($tr.attr('data-comments-unread')).toEqual('3');
+ });
+ it('clicking icon opens sidebar', function() {
+ var sidebarStub = sinon.stub(fileList, 'showDetailsView');
+ var $action, $tr;
+ fileList.setFiles(testFiles);
+ $tr = fileList.findFileEl('One.txt');
+ $action = $tr.find('.action-comment');
+ $action.click();
+
+ expect(sidebarStub.calledOnce).toEqual(true);
+ expect(sidebarStub.lastCall.args[0]).toEqual('One.txt');
+ expect(sidebarStub.lastCall.args[1]).toEqual('commentsTabView');
+ });
+ });
+ describe('elementToFile', function() {
+ it('returns comment count', function() {
+ fileList.setFiles(testFiles);
+ var $tr = fileList.findFileEl('One.txt');
+ var data = fileList.elementToFile($tr);
+ expect(data.commentsUnread).toEqual(3);
+ });
+ it('does not set comment count when not set', function() {
+ delete testFiles[0].commentsUnread;
+ fileList.setFiles(testFiles);
+ var $tr = fileList.findFileEl('One.txt');
+ var data = fileList.elementToFile($tr);
+ expect(data.commentsUnread).not.toBeDefined();
+ });
+ it('does not set comment count when zero', function() {
+ testFiles[0].commentsUnread = 0;
+ fileList.setFiles(testFiles);
+ var $tr = fileList.findFileEl('One.txt');
+ var data = fileList.elementToFile($tr);
+ expect(data.commentsUnread).not.toBeDefined();
+ });
+ });
+});
diff --git a/apps/dav/appinfo/info.xml b/apps/dav/appinfo/info.xml
index 3a38feab59e..f035d19d862 100644
--- a/apps/dav/appinfo/info.xml
+++ b/apps/dav/appinfo/info.xml
@@ -6,7 +6,6 @@
<licence>AGPL</licence>
<author>owncloud.org</author>
<version>0.1.4</version>
- <standalone/>
<default_enable/>
<types>
<filesystem/>
diff --git a/apps/dav/appinfo/register_command.php b/apps/dav/appinfo/register_command.php
index e8fea5daf23..e8ca370f84f 100644
--- a/apps/dav/appinfo/register_command.php
+++ b/apps/dav/appinfo/register_command.php
@@ -36,7 +36,7 @@ $app = new Application();
/** @var Symfony\Component\Console\Application $application */
$application->add(new CreateAddressBook($userManager, $groupManager, $dbConnection, $logger));
-$application->add(new CreateCalendar($userManager, $dbConnection));
+$application->add(new CreateCalendar($userManager, $groupManager, $dbConnection));
$application->add(new SyncSystemAddressBook($app->getSyncService()));
// the occ tool is *for now* only available in debug mode for developers to test
diff --git a/apps/dav/command/createcalendar.php b/apps/dav/command/createcalendar.php
index 34bc061c45b..d7f82dd0e52 100644
--- a/apps/dav/command/createcalendar.php
+++ b/apps/dav/command/createcalendar.php
@@ -21,7 +21,9 @@
namespace OCA\DAV\Command;
use OCA\DAV\CalDAV\CalDavBackend;
+use OCA\DAV\Connector\Sabre\Principal;
use OCP\IDBConnection;
+use OCP\IGroupManager;
use OCP\IUserManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
@@ -33,6 +35,9 @@ class CreateCalendar extends Command {
/** @var IUserManager */
protected $userManager;
+ /** @var IGroupManager $groupManager */
+ private $groupManager;
+
/** @var \OCP\IDBConnection */
protected $dbConnection;
@@ -40,9 +45,10 @@ class CreateCalendar extends Command {
* @param IUserManager $userManager
* @param IDBConnection $dbConnection
*/
- function __construct(IUserManager $userManager, IDBConnection $dbConnection) {
+ function __construct(IUserManager $userManager, IGroupManager $groupManager, IDBConnection $dbConnection) {
parent::__construct();
$this->userManager = $userManager;
+ $this->groupManager = $groupManager;
$this->dbConnection = $dbConnection;
}
@@ -63,8 +69,13 @@ class CreateCalendar extends Command {
if (!$this->userManager->userExists($user)) {
throw new \InvalidArgumentException("User <$user> in unknown.");
}
+ $principalBackend = new Principal(
+ $this->userManager,
+ $this->groupManager
+ );
+
$name = $input->getArgument('name');
- $caldav = new CalDavBackend($this->dbConnection);
+ $caldav = new CalDavBackend($this->dbConnection, $principalBackend);
$caldav->createCalendar("principals/users/$user", $name, []);
}
}
diff --git a/apps/dav/lib/caldav/caldavbackend.php b/apps/dav/lib/caldav/caldavbackend.php
index 0b70b37967f..3aa493e5087 100644
--- a/apps/dav/lib/caldav/caldavbackend.php
+++ b/apps/dav/lib/caldav/caldavbackend.php
@@ -23,6 +23,8 @@
namespace OCA\DAV\CalDAV;
use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCA\DAV\Connector\Sabre\Principal;
+use OCA\DAV\DAV\Sharing\Backend;
use Sabre\CalDAV\Backend\AbstractBackend;
use Sabre\CalDAV\Backend\SchedulingSupport;
use Sabre\CalDAV\Backend\SubscriptionSupport;
@@ -32,6 +34,7 @@ use Sabre\CalDAV\Xml\Property\ScheduleCalendarTransp;
use Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet;
use Sabre\DAV;
use Sabre\DAV\Exception\Forbidden;
+use Sabre\HTTP\URLUtil;
use Sabre\VObject\DateTimeParser;
use Sabre\VObject\Reader;
use Sabre\VObject\RecurrenceIterator;
@@ -86,8 +89,24 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
'{http://calendarserver.org/ns/}subscribed-strip-attachments' => 'stripattachments',
];
- public function __construct(\OCP\IDBConnection $db) {
+ /** @var \OCP\IDBConnection */
+ private $db;
+
+ /** @var Backend */
+ private $sharingBackend;
+
+ /** @var Principal */
+ private $principalBackend;
+
+ /**
+ * CalDavBackend constructor.
+ *
+ * @param \OCP\IDBConnection $db
+ */
+ public function __construct(\OCP\IDBConnection $db, Principal $principalBackend) {
$this->db = $db;
+ $this->principalBackend = $principalBackend;
+ $this->sharingBackend = new Backend($this->db, 'calendar');
}
/**
@@ -153,10 +172,60 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
$calendar[$xmlName] = $row[$dbName];
}
- $calendars[] = $calendar;
+ $calendars[$calendar['id']] = $calendar;
+ }
+
+ $stmt->closeCursor();
+
+ // query for shared calendars
+ $principals = $this->principalBackend->getGroupMembership($principalUri);
+ $principals[]= $principalUri;
+
+ $fields = array_values($this->propertyMap);
+ $fields[] = 'a.id';
+ $fields[] = 'a.uri';
+ $fields[] = 'a.synctoken';
+ $fields[] = 'a.components';
+ $fields[] = 'a.principaluri';
+ $fields[] = 'a.transparent';
+ $query = $this->db->getQueryBuilder();
+ $result = $query->select($fields)
+ ->from('dav_shares', 's')
+ ->join('s', 'calendars', 'a', $query->expr()->eq('s.resourceid', 'a.id'))
+ ->where($query->expr()->in('s.principaluri', $query->createParameter('principaluri')))
+ ->andWhere($query->expr()->eq('s.type', $query->createParameter('type')))
+ ->setParameter('type', 'calendar')
+ ->setParameter('principaluri', $principals, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY)
+ ->execute();
+
+ while($row = $result->fetch()) {
+ list(, $name) = URLUtil::splitPath($row['principaluri']);
+ $uri = $row['uri'] . '_shared_by_' . $name;
+ $row['displayname'] = $row['displayname'] . "($name)";
+ $components = [];
+ if ($row['components']) {
+ $components = explode(',',$row['components']);
+ }
+ $calendar = [
+ 'id' => $row['id'],
+ 'uri' => $uri,
+ 'principaluri' => $principalUri,
+ '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
+ '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
+ '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
+ '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
+ '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'],
+ ];
+
+ foreach($this->propertyMap as $xmlName=>$dbName) {
+ $calendar[$xmlName] = $row[$dbName];
+ }
+
+ $calendars[$calendar['id']] = $calendar;
}
+ $result->closeCursor();
- return $calendars;
+ return array_values($calendars);
}
/**
@@ -271,6 +340,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
$stmt = $this->db->prepare('DELETE FROM `*PREFIX*calendarchanges` WHERE `calendarid` = ?');
$stmt->execute([$calendarId]);
+
+ $this->sharingBackend->deleteAllShares($calendarId);
}
/**
@@ -1173,4 +1244,17 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
return $cardData;
}
+
+ public function updateShares($shareable, $add, $remove) {
+ $this->sharingBackend->updateShares($shareable, $add, $remove);
+ }
+
+ public function getShares($resourceId) {
+ return $this->sharingBackend->getShares($resourceId);
+ }
+
+ public function applyShareAcl($addressBookId, $acl) {
+ return $this->sharingBackend->applyShareAcl($addressBookId, $acl);
+ }
+
}
diff --git a/apps/dav/lib/caldav/calendar.php b/apps/dav/lib/caldav/calendar.php
new file mode 100644
index 00000000000..8ed5b6563d0
--- /dev/null
+++ b/apps/dav/lib/caldav/calendar.php
@@ -0,0 +1,102 @@
+<?php
+
+namespace OCA\DAV\CalDAV;
+
+use OCA\DAV\DAV\Sharing\IShareable;
+use Sabre\DAV\Exception\Forbidden;
+
+class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
+
+ /**
+ * Updates the list of shares.
+ *
+ * The first array is a list of people that are to be added to the
+ * resource.
+ *
+ * Every element in the add array has the following properties:
+ * * href - A url. Usually a mailto: address
+ * * commonName - Usually a first and last name, or false
+ * * summary - A description of the share, can also be false
+ * * readOnly - A boolean value
+ *
+ * Every element in the remove array is just the address string.
+ *
+ * @param array $add
+ * @param array $remove
+ * @return void
+ */
+ function updateShares(array $add, array $remove) {
+ /** @var CalDavBackend $calDavBackend */
+ $calDavBackend = $this->caldavBackend;
+ $calDavBackend->updateShares($this, $add, $remove);
+ }
+
+ /**
+ * Returns the list of people whom this resource is shared with.
+ *
+ * Every element in this array should have the following properties:
+ * * href - Often a mailto: address
+ * * commonName - Optional, for example a first + last name
+ * * status - See the Sabre\CalDAV\SharingPlugin::STATUS_ constants.
+ * * readOnly - boolean
+ * * summary - Optional, a description for the share
+ *
+ * @return array
+ */
+ function getShares() {
+ /** @var CalDavBackend $calDavBackend */
+ $calDavBackend = $this->caldavBackend;
+ return $calDavBackend->getShares($this->getResourceId());
+ }
+
+ /**
+ * @return int
+ */
+ public function getResourceId() {
+ return $this->calendarInfo['id'];
+ }
+
+ function getACL() {
+ $acl = parent::getACL();
+
+ /** @var CalDavBackend $calDavBackend */
+ $calDavBackend = $this->caldavBackend;
+ return $calDavBackend->applyShareAcl($this->getResourceId(), $acl);
+ }
+
+ function getChildACL() {
+ $acl = parent::getChildACL();
+
+ /** @var CalDavBackend $calDavBackend */
+ $calDavBackend = $this->caldavBackend;
+ return $calDavBackend->applyShareAcl($this->getResourceId(), $acl);
+ }
+
+ function getOwner() {
+ if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) {
+ return $this->calendarInfo['{http://owncloud.org/ns}owner-principal'];
+ }
+ return parent::getOwner();
+ }
+
+ function delete() {
+ if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) {
+ $principal = 'principal:' . parent::getOwner();
+ $shares = $this->getShares();
+ $shares = array_filter($shares, function($share) use ($principal){
+ return $share['href'] === $principal;
+ });
+ if (empty($shares)) {
+ throw new Forbidden();
+ }
+
+ /** @var CalDavBackend $calDavBackend */
+ $calDavBackend = $this->caldavBackend;
+ $calDavBackend->updateShares($this, [], [
+ 'href' => $principal
+ ]);
+ return;
+ }
+ parent::delete();
+ }
+}
diff --git a/apps/dav/lib/caldav/calendarhome.php b/apps/dav/lib/caldav/calendarhome.php
new file mode 100644
index 00000000000..7f98dfb94e0
--- /dev/null
+++ b/apps/dav/lib/caldav/calendarhome.php
@@ -0,0 +1,78 @@
+<?php
+
+namespace OCA\DAV\CalDAV;
+
+use Sabre\CalDAV\Backend\NotificationSupport;
+use Sabre\CalDAV\Backend\SchedulingSupport;
+use Sabre\CalDAV\Backend\SubscriptionSupport;
+use Sabre\CalDAV\Schedule\Inbox;
+use Sabre\CalDAV\Schedule\Outbox;
+use Sabre\CalDAV\Subscriptions\Subscription;
+use Sabre\DAV\Exception\NotFound;
+
+class CalendarHome extends \Sabre\CalDAV\CalendarHome {
+
+ /**
+ * @inheritdoc
+ */
+ function getChildren() {
+ $calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']);
+ $objs = [];
+ foreach ($calendars as $calendar) {
+ $objs[] = new Calendar($this->caldavBackend, $calendar);
+ }
+
+ if ($this->caldavBackend instanceof SchedulingSupport) {
+ $objs[] = new Inbox($this->caldavBackend, $this->principalInfo['uri']);
+ $objs[] = new Outbox($this->principalInfo['uri']);
+ }
+
+ // We're adding a notifications node, if it's supported by the backend.
+ if ($this->caldavBackend instanceof NotificationSupport) {
+ $objs[] = new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
+ }
+
+ // If the backend supports subscriptions, we'll add those as well,
+ if ($this->caldavBackend instanceof SubscriptionSupport) {
+ foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) {
+ $objs[] = new Subscription($this->caldavBackend, $subscription);
+ }
+ }
+
+ return $objs;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ function getChild($name) {
+ // Special nodes
+ if ($name === 'inbox' && $this->caldavBackend instanceof SchedulingSupport) {
+ return new Inbox($this->caldavBackend, $this->principalInfo['uri']);
+ }
+ if ($name === 'outbox' && $this->caldavBackend instanceof SchedulingSupport) {
+ return new Outbox($this->principalInfo['uri']);
+ }
+ if ($name === 'notifications' && $this->caldavBackend instanceof NotificationSupport) {
+ return new \Sabre\CalDAv\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
+ }
+
+ // Calendars
+ foreach ($this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']) as $calendar) {
+ if ($calendar['uri'] === $name) {
+ return new Calendar($this->caldavBackend, $calendar);
+ }
+ }
+
+ if ($this->caldavBackend instanceof SubscriptionSupport) {
+ foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) {
+ if ($subscription['uri'] === $name) {
+ return new Subscription($this->caldavBackend, $subscription);
+ }
+ }
+
+ }
+
+ throw new NotFound('Node with name \'' . $name . '\' could not be found');
+ }
+} \ No newline at end of file
diff --git a/apps/dav/lib/caldav/calendarroot.php b/apps/dav/lib/caldav/calendarroot.php
new file mode 100644
index 00000000000..ae5fc54cdf3
--- /dev/null
+++ b/apps/dav/lib/caldav/calendarroot.php
@@ -0,0 +1,10 @@
+<?php
+
+namespace OCA\DAV\CalDAV;
+
+class CalendarRoot extends \Sabre\CalDAV\CalendarRoot {
+
+ function getChildForPrincipal(array $principal) {
+ return new CalendarHome($this->caldavBackend, $principal);
+ }
+} \ No newline at end of file
diff --git a/apps/dav/lib/carddav/addressbook.php b/apps/dav/lib/carddav/addressbook.php
index 513eae4d723..ca3f5ba0ef6 100644
--- a/apps/dav/lib/carddav/addressbook.php
+++ b/apps/dav/lib/carddav/addressbook.php
@@ -21,6 +21,7 @@
namespace OCA\DAV\CardDAV;
use OCA\DAV\DAV\Sharing\IShareable;
+use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\Exception\NotFound;
class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable {
@@ -132,4 +133,32 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable {
public function getResourceId() {
return $this->addressBookInfo['id'];
}
+
+ function getOwner() {
+ if (isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) {
+ return $this->addressBookInfo['{http://owncloud.org/ns}owner-principal'];
+ }
+ return parent::getOwner();
+ }
+
+ function delete() {
+ if (isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) {
+ $principal = 'principal:' . parent::getOwner();
+ $shares = $this->getShares();
+ $shares = array_filter($shares, function($share) use ($principal){
+ return $share['href'] === $principal;
+ });
+ if (empty($shares)) {
+ throw new Forbidden();
+ }
+
+ /** @var CardDavBackend $cardDavBackend */
+ $cardDavBackend = $this->carddavBackend;
+ $cardDavBackend->updateShares($this, [], [
+ 'href' => $principal
+ ]);
+ return;
+ }
+ parent::delete();
+ }
}
diff --git a/apps/dav/lib/carddav/carddavbackend.php b/apps/dav/lib/carddav/carddavbackend.php
index 3dc5c00e10b..9ca166c22a2 100644
--- a/apps/dav/lib/carddav/carddavbackend.php
+++ b/apps/dav/lib/carddav/carddavbackend.php
@@ -103,7 +103,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$result = $query->execute();
while($row = $result->fetch()) {
- $addressBooks[] = [
+ $addressBooks[$row['id']] = [
'id' => $row['id'],
'uri' => $row['uri'],
'principaluri' => $row['principaluri'],
@@ -133,7 +133,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
list(, $name) = URLUtil::splitPath($row['principaluri']);
$uri = $row['uri'] . '_shared_by_' . $name;
$displayName = $row['displayname'] . "($name)";
- $addressBooks[] = [
+ $addressBooks[$row['id']] = [
'id' => $row['id'],
'uri' => $uri,
'principaluri' => $principalUri,
@@ -147,7 +147,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
}
$result->closeCursor();
- return $addressBooks;
+ return array_values($addressBooks);
}
/**
@@ -336,10 +336,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
->setParameter('id', $addressBookId)
->execute();
- $query->delete('dav_shares')
- ->where($query->expr()->eq('resourceid', $query->createNamedParameter($addressBookId)))
- ->andWhere($query->expr()->eq('type', $query->createNamedParameter('addressbook')))
- ->execute();
+ $this->sharingBackend->deleteAllShares($addressBookId);
$query->delete($this->dbCardsPropertiesTable)
->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)))
@@ -920,22 +917,6 @@ class CardDavBackend implements BackendInterface, SyncSupport {
* @return array
*/
public function applyShareAcl($addressBookId, $acl) {
-
- $shares = $this->getShares($addressBookId);
- foreach ($shares as $share) {
- $acl[] = [
- 'privilege' => '{DAV:}read',
- 'principal' => $share['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}principal'],
- 'protected' => true,
- ];
- if (!$share['readOnly']) {
- $acl[] = [
- 'privilege' => '{DAV:}write',
- 'principal' => $share['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}principal'],
- 'protected' => true,
- ];
- }
- }
- return $acl;
+ return $this->sharingBackend->applyShareAcl($addressBookId, $acl);
}
}
diff --git a/apps/dav/lib/dav/sharing/backend.php b/apps/dav/lib/dav/sharing/backend.php
index fee864ffe6f..0b28891fbc4 100644
--- a/apps/dav/lib/dav/sharing/backend.php
+++ b/apps/dav/lib/dav/sharing/backend.php
@@ -58,7 +58,7 @@ class Backend {
$this->shareWith($shareable, $element);
}
foreach($remove as $element) {
- $this->unshare($shareable->getResourceId(), $element);
+ $this->unshare($shareable, $element);
}
}
@@ -73,8 +73,13 @@ class Backend {
return;
}
+ // don't share with owner
+ if ($shareable->getOwner() === $parts[1]) {
+ return;
+ }
+
// remove the share if it already exists
- $this->unshare($shareable->getResourceId(), $element['href']);
+ $this->unshare($shareable, $element['href']);
$access = self::ACCESS_READ;
if (isset($element['readOnly'])) {
$access = $element['readOnly'] ? self::ACCESS_READ : self::ACCESS_READ_WRITE;
@@ -92,18 +97,34 @@ class Backend {
}
/**
- * @param int $resourceId
+ * @param $resourceId
+ */
+ public function deleteAllShares($resourceId) {
+ $query = $this->db->getQueryBuilder();
+ $query->delete('dav_shares')
+ ->where($query->expr()->eq('resourceid', $query->createNamedParameter($resourceId)))
+ ->andWhere($query->expr()->eq('type', $query->createNamedParameter($this->resourceType)))
+ ->execute();
+ }
+
+ /**
+ * @param IShareable $shareable
* @param string $element
*/
- private function unshare($resourceId, $element) {
+ private function unshare($shareable, $element) {
$parts = explode(':', $element, 2);
if ($parts[0] !== 'principal') {
return;
}
+ // don't share with owner
+ if ($shareable->getOwner() === $parts[1]) {
+ return;
+ }
+
$query = $this->db->getQueryBuilder();
$query->delete('dav_shares')
- ->where($query->expr()->eq('resourceid', $query->createNamedParameter($resourceId)))
+ ->where($query->expr()->eq('resourceid', $query->createNamedParameter($shareable->getResourceId())))
->andWhere($query->expr()->eq('type', $query->createNamedParameter($this->resourceType)))
->andWhere($query->expr()->eq('principaluri', $query->createNamedParameter($parts[1])))
;
@@ -136,7 +157,7 @@ class Backend {
'href' => "principal:${row['principaluri']}",
// 'commonName' => isset($p['{DAV:}displayname']) ? $p['{DAV:}displayname'] : '',
'status' => 1,
- 'readOnly' => ($row['access'] === self::ACCESS_READ),
+ 'readOnly' => ($row['access'] == self::ACCESS_READ),
'{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}principal' => $row['principaluri']
];
}
diff --git a/apps/dav/lib/dav/sharing/plugin.php b/apps/dav/lib/dav/sharing/plugin.php
index cbb4408e29b..f6e2cceebd9 100644
--- a/apps/dav/lib/dav/sharing/plugin.php
+++ b/apps/dav/lib/dav/sharing/plugin.php
@@ -23,9 +23,12 @@
namespace OCA\DAV\DAV\Sharing;
use OCA\DAV\Connector\Sabre\Auth;
+use OCA\DAV\DAV\Sharing\Xml\Invite;
use OCP\IRequest;
use Sabre\DAV\Exception\BadRequest;
use Sabre\DAV\Exception\NotFound;
+use Sabre\DAV\INode;
+use Sabre\DAV\PropFind;
use Sabre\DAV\Server;
use Sabre\DAV\ServerPlugin;
use Sabre\HTTP\RequestInterface;
@@ -97,8 +100,10 @@ class Plugin extends ServerPlugin {
function initialize(Server $server) {
$this->server = $server;
$this->server->xml->elementMap['{' . Plugin::NS_OWNCLOUD . '}share'] = 'OCA\\DAV\\DAV\\Sharing\\Xml\\ShareRequest';
+ $this->server->xml->elementMap['{' . Plugin::NS_OWNCLOUD . '}invite'] = 'OCA\\DAV\\DAV\\Sharing\\Xml\\Invite';
$this->server->on('method:POST', [$this, 'httpPost']);
+ $this->server->on('propFind', [$this, 'propFind']);
}
/**
@@ -174,6 +179,28 @@ class Plugin extends ServerPlugin {
}
}
+ /**
+ * This event is triggered when properties are requested for a certain
+ * node.
+ *
+ * This allows us to inject any properties early.
+ *
+ * @param PropFind $propFind
+ * @param INode $node
+ * @return void
+ */
+ function propFind(PropFind $propFind, INode $node) {
+ if ($node instanceof IShareable) {
+
+ $propFind->handle('{' . Plugin::NS_OWNCLOUD . '}invite', function() use ($node) {
+ return new Invite(
+ $node->getShares()
+ );
+ });
+
+ }
+ }
+
private function protectAgainstCSRF() {
$user = $this->auth->getCurrentUser();
if ($this->auth->isDavAuthenticated($user)) {
diff --git a/apps/dav/lib/dav/sharing/xml/invite.php b/apps/dav/lib/dav/sharing/xml/invite.php
new file mode 100644
index 00000000000..659f95d8074
--- /dev/null
+++ b/apps/dav/lib/dav/sharing/xml/invite.php
@@ -0,0 +1,149 @@
+<?php
+
+namespace OCA\DAV\DAV\Sharing\Xml;
+
+use OCA\DAV\DAV\Sharing\Plugin;
+use Sabre\Xml\Writer;
+use Sabre\Xml\XmlSerializable;
+
+/**
+ * Invite property
+ *
+ * This property encodes the 'invite' property, as defined by
+ * the 'caldav-sharing-02' spec, in the http://calendarserver.org/ns/
+ * namespace.
+ *
+ * @see https://trac.calendarserver.org/browser/CalendarServer/trunk/doc/Extensions/caldav-sharing-02.txt
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class Invite implements XmlSerializable {
+
+ /**
+ * The list of users a calendar has been shared to.
+ *
+ * @var array
+ */
+ protected $users;
+
+ /**
+ * The organizer contains information about the person who shared the
+ * object.
+ *
+ * @var array
+ */
+ protected $organizer;
+
+ /**
+ * Creates the property.
+ *
+ * Users is an array. Each element of the array has the following
+ * properties:
+ *
+ * * href - Often a mailto: address
+ * * commonName - Optional, for example a first and lastname for a user.
+ * * status - One of the SharingPlugin::STATUS_* constants.
+ * * readOnly - true or false
+ * * summary - Optional, description of the share
+ *
+ * The organizer key is optional to specify. It's only useful when a
+ * 'sharee' requests the sharing information.
+ *
+ * The organizer may have the following properties:
+ * * href - Often a mailto: address.
+ * * commonName - Optional human-readable name.
+ * * firstName - Optional first name.
+ * * lastName - Optional last name.
+ *
+ * If you wonder why these two structures are so different, I guess a
+ * valid answer is that the current spec is still a draft.
+ *
+ * @param array $users
+ */
+ function __construct(array $users, array $organizer = null) {
+
+ $this->users = $users;
+ $this->organizer = $organizer;
+
+ }
+
+ /**
+ * Returns the list of users, as it was passed to the constructor.
+ *
+ * @return array
+ */
+ function getValue() {
+
+ return $this->users;
+
+ }
+
+ /**
+ * The xmlSerialize metod is called during xml writing.
+ *
+ * Use the $writer argument to write its own xml serialization.
+ *
+ * An important note: do _not_ create a parent element. Any element
+ * implementing XmlSerializble should only ever write what's considered
+ * its 'inner xml'.
+ *
+ * The parent of the current element is responsible for writing a
+ * containing element.
+ *
+ * This allows serializers to be re-used for different element names.
+ *
+ * If you are opening new elements, you must also close them again.
+ *
+ * @param Writer $writer
+ * @return void
+ */
+ function xmlSerialize(Writer $writer) {
+
+ $cs = '{' . Plugin::NS_OWNCLOUD . '}';
+
+ if (!is_null($this->organizer)) {
+
+ $writer->startElement($cs . 'organizer');
+ $writer->writeElement('{DAV:}href', $this->organizer['href']);
+
+ if (isset($this->organizer['commonName']) && $this->organizer['commonName']) {
+ $writer->writeElement($cs . 'common-name', $this->organizer['commonName']);
+ }
+ if (isset($this->organizer['firstName']) && $this->organizer['firstName']) {
+ $writer->writeElement($cs . 'first-name', $this->organizer['firstName']);
+ }
+ if (isset($this->organizer['lastName']) && $this->organizer['lastName']) {
+ $writer->writeElement($cs . 'last-name', $this->organizer['lastName']);
+ }
+ $writer->endElement(); // organizer
+
+ }
+
+ foreach ($this->users as $user) {
+
+ $writer->startElement($cs . 'user');
+ $writer->writeElement('{DAV:}href', $user['href']);
+ if (isset($user['commonName']) && $user['commonName']) {
+ $writer->writeElement($cs . 'common-name', $user['commonName']);
+ }
+ $writer->writeElement($cs . 'invite-accepted');
+
+ $writer->startElement($cs . 'access');
+ if ($user['readOnly']) {
+ $writer->writeElement($cs . 'read');
+ } else {
+ $writer->writeElement($cs . 'read-write');
+ }
+ $writer->endElement(); // access
+
+ if (isset($user['summary']) && $user['summary']) {
+ $writer->writeElement($cs . 'summary', $user['summary']);
+ }
+
+ $writer->endElement(); //user
+
+ }
+
+ }
+}
diff --git a/apps/dav/lib/rootcollection.php b/apps/dav/lib/rootcollection.php
index 5be469e7b0c..2a8f63a2270 100644
--- a/apps/dav/lib/rootcollection.php
+++ b/apps/dav/lib/rootcollection.php
@@ -22,12 +22,12 @@
namespace OCA\DAV;
use OCA\DAV\CalDAV\CalDavBackend;
+use OCA\DAV\CalDAV\CalendarRoot;
use OCA\DAV\CardDAV\AddressBookRoot;
use OCA\DAV\CardDAV\CardDavBackend;
use OCA\DAV\Connector\Sabre\Principal;
use OCA\DAV\DAV\GroupPrincipalBackend;
use OCA\DAV\DAV\SystemPrincipalBackend;
-use Sabre\CalDAV\CalendarRoot;
use Sabre\CalDAV\Principal\Collection;
use Sabre\DAV\SimpleCollection;
@@ -55,7 +55,7 @@ class RootCollection extends SimpleCollection {
$systemPrincipals->disableListing = $disableListing;
$filesCollection = new Files\RootCollection($userPrincipalBackend, 'principals/users');
$filesCollection->disableListing = $disableListing;
- $caldavBackend = new CalDavBackend($db);
+ $caldavBackend = new CalDavBackend($db, $userPrincipalBackend);
$calendarRoot = new CalendarRoot($userPrincipalBackend, $caldavBackend, 'principals/users');
$calendarRoot->disableListing = $disableListing;
diff --git a/apps/dav/tests/travis/caldav/install.sh b/apps/dav/tests/travis/caldav/install.sh
index e836e37f86f..9688ec660de 100644
--- a/apps/dav/tests/travis/caldav/install.sh
+++ b/apps/dav/tests/travis/caldav/install.sh
@@ -15,6 +15,7 @@ fi
cd "$SCRIPTPATH/../../../../../"
OC_PASS=user01 php occ user:add --password-from-env user01
php occ dav:create-calendar user01 calendar
+php occ dav:create-calendar user01 shared
OC_PASS=user02 php occ user:add --password-from-env user02
php occ dav:create-calendar user02 calendar
cd "$SCRIPTPATH/../../../../../"
diff --git a/apps/dav/tests/travis/caldav/script.sh b/apps/dav/tests/travis/caldav/script.sh
index fe3391d5a06..aa5fc732922 100644
--- a/apps/dav/tests/travis/caldav/script.sh
+++ b/apps/dav/tests/travis/caldav/script.sh
@@ -10,9 +10,7 @@ sleep 30
# run the tests
cd "$SCRIPTPATH/CalDAVTester"
PYTHONPATH="$SCRIPTPATH/pycalendar/src" python testcaldav.py --print-details-onfail --basedir "$SCRIPTPATH/../caldavtest/" -o cdt.txt \
- "CalDAV/current-user-principal.xml" \
- "CalDAV/sync-report.xml"
-
+ "CalDAV/sharing-calendars.xml"
RESULT=$?
diff --git a/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/1.xml b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/1.xml
new file mode 100644
index 00000000000..3bcf9dc47f9
--- /dev/null
+++ b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/1.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<CS:share xmlns:D="DAV:" xmlns:CS="http://owncloud.org/ns">
+ <CS:set>
+ <D:href>principal:principals/users/user02</D:href>
+ <CS:summary>My Shared Calendar</CS:summary>
+ <CS:read-write/>
+ </CS:set>
+</CS:share>
diff --git a/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/4.xml b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/4.xml
new file mode 100644
index 00000000000..fd0f248bb31
--- /dev/null
+++ b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/4.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<D:propfind xmlns:D="DAV:">
+<D:prop>
+<D:resourcetype/>
+<D:owner/>
+<D:current-user-privilege-set/>
+</D:prop>
+</D:propfind>
diff --git a/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/5.ics b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/5.ics
new file mode 100644
index 00000000000..ae21adac8b2
--- /dev/null
+++ b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/5.ics
@@ -0,0 +1,29 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//PYVOBJECT//NONSGML Version 1//EN
+BEGIN:VTIMEZONE
+TZID:US/Eastern
+LAST-MODIFIED:20040110T032845Z
+BEGIN:STANDARD
+DTSTART:20001026T020000
+RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
+TZNAME:EST
+TZOFFSETFROM:-0400
+TZOFFSETTO:-0500
+END:STANDARD
+BEGIN:DAYLIGHT
+DTSTART:20000404T020000
+RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4
+TZNAME:EDT
+TZOFFSETFROM:-0500
+TZOFFSETTO:-0400
+END:DAYLIGHT
+END:VTIMEZONE
+BEGIN:VEVENT
+UID:$uid1:
+DTSTART;TZID=US/Eastern:$now.year.1:0101T100000
+DURATION:PT1H
+DTSTAMP:20051222T205953Z
+SUMMARY:event 1
+END:VEVENT
+END:VCALENDAR
diff --git a/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/5.xml b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/5.xml
new file mode 100644
index 00000000000..4862ed195f8
--- /dev/null
+++ b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/5.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<D:propfind xmlns:D="DAV:" xmlns:CS="http://owncloud.org/ns">
+<D:prop>
+<CS:invite/>
+</D:prop>
+</D:propfind>
diff --git a/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/6.ics b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/6.ics
new file mode 100644
index 00000000000..145f5f14c7b
--- /dev/null
+++ b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/6.ics
@@ -0,0 +1,29 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//PYVOBJECT//NONSGML Version 1//EN
+BEGIN:VTIMEZONE
+TZID:US/Eastern
+LAST-MODIFIED:20040110T032845Z
+BEGIN:STANDARD
+DTSTART:20001026T020000
+RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
+TZNAME:EST
+TZOFFSETFROM:-0400
+TZOFFSETTO:-0500
+END:STANDARD
+BEGIN:DAYLIGHT
+DTSTART:20000404T020000
+RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4
+TZNAME:EDT
+TZOFFSETFROM:-0500
+TZOFFSETTO:-0400
+END:DAYLIGHT
+END:VTIMEZONE
+BEGIN:VEVENT
+UID:$uid1:
+DTSTART;TZID=US/Eastern:$now.year.1:0101T100000
+DURATION:PT4H
+DTSTAMP:20051222T205953Z
+SUMMARY:event 4
+END:VEVENT
+END:VCALENDAR
diff --git a/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/7.ics b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/7.ics
new file mode 100644
index 00000000000..c4e816210df
--- /dev/null
+++ b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/7.ics
@@ -0,0 +1,29 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//PYVOBJECT//NONSGML Version 1//EN
+BEGIN:VTIMEZONE
+TZID:US/Eastern
+LAST-MODIFIED:20040110T032845Z
+BEGIN:STANDARD
+DTSTART:20001026T020000
+RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
+TZNAME:EST
+TZOFFSETFROM:-0400
+TZOFFSETTO:-0500
+END:STANDARD
+BEGIN:DAYLIGHT
+DTSTART:20000404T020000
+RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4
+TZNAME:EDT
+TZOFFSETFROM:-0500
+TZOFFSETTO:-0400
+END:DAYLIGHT
+END:VTIMEZONE
+BEGIN:VEVENT
+UID:$uid2:
+DTSTART;TZID=US/Eastern:$now.year.1:0201T100000
+DURATION:PT1H
+DTSTAMP:20051222T205953Z
+SUMMARY:event 7
+END:VEVENT
+END:VCALENDAR
diff --git a/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/8.ics b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/8.ics
new file mode 100644
index 00000000000..2da72d2f601
--- /dev/null
+++ b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/8.ics
@@ -0,0 +1,29 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//PYVOBJECT//NONSGML Version 1//EN
+BEGIN:VTIMEZONE
+TZID:US/Eastern
+LAST-MODIFIED:20040110T032845Z
+BEGIN:STANDARD
+DTSTART:20001026T020000
+RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
+TZNAME:EST
+TZOFFSETFROM:-0400
+TZOFFSETTO:-0500
+END:STANDARD
+BEGIN:DAYLIGHT
+DTSTART:20000404T020000
+RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4
+TZNAME:EDT
+TZOFFSETFROM:-0500
+TZOFFSETTO:-0400
+END:DAYLIGHT
+END:VTIMEZONE
+BEGIN:VEVENT
+UID:$uid2:
+DTSTART;TZID=US/Eastern:$now.year.1:0201T100000
+DURATION:PT7H
+DTSTAMP:20051222T205953Z
+SUMMARY:event 7-1
+END:VEVENT
+END:VCALENDAR
diff --git a/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/9.ics b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/9.ics
new file mode 100644
index 00000000000..dfc21bb9c5b
--- /dev/null
+++ b/apps/dav/tests/travis/caldavtest/data/Resource/CalDAV/sharing/calendars/read-write/9.ics
@@ -0,0 +1,29 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//PYVOBJECT//NONSGML Version 1//EN
+BEGIN:VTIMEZONE
+TZID:US/Eastern
+LAST-MODIFIED:20040110T032845Z
+BEGIN:STANDARD
+DTSTART:20001026T020000
+RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
+TZNAME:EST
+TZOFFSETFROM:-0400
+TZOFFSETTO:-0500
+END:STANDARD
+BEGIN:DAYLIGHT
+DTSTART:20000404T020000
+RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4
+TZNAME:EDT
+TZOFFSETFROM:-0500
+TZOFFSETTO:-0400
+END:DAYLIGHT
+END:VTIMEZONE
+BEGIN:VEVENT
+UID:$uid3:
+DTSTART;TZID=US/Eastern:$now.year.1:0201T100000
+DURATION:PT7H
+DTSTAMP:20051222T205953Z
+SUMMARY:event 9.ics
+END:VEVENT
+END:VCALENDAR
diff --git a/apps/dav/tests/travis/caldavtest/tests/CalDAV/sharing-calendars.xml b/apps/dav/tests/travis/caldavtest/tests/CalDAV/sharing-calendars.xml
index fa20a6e4862..334fa561aec 100644
--- a/apps/dav/tests/travis/caldavtest/tests/CalDAV/sharing-calendars.xml
+++ b/apps/dav/tests/travis/caldavtest/tests/CalDAV/sharing-calendars.xml
@@ -27,6 +27,7 @@
</require-feature>
<start>
+ <!--
<request user="$userid1:" pswd="$pswd1:">
<method>DELETEALL</method>
<ruri>$notificationpath1:/</ruri>
@@ -50,6 +51,7 @@
<filepath>Resource/Common/PROPPATCH/calendar-transp-opaque.xml</filepath>
</data>
</request>
+ -->
</start>
<test-suite name='Read-write calendar'>
@@ -67,56 +69,11 @@
</verify>
</request>
</test>
- <test name='2'>
- <description>Check Sharee notification collection</description>
- <request user="$userid2:" pswd="$pswd2:">
- <method>WAITCOUNT 1</method>
- <ruri>$notificationpath2:/</ruri>
- </request>
- <request user="$userid2:" pswd="$pswd2:">
- <method>GETNEW</method>
- <ruri>$notificationpath2:/</ruri>
- <verify>
- <callback>xmlDataMatch</callback>
- <arg>
- <name>filepath</name>
- <value>Resource/CalDAV/sharing/calendars/read-write/2.xml</value>
- </arg>
- <arg>
- <name>filter</name>
- <value>{http://calendarserver.org/ns/}dtstamp</value>
- <value>{http://calendarserver.org/ns/}uid</value>
- </arg>
- </verify>
- <grabelement>
- <name>{http://calendarserver.org/ns/}invite-notification/{http://calendarserver.org/ns/}uid</name>
- <variable>$inviteuid:</variable>
- </grabelement>
- </request>
- </test>
- <test name='3'>
- <description>Sharee replies ACCEPTED</description>
- <request user="$userid2:" pswd="$pswd2:">
- <method>POST</method>
- <ruri>$calendarhome2:/</ruri>
- <data>
- <content-type>application/xml; charset=utf-8</content-type>
- <filepath>Resource/CalDAV/sharing/calendars/read-write/3.xml</filepath>
- </data>
- <verify>
- <callback>statusCode</callback>
- </verify>
- <grabelement>
- <name>{DAV:}href</name>
- <variable>$sharedcalendar:</variable>
- </grabelement>
- </request>
- </test>
<test name='4'>
<description>Shared calendar exists</description>
<request user="$userid2:" pswd="$pswd2:">
<method>PROPFIND</method>
- <ruri>$sharedcalendar:/</ruri>
+ <ruri>$calendarhome1:/shared/</ruri>
<header>
<name>Depth</name>
<value>0</value>
@@ -132,12 +89,12 @@
<value>$verify-property-prefix:/{DAV:}owner/{DAV:}href[=$principaluri1:]</value>
<value>$verify-property-prefix:/{DAV:}resourcetype/{DAV:}collection</value>
<value>$verify-property-prefix:/{DAV:}resourcetype/{urn:ietf:params:xml:ns:caldav}calendar</value>
- <value>$verify-property-prefix:/{DAV:}resourcetype/{http://calendarserver.org/ns/}shared</value>
+ <!-- value>$verify-property-prefix:/{DAV:}resourcetype/{http://calendarserver.org/ns/}shared</value -->
<value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}read</value>
<value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}write</value>
<value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}bind</value>
<value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}unbind</value>
- <value>$verify-property-prefix:/{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp/{urn:ietf:params:xml:ns:caldav}transparent</value>
+ <!-- value>$verify-property-prefix:/{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp/{urn:ietf:params:xml:ns:caldav}transparent</value -->
</arg>
<arg>
<name>notexists</name>
@@ -151,7 +108,7 @@
<description>Shared calendar exists Depth:1</description>
<request user="$userid2:" pswd="$pswd2:">
<method>PROPFIND</method>
- <ruri>$calendarhome2:/</ruri>
+ <ruri>$calendarhome2:</ruri>
<header>
<name>Depth</name>
<value>1</value>
@@ -164,19 +121,19 @@
<callback>xmlElementMatch</callback>
<arg>
<name>parent</name>
- <value>$multistatus-response-prefix:[^{DAV:}href=$sharedcalendar:/]</value>
+ <value>$multistatus-response-prefix:[^{DAV:}href=$calendarhome2:/shared_shared_by_user01/]</value>
</arg>
<arg>
<name>exists</name>
<value>$verify-response-prefix:/{DAV:}owner/{DAV:}href[=$principaluri1:]</value>
<value>$verify-response-prefix:/{DAV:}resourcetype/{DAV:}collection</value>
<value>$verify-response-prefix:/{DAV:}resourcetype/{urn:ietf:params:xml:ns:caldav}calendar</value>
- <value>$verify-response-prefix:/{DAV:}resourcetype/{http://calendarserver.org/ns/}shared</value>
+ <!-- value>$verify-response-prefix:/{DAV:}resourcetype/{http://calendarserver.org/ns/}shared</value -->
<value>$verify-response-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}read</value>
<value>$verify-response-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}write</value>
<value>$verify-response-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}bind</value>
<value>$verify-response-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}unbind</value>
- <value>$verify-response-prefix:/{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp/{urn:ietf:params:xml:ns:caldav}transparent</value>
+ <!-- value>$verify-response-prefix:/{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp/{urn:ietf:params:xml:ns:caldav}transparent</value -->
</arg>
<arg>
<name>notexists</name>
@@ -186,44 +143,31 @@
</verify>
</request>
</test>
- <test name='4b'>
- <description>Shared calendar has invite property</description>
- <request user="$userid2:" pswd="$pswd2:">
+ <test name='5'>
+ <description>Original calendar unchanged</description>
+ <request>
<method>PROPFIND</method>
- <ruri>$sharedcalendar:/</ruri>
+ <ruri>$calendarhome1:/shared/</ruri>
<header>
<name>Depth</name>
<value>0</value>
</header>
<data>
<content-type>text/xml; charset=utf-8</content-type>
- <filepath>Resource/CalDAV/sharing/calendars/read-write/5.xml</filepath>
+ <filepath>Resource/CalDAV/sharing/calendars/read-write/4.xml</filepath>
</data>
<verify>
- <callback>propfindItems</callback>
- <arg>
- <name>okprops</name>
- <value>{http://calendarserver.org/ns/}invite</value>
- </arg>
- </verify>
- <verify>
<callback>xmlElementMatch</callback>
<arg>
<name>exists</name>
- <value>$verify-property-prefix:/{http://calendarserver.org/ns/}invite</value>
- <value>$verify-property-prefix:/{http://calendarserver.org/ns/}invite/{http://calendarserver.org/ns/}organizer</value>
- <value>$verify-property-prefix:/{http://calendarserver.org/ns/}invite/{http://calendarserver.org/ns/}organizer/{DAV:}href[=$principaluri1:]</value>
- <value>$verify-property-prefix:/{http://calendarserver.org/ns/}invite/{http://calendarserver.org/ns/}organizer/{http://calendarserver.org/ns/}common-name[=$username1:]</value>
- <value>$verify-property-prefix:/{http://calendarserver.org/ns/}invite/{http://calendarserver.org/ns/}user</value>
- <value>$verify-property-prefix:/{http://calendarserver.org/ns/}invite/{http://calendarserver.org/ns/}user/{DAV:}href[=$cuaddrurn2:]</value>
- <value>$verify-property-prefix:/{http://calendarserver.org/ns/}invite/{http://calendarserver.org/ns/}user/{http://calendarserver.org/ns/}access/{http://calendarserver.org/ns/}read-write</value>
- <value>$verify-property-prefix:/{http://calendarserver.org/ns/}invite/{http://calendarserver.org/ns/}user/{http://calendarserver.org/ns/}invite-accepted</value>
+ <value>$verify-property-prefix:/{DAV:}owner/{DAV:}href[=$principaluri1:]</value>
+ <!--<value>$verify-property-prefix:/{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp/{urn:ietf:params:xml:ns:caldav}opaque</value>-->
</arg>
</verify>
</request>
</test>
- <test name='5'>
- <description>Original calendar unchanged</description>
+ <test name='5a'>
+ <description>Invite propfind returns sharees</description>
<request>
<method>PROPFIND</method>
<ruri>$calendarhome1:/shared/</ruri>
@@ -233,14 +177,14 @@
</header>
<data>
<content-type>text/xml; charset=utf-8</content-type>
- <filepath>Resource/CalDAV/sharing/calendars/read-write/4.xml</filepath>
+ <filepath>Resource/CalDAV/sharing/calendars/read-write/5.xml</filepath>
</data>
<verify>
<callback>xmlElementMatch</callback>
<arg>
<name>exists</name>
- <value>$verify-property-prefix:/{DAV:}owner/{DAV:}href[=$principaluri1:]</value>
- <value>$verify-property-prefix:/{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp/{urn:ietf:params:xml:ns:caldav}opaque</value>
+ <value>$verify-property-prefix:/{http://owncloud.org/ns}invite/{http://owncloud.org/ns}user/{DAV:}href</value>
+ <value>$verify-property-prefix:/{http://owncloud.org/ns}invite/{http://owncloud.org/ns}user/{http://owncloud.org/ns}invite-accepted</value>
</arg>
</verify>
</request>
@@ -249,7 +193,7 @@
<description>Sharee creates event</description>
<request user="$userid2:" pswd="$pswd2:">
<method>PUT</method>
- <ruri>$sharedcalendar:/1.ics</ruri>
+ <ruri>$calendarhome1:/shared/1.ics</ruri>
<data>
<content-type>text/calendar; charset=utf-8</content-type>
<filepath>Resource/CalDAV/sharing/calendars/read-write/5.ics</filepath>
@@ -291,7 +235,7 @@
<description>Sharee sees changed event</description>
<request user="$userid2:" pswd="$pswd2:">
<method>GET</method>
- <ruri>$sharedcalendar:/1.ics</ruri>
+ <ruri>$calendarhome1:/shared/1.ics</ruri>
<verify>
<callback>calendarDataMatch</callback>
<arg>
@@ -319,7 +263,7 @@
<description>Sharee sees new event</description>
<request user="$userid2:" pswd="$pswd2:">
<method>GET</method>
- <ruri>$sharedcalendar:/2.ics</ruri>
+ <ruri>$calendarhome1:/shared/2.ics</ruri>
<verify>
<callback>calendarDataMatch</callback>
<arg>
@@ -333,7 +277,7 @@
<description>Sharee changes event</description>
<request user="$userid2:" pswd="$pswd2:">
<method>PUT</method>
- <ruri>$sharedcalendar:/2.ics</ruri>
+ <ruri>$calendarhome1:/shared/2.ics</ruri>
<data>
<content-type>text/calendar; charset=utf-8</content-type>
<filepath>Resource/CalDAV/sharing/calendars/read-write/8.ics</filepath>
@@ -357,8 +301,76 @@
</verify>
</request>
</test>
+ <test name='14'>
+ <description>Un-share by delete</description>
+ <request user="$userid2:" pswd="$pswd2:">
+ <method>DELETE</method>
+ <ruri>$calendarhome2:/shared_shared_by_user01/</ruri>
+ <verify>
+ <callback>statusCode</callback>
+ </verify>
+ </request>
+ </test>
+ <test name='15'>
+ <description>Original calendar still exists</description>
+ <request>
+ <method>PROPFIND</method>
+ <ruri>$calendarhome1:/shared/</ruri>
+ <header>
+ <name>Depth</name>
+ <value>0</value>
+ </header>
+ <data>
+ <content-type>text/xml; charset=utf-8</content-type>
+ <filepath>Resource/CalDAV/sharing/calendars/read-write/4.xml</filepath>
+ </data>
+ <verify>
+ <callback>xmlElementMatch</callback>
+ <arg>
+ <name>exists</name>
+ <value>$verify-property-prefix:/{DAV:}owner/{DAV:}href[=$principaluri1:]</value>
+ <value>$verify-property-prefix:/{DAV:}resourcetype/{DAV:}collection</value>
+ <value>$verify-property-prefix:/{DAV:}resourcetype/{urn:ietf:params:xml:ns:caldav}calendar</value>
+ <!-- value>$verify-property-prefix:/{DAV:}resourcetype/{http://calendarserver.org/ns/}shared</value -->
+ <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}read</value>
+ <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}write</value>
+ <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}bind</value>
+ <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}unbind</value>
+ <!-- value>$verify-property-prefix:/{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp/{urn:ietf:params:xml:ns:caldav}transparent</value -->
+ </arg>
+ <arg>
+ <name>notexists</name>
+ <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}admin</value>
+ <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}all</value>
+ </arg>
+ </verify>
+ </request>
+ </test>
+ <test name='16'>
+ <description>Shared calendar no longer exists Depth:1</description>
+ <request user="$userid2:" pswd="$pswd2:">
+ <method>PROPFIND</method>
+ <ruri>$calendarhome2:</ruri>
+ <header>
+ <name>Depth</name>
+ <value>1</value>
+ </header>
+ <data>
+ <content-type>text/xml; charset=utf-8</content-type>
+ <filepath>Resource/CalDAV/sharing/calendars/read-write/4.xml</filepath>
+ </data>
+ <verify>
+ <callback>xmlElementMatch</callback>
+ <arg>
+ <name>notexists</name>
+ <value>$multistatus-response-prefix:[^{DAV:}href=$calendarhome2:/shared_shared_by_user01/]</value>
+ </arg>
+ </verify>
+ </request>
+ </test>
</test-suite>
-
+
+ <!--
<test-suite name='Default calendar cannot be shared calendar'>
<test name='1'>
<description>Set property on Inbox</description>
@@ -560,7 +572,10 @@
</test>
</test-suite>
+-->
+
<end>
+ <!--
<request user="$useradmin:" pswd="$pswdadmin:">
<method>DELETEALL</method>
<ruri>$notificationpath1:/</ruri>
@@ -568,6 +583,7 @@
<ruri>$notificationpath3:/</ruri>
<ruri>$notificationpath4:/</ruri>
</request>
+ -->
</end>
</caldavtest>
diff --git a/apps/dav/tests/travis/caldavtest/tests/CardDAV/sharing-addressbooks.xml b/apps/dav/tests/travis/caldavtest/tests/CardDAV/sharing-addressbooks.xml
index 37b4941b9f1..84ee6265017 100644
--- a/apps/dav/tests/travis/caldavtest/tests/CardDAV/sharing-addressbooks.xml
+++ b/apps/dav/tests/travis/caldavtest/tests/CardDAV/sharing-addressbooks.xml
@@ -238,7 +238,70 @@
</verify>
</request>
</test>
- </test-suite>
+ <test name='14'>
+ <description>Un-share by delete</description>
+ <request user="$userid2:" pswd="$pswd2:">
+ <method>DELETE</method>
+ <ruri>$addressbookhome2:/addressbook_shared_by_user01/</ruri>
+ <verify>
+ <callback>statusCode</callback>
+ </verify>
+ </request>
+ </test>
+ <test name='15'>
+ <description>Original address book still exists</description>
+ <request>
+ <method>PROPFIND</method>
+ <ruri>$addressbookhome1:/addressbook/</ruri>
+ <header>
+ <name>Depth</name>
+ <value>0</value>
+ </header>
+ <data>
+ <content-type>text/xml; charset=utf-8</content-type>
+ <filepath>Resource/CardDAV/sharing/read-write/4.xml</filepath>
+ </data>
+ <verify>
+ <callback>xmlElementMatch</callback>
+ <arg>
+ <name>exists</name>
+ <value>$verify-property-prefix:/{DAV:}owner/{DAV:}href[=$principaluri1:]</value>
+ <value>$verify-property-prefix:/{DAV:}resourcetype/{DAV:}collection</value>
+ <value>$verify-property-prefix:/{DAV:}resourcetype/{urn:ietf:params:xml:ns:carddav}addressbook</value>
+ <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}read</value>
+ <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}write</value>
+ <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}bind</value>
+ <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}unbind</value>
+ </arg>
+ <arg>
+ <name>notexists</name>
+ <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}admin</value>
+ <value>$verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}all</value>
+ </arg>
+ </verify> </request>
+ </test>
+ <test name='16'>
+ <description>Shared calendar no longer exists Depth:1</description>
+ <request user="$userid2:" pswd="$pswd2:">
+ <method>PROPFIND</method>
+ <ruri>$addressbookhome2:</ruri>
+ <header>
+ <name>Depth</name>
+ <value>1</value>
+ </header>
+ <data>
+ <content-type>text/xml; charset=utf-8</content-type>
+ <filepath>Resource/CardDAV/sharing/read-write/4.xml</filepath>
+ </data>
+ <verify>
+ <callback>xmlElementMatch</callback>
+ <arg>
+ <name>notexists</name>
+ <value>$multistatus-response-prefix:[^{DAV:}href=$addressbookhome2:/addressbook_shared_by_user01/]</value>
+ </arg>
+ </verify>
+ </request>
+ </test> </test-suite>
<end>
</end>
diff --git a/apps/dav/tests/unit/caldav/caldavbackendtest.php b/apps/dav/tests/unit/caldav/caldavbackendtest.php
index 939fd36fba8..aece738166a 100644
--- a/apps/dav/tests/unit/caldav/caldavbackendtest.php
+++ b/apps/dav/tests/unit/caldav/caldavbackendtest.php
@@ -23,9 +23,12 @@ namespace Tests\Connector\Sabre;
use DateTime;
use DateTimeZone;
use OCA\DAV\CalDAV\CalDavBackend;
+use OCA\DAV\CalDAV\Calendar;
+use OCA\DAV\Connector\Sabre\Principal;
use Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet;
use Sabre\DAV\PropPatch;
use Sabre\DAV\Xml\Property\Href;
+use Sabre\DAVACL\IACL;
use Test\TestCase;
/**
@@ -40,14 +43,30 @@ class CalDavBackendTest extends TestCase {
/** @var CalDavBackend */
private $backend;
- const UNIT_TEST_USER = 'caldav-unit-test';
+ /** @var Principal | \PHPUnit_Framework_MockObject_MockObject */
+ private $principal;
+ const UNIT_TEST_USER = 'principals/users/caldav-unit-test';
+ const UNIT_TEST_USER1 = 'principals/users/caldav-unit-test1';
+ const UNIT_TEST_GROUP = 'principals/groups/caldav-unit-test-group';
public function setUp() {
parent::setUp();
+ $this->principal = $this->getMockBuilder('OCA\DAV\Connector\Sabre\Principal')
+ ->disableOriginalConstructor()
+ ->setMethods(['getPrincipalByPath', 'getGroupMembership'])
+ ->getMock();
+ $this->principal->method('getPrincipalByPath')
+ ->willReturn([
+ 'uri' => 'principals/best-friend'
+ ]);
+ $this->principal->method('getGroupMembership')
+ ->withAnyParameters()
+ ->willReturn([self::UNIT_TEST_GROUP]);
+
$db = \OC::$server->getDatabaseConnection();
- $this->backend = new CalDavBackend($db);
+ $this->backend = new CalDavBackend($db, $this->principal);
$this->tearDown();
}
@@ -90,6 +109,87 @@ class CalDavBackendTest extends TestCase {
$this->assertEquals(0, count($books));
}
+ public function providesSharingData() {
+ return [
+ [true, true, true, false, [
+ [
+ 'href' => 'principal:' . self::UNIT_TEST_USER1,
+ 'readOnly' => false
+ ],
+ [
+ 'href' => 'principal:' . self::UNIT_TEST_GROUP,
+ 'readOnly' => true
+ ]
+ ]],
+ [true, false, false, false, [
+ [
+ 'href' => 'principal:' . self::UNIT_TEST_USER1,
+ 'readOnly' => true
+ ],
+ ]],
+
+ ];
+ }
+
+ /**
+ * @dataProvider providesSharingData
+ */
+ public function testCalendarSharing($userCanRead, $userCanWrite, $groupCanRead, $groupCanWrite, $add) {
+
+ $calendarId = $this->createTestCalendar();
+ $books = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
+ $this->assertEquals(1, count($books));
+ $calendar = new Calendar($this->backend, $books[0]);
+ $this->backend->updateShares($calendar, $add, []);
+ $books = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER1);
+ $this->assertEquals(1, count($books));
+ $calendar = new Calendar($this->backend, $books[0]);
+ $acl = $calendar->getACL();
+ $this->assertAcl(self::UNIT_TEST_USER, '{DAV:}read', $acl);
+ $this->assertAcl(self::UNIT_TEST_USER, '{DAV:}write', $acl);
+ $this->assertAccess($userCanRead, self::UNIT_TEST_USER1, '{DAV:}read', $acl);
+ $this->assertAccess($userCanWrite, self::UNIT_TEST_USER1, '{DAV:}write', $acl);
+ $this->assertAccess($groupCanRead, self::UNIT_TEST_GROUP, '{DAV:}read', $acl);
+ $this->assertAccess($groupCanWrite, self::UNIT_TEST_GROUP, '{DAV:}write', $acl);
+ $this->assertEquals(self::UNIT_TEST_USER, $calendar->getOwner());
+
+ // test acls on the child
+ $uri = $this->getUniqueID('calobj');
+ $calData = <<<'EOD'
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:ownCloud Calendar
+BEGIN:VEVENT
+CREATED;VALUE=DATE-TIME:20130910T125139Z
+UID:47d15e3ec8
+LAST-MODIFIED;VALUE=DATE-TIME:20130910T125139Z
+DTSTAMP;VALUE=DATE-TIME:20130910T125139Z
+SUMMARY:Test Event
+DTSTART;VALUE=DATE-TIME:20130912T130000Z
+DTEND;VALUE=DATE-TIME:20130912T140000Z
+CLASS:PUBLIC
+END:VEVENT
+END:VCALENDAR
+EOD;
+
+ $this->backend->createCalendarObject($calendarId, $uri, $calData);
+
+ /** @var IACL $child */
+ $child = $calendar->getChild($uri);
+ $acl = $child->getACL();
+ $this->assertAcl(self::UNIT_TEST_USER, '{DAV:}read', $acl);
+ $this->assertAcl(self::UNIT_TEST_USER, '{DAV:}write', $acl);
+ $this->assertAccess($userCanRead, self::UNIT_TEST_USER1, '{DAV:}read', $acl);
+ $this->assertAccess($userCanWrite, self::UNIT_TEST_USER1, '{DAV:}write', $acl);
+ $this->assertAccess($groupCanRead, self::UNIT_TEST_GROUP, '{DAV:}read', $acl);
+ $this->assertAccess($groupCanWrite, self::UNIT_TEST_GROUP, '{DAV:}write', $acl);
+
+ // delete the address book
+ $this->backend->deleteCalendar($books[0]['id']);
+ $books = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
+ $this->assertEquals(0, count($books));
+ }
+
public function testCalendarObjectsOperations() {
$calendarId = $this->createTestCalendar();
@@ -345,4 +445,32 @@ EOD;
$sos = $this->backend->getSchedulingObjects(self::UNIT_TEST_USER);
$this->assertEquals(0, count($sos));
}
+
+ private function assertAcl($principal, $privilege, $acl) {
+ foreach($acl as $a) {
+ if ($a['principal'] === $principal && $a['privilege'] === $privilege) {
+ $this->assertTrue(true);
+ return;
+ }
+ }
+ $this->fail("ACL does not contain $principal / $privilege");
+ }
+
+ private function assertNotAcl($principal, $privilege, $acl) {
+ foreach($acl as $a) {
+ if ($a['principal'] === $principal && $a['privilege'] === $privilege) {
+ $this->fail("ACL contains $principal / $privilege");
+ return;
+ }
+ }
+ $this->assertTrue(true);
+ }
+
+ private function assertAccess($shouldHaveAcl, $principal, $privilege, $acl) {
+ if ($shouldHaveAcl) {
+ $this->assertAcl($principal, $privilege, $acl);
+ } else {
+ $this->assertNotAcl($principal, $privilege, $acl);
+ }
+ }
}
diff --git a/apps/dav/tests/unit/caldav/calendartest.php b/apps/dav/tests/unit/caldav/calendartest.php
new file mode 100644
index 00000000000..93b3f4bff8c
--- /dev/null
+++ b/apps/dav/tests/unit/caldav/calendartest.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * @author Thomas Müller <thomas.mueller@tmit.eu>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\DAV\Tests\Unit\CalDAV;
+
+use OCA\DAV\CalDAV\CalDavBackend;
+use OCA\DAV\CalDAV\Calendar;
+use Test\TestCase;
+
+class CalendarTest extends TestCase {
+
+ public function testDelete() {
+ /** @var \PHPUnit_Framework_MockObject_MockObject | CalDavBackend $backend */
+ $backend = $this->getMockBuilder('OCA\DAV\CalDAV\CalDavBackend')->disableOriginalConstructor()->getMock();
+ $backend->expects($this->once())->method('updateShares');
+ $backend->method('getShares')->willReturn([
+ ['href' => 'principal:user2']
+ ]);
+ $calendarInfo = [
+ '{http://owncloud.org/ns}owner-principal' => 'user1',
+ 'principaluri' => 'user2',
+ 'id' => 666
+ ];
+ $c = new Calendar($backend, $calendarInfo);
+ $c->delete();
+ }
+
+ /**
+ * @expectedException \Sabre\DAV\Exception\Forbidden
+ */
+ public function testDeleteFromGroup() {
+ /** @var \PHPUnit_Framework_MockObject_MockObject | CalDavBackend $backend */
+ $backend = $this->getMockBuilder('OCA\DAV\CalDAV\CalDavBackend')->disableOriginalConstructor()->getMock();
+ $backend->expects($this->never())->method('updateShares');
+ $backend->method('getShares')->willReturn([
+ ['href' => 'principal:group2']
+ ]);
+ $calendarInfo = [
+ '{http://owncloud.org/ns}owner-principal' => 'user1',
+ 'principaluri' => 'user2',
+ 'id' => 666
+ ];
+ $c = new Calendar($backend, $calendarInfo);
+ $c->delete();
+ }
+}
diff --git a/apps/dav/tests/unit/carddav/addressbooktest.php b/apps/dav/tests/unit/carddav/addressbooktest.php
new file mode 100644
index 00000000000..d714fc71679
--- /dev/null
+++ b/apps/dav/tests/unit/carddav/addressbooktest.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * @author Thomas Müller <thomas.mueller@tmit.eu>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\DAV\Tests\Unit\CardDAV;
+
+use OCA\DAV\CardDAV\AddressBook;
+use OCA\DAV\CardDAV\CardDavBackend;
+use Test\TestCase;
+
+class AddressBookTest extends TestCase {
+
+ public function testDelete() {
+ /** @var \PHPUnit_Framework_MockObject_MockObject | CardDavBackend $backend */
+ $backend = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend')->disableOriginalConstructor()->getMock();
+ $backend->expects($this->once())->method('updateShares');
+ $backend->method('getShares')->willReturn([
+ ['href' => 'principal:user2']
+ ]);
+ $calendarInfo = [
+ '{http://owncloud.org/ns}owner-principal' => 'user1',
+ 'principaluri' => 'user2',
+ 'id' => 666
+ ];
+ $c = new AddressBook($backend, $calendarInfo);
+ $c->delete();
+ }
+
+ /**
+ * @expectedException \Sabre\DAV\Exception\Forbidden
+ */
+ public function testDeleteFromGroup() {
+ /** @var \PHPUnit_Framework_MockObject_MockObject | CardDavBackend $backend */
+ $backend = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend')->disableOriginalConstructor()->getMock();
+ $backend->expects($this->never())->method('updateShares');
+ $backend->method('getShares')->willReturn([
+ ['href' => 'principal:group2']
+ ]);
+ $calendarInfo = [
+ '{http://owncloud.org/ns}owner-principal' => 'user1',
+ 'principaluri' => 'user2',
+ 'id' => 666
+ ];
+ $c = new AddressBook($backend, $calendarInfo);
+ $c->delete();
+ }
+}
diff --git a/apps/dav/tests/unit/carddav/carddavbackendtest.php b/apps/dav/tests/unit/carddav/carddavbackendtest.php
index 0158330a194..86bc26b4c0d 100644
--- a/apps/dav/tests/unit/carddav/carddavbackendtest.php
+++ b/apps/dav/tests/unit/carddav/carddavbackendtest.php
@@ -27,7 +27,6 @@ use OCA\DAV\CardDAV\AddressBook;
use OCA\DAV\CardDAV\CardDavBackend;
use OCA\DAV\Connector\Sabre\Principal;
use OCP\IDBConnection;
-use OCP\ILogger;
use Sabre\DAV\PropPatch;
use Sabre\VObject\Component\VCard;
use Sabre\VObject\Property\Text;
@@ -57,19 +56,24 @@ class CardDavBackendTest extends TestCase {
/** @var string */
private $dbCardsPropertiesTable = 'cards_properties';
- const UNIT_TEST_USER = 'carddav-unit-test';
+ const UNIT_TEST_USER = 'principals/users/carddav-unit-test';
+ const UNIT_TEST_USER1 = 'principals/users/carddav-unit-test1';
+ const UNIT_TEST_GROUP = 'principals/groups/carddav-unit-test-group';
public function setUp() {
parent::setUp();
$this->principal = $this->getMockBuilder('OCA\DAV\Connector\Sabre\Principal')
->disableOriginalConstructor()
- ->setMethods(['getPrincipalByPath'])
+ ->setMethods(['getPrincipalByPath', 'getGroupMembership'])
->getMock();
$this->principal->method('getPrincipalByPath')
->willReturn([
'uri' => 'principals/best-friend'
]);
+ $this->principal->method('getGroupMembership')
+ ->withAnyParameters()
+ ->willReturn([self::UNIT_TEST_GROUP]);
$this->db = \OC::$server->getDatabaseConnection();
@@ -124,6 +128,29 @@ class CardDavBackendTest extends TestCase {
$this->assertEquals(0, count($books));
}
+ public function testAddressBookSharing() {
+
+ $this->backend->createAddressBook(self::UNIT_TEST_USER, 'Example', []);
+ $books = $this->backend->getAddressBooksForUser(self::UNIT_TEST_USER);
+ $this->assertEquals(1, count($books));
+ $addressBook = new AddressBook($this->backend, $books[0]);
+ $this->backend->updateShares($addressBook, [
+ [
+ 'href' => 'principal:' . self::UNIT_TEST_USER1,
+ ],
+ [
+ 'href' => 'principal:' . self::UNIT_TEST_GROUP,
+ ]
+ ], []);
+ $books = $this->backend->getAddressBooksForUser(self::UNIT_TEST_USER1);
+ $this->assertEquals(1, count($books));
+
+ // delete the address book
+ $this->backend->deleteAddressBook($books[0]['id']);
+ $books = $this->backend->getAddressBooksForUser(self::UNIT_TEST_USER);
+ $this->assertEquals(0, count($books));
+ }
+
public function testCardOperations() {
/** @var CardDavBackend | \PHPUnit_Framework_MockObject_MockObject $backend */
diff --git a/apps/encryption/appinfo/info.xml b/apps/encryption/appinfo/info.xml
index 1fb4e93c508..970b58e3898 100644
--- a/apps/encryption/appinfo/info.xml
+++ b/apps/encryption/appinfo/info.xml
@@ -12,7 +12,7 @@
to enable server-side encryption.
</description>
<name>Default encryption module</name>
- <license>AGPL</license>
+ <licence>AGPL</licence>
<author>Bjoern Schiessle, Clark Tomlinson</author>
<documentation>
<user>user-encryption</user>
diff --git a/apps/files/appinfo/info.xml b/apps/files/appinfo/info.xml
index c0db1783235..136baa2ed07 100644
--- a/apps/files/appinfo/info.xml
+++ b/apps/files/appinfo/info.xml
@@ -5,7 +5,6 @@
<description>File Management</description>
<licence>AGPL</licence>
<author>Robin Appelman, Vincent Petry</author>
- <standalone/>
<default_enable/>
<version>1.4.2</version>
<types>
diff --git a/apps/files_external/l10n/it.js b/apps/files_external/l10n/it.js
index d9adaad833b..b6fad31111d 100644
--- a/apps/files_external/l10n/it.js
+++ b/apps/files_external/l10n/it.js
@@ -29,6 +29,7 @@ OC.L10N.register(
"Error generating key pair" : "Errore durante la generazione della coppia di chiavi",
"Enable encryption" : "Abilita cifratura",
"Enable previews" : "Abilita le anteprime",
+ "Enable sharing" : "Abilita condivisione",
"Check for changes" : "Controlla le modifiche",
"Never" : "Mai",
"Once every direct access" : "Una volta per ogni accesso diretto",
diff --git a/apps/files_external/l10n/it.json b/apps/files_external/l10n/it.json
index b228cd76604..e253c22b6b1 100644
--- a/apps/files_external/l10n/it.json
+++ b/apps/files_external/l10n/it.json
@@ -27,6 +27,7 @@
"Error generating key pair" : "Errore durante la generazione della coppia di chiavi",
"Enable encryption" : "Abilita cifratura",
"Enable previews" : "Abilita le anteprime",
+ "Enable sharing" : "Abilita condivisione",
"Check for changes" : "Controlla le modifiche",
"Never" : "Mai",
"Once every direct access" : "Una volta per ogni accesso diretto",
diff --git a/apps/files_external/l10n/pt_PT.js b/apps/files_external/l10n/pt_PT.js
index b84c399e34d..ef75f504bcf 100644
--- a/apps/files_external/l10n/pt_PT.js
+++ b/apps/files_external/l10n/pt_PT.js
@@ -29,6 +29,7 @@ OC.L10N.register(
"Error generating key pair" : "Erro ao gerar chave par",
"Enable encryption" : "Ative a encriptação",
"Enable previews" : "Ative as pré-visualizações",
+ "Enable sharing" : "Ativar partilha",
"Check for changes" : "Verifique as suas alterações",
"Never" : "Nunca",
"Once every direct access" : "Uma vez em cada acesso direto",
diff --git a/apps/files_external/l10n/pt_PT.json b/apps/files_external/l10n/pt_PT.json
index ac65ca7744f..686802379ee 100644
--- a/apps/files_external/l10n/pt_PT.json
+++ b/apps/files_external/l10n/pt_PT.json
@@ -27,6 +27,7 @@
"Error generating key pair" : "Erro ao gerar chave par",
"Enable encryption" : "Ative a encriptação",
"Enable previews" : "Ative as pré-visualizações",
+ "Enable sharing" : "Ativar partilha",
"Check for changes" : "Verifique as suas alterações",
"Never" : "Nunca",
"Once every direct access" : "Uma vez em cada acesso direto",
diff --git a/apps/files_sharing/api/share20ocs.php b/apps/files_sharing/api/share20ocs.php
index 63c49b926bf..d7c5d004d9c 100644
--- a/apps/files_sharing/api/share20ocs.php
+++ b/apps/files_sharing/api/share20ocs.php
@@ -26,35 +26,41 @@ use OCP\IRequest;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\Files\IRootFolder;
+use OCP\Share\IManager;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\Exceptions\GenericShareException;
class Share20OCS {
- /** @var \OC\Share20\Manager */
+ /** @var IManager */
private $shareManager;
-
/** @var IGroupManager */
private $groupManager;
-
/** @var IUserManager */
private $userManager;
-
/** @var IRequest */
private $request;
-
/** @var IRootFolder */
private $rootFolder;
-
/** @var IUrlGenerator */
private $urlGenerator;
-
/** @var IUser */
private $currentUser;
+ /**
+ * Share20OCS constructor.
+ *
+ * @param IManager $shareManager
+ * @param IGroupManager $groupManager
+ * @param IUserManager $userManager
+ * @param IRequest $request
+ * @param IRootFolder $rootFolder
+ * @param IURLGenerator $urlGenerator
+ * @param IUser $currentUser
+ */
public function __construct(
- \OC\Share20\Manager $shareManager,
+ IManager $shareManager,
IGroupManager $groupManager,
IUserManager $userManager,
IRequest $request,
@@ -78,22 +84,24 @@ class Share20OCS {
* @return array
*/
protected function formatShare(\OCP\Share\IShare $share) {
+ $sharedBy = $this->userManager->get($share->getSharedBy());
+ $shareOwner = $this->userManager->get($share->getShareOwner());
$result = [
'id' => $share->getId(),
'share_type' => $share->getShareType(),
- 'uid_owner' => $share->getSharedBy()->getUID(),
- 'displayname_owner' => $share->getSharedBy()->getDisplayName(),
+ 'uid_owner' => $share->getSharedBy(),
+ 'displayname_owner' => $sharedBy->getDisplayName(),
'permissions' => $share->getPermissions(),
'stime' => $share->getShareTime()->getTimestamp(),
'parent' => null,
'expiration' => null,
'token' => null,
- 'uid_file_owner' => $share->getShareOwner()->getUID(),
- 'displayname_file_owner' => $share->getShareOwner()->getDisplayName(),
+ 'uid_file_owner' => $share->getShareOwner(),
+ 'displayname_file_owner' => $shareOwner->getDisplayName(),
];
$node = $share->getNode();
- $result['path'] = $this->rootFolder->getUserFolder($share->getShareOwner()->getUID())->getRelativePath($node->getPath());
+ $result['path'] = $this->rootFolder->getUserFolder($share->getShareOwner())->getRelativePath($node->getPath());
if ($node instanceOf \OCP\Files\Folder) {
$result['item_type'] = 'folder';
} else {
@@ -107,13 +115,12 @@ class Share20OCS {
$result['file_target'] = $share->getTarget();
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
- $sharedWith = $share->getSharedWith();
+ $sharedWith = $this->userManager->get($share->getSharedWith());
$result['share_with'] = $sharedWith->getUID();
$result['share_with_displayname'] = $sharedWith->getDisplayName();
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
- $sharedWith = $share->getSharedWith();
- $result['share_with'] = $sharedWith->getGID();
- $result['share_with_displayname'] = $sharedWith->getGID();
+ $result['share_with'] = $share->getSharedWith();
+ $result['share_with_displayname'] = $share->getSharedWith();
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
$result['share_with'] = $share->getPassword();
@@ -250,14 +257,14 @@ class Share20OCS {
if ($shareWith === null || !$this->userManager->userExists($shareWith)) {
return new \OC_OCS_Result(null, 404, 'please specify a valid user');
}
- $share->setSharedWith($this->userManager->get($shareWith));
+ $share->setSharedWith($shareWith);
$share->setPermissions($permissions);
} else if ($shareType === \OCP\Share::SHARE_TYPE_GROUP) {
// Valid group is required to share
if ($shareWith === null || !$this->groupManager->groupExists($shareWith)) {
return new \OC_OCS_Result(null, 404, 'please specify a valid group');
}
- $share->setSharedWith($this->groupManager->get($shareWith));
+ $share->setSharedWith($shareWith);
$share->setPermissions($permissions);
} else if ($shareType === \OCP\Share::SHARE_TYPE_LINK) {
//Can we even share links?
@@ -313,7 +320,7 @@ class Share20OCS {
}
$share->setShareType($shareType);
- $share->setSharedBy($this->currentUser);
+ $share->setSharedBy($this->currentUser->getUID());
try {
$share = $this->shareManager->createShare($share);
@@ -333,8 +340,8 @@ class Share20OCS {
* @return \OC_OCS_Result
*/
private function getSharedWithMe($node = null) {
- $userShares = $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $node, -1, 0);
- $groupShares = $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $node, -1, 0);
+ $userShares = $this->shareManager->getSharedWith($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_USER, $node, -1, 0);
+ $groupShares = $this->shareManager->getSharedWith($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_GROUP, $node, -1, 0);
$shares = array_merge($userShares, $groupShares);
@@ -361,9 +368,9 @@ class Share20OCS {
/** @var \OCP\Share\IShare[] $shares */
$shares = [];
foreach ($nodes as $node) {
- $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $node, false, -1, 0));
- $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $node, false, -1, 0));
- $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_LINK, $node, false, -1, 0));
+ $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_USER, $node, false, -1, 0));
+ $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_GROUP, $node, false, -1, 0));
+ $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_LINK, $node, false, -1, 0));
//TODO: Add federated shares
}
@@ -417,9 +424,9 @@ class Share20OCS {
}
// Get all shares
- $userShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $path, $reshares, -1, 0);
- $groupShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $path, $reshares, -1, 0);
- $linkShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_LINK, $path, $reshares, -1, 0);
+ $userShares = $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_USER, $path, $reshares, -1, 0);
+ $groupShares = $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_GROUP, $path, $reshares, -1, 0);
+ $linkShares = $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_LINK, $path, $reshares, -1, 0);
//TODO: Add federated shares
$shares = array_merge($userShares, $groupShares, $linkShares);
@@ -538,14 +545,6 @@ class Share20OCS {
return new \OC_OCS_Result($this->formatShare($share));
}
- public function validatePermissions($permissions) {
- if ($permissions < 0 || $permissions > \OCP\Constants::PERMISSION_ALL) {
- return false;
- }
-
-
- }
-
/**
* @param \OCP\Share\IShare $share
* @return bool
@@ -557,21 +556,23 @@ class Share20OCS {
}
// Owner of the file and the sharer of the file can always get share
- if ($share->getShareOwner() === $this->currentUser ||
- $share->getSharedBy() === $this->currentUser
+ if ($share->getShareOwner() === $this->currentUser->getUID() ||
+ $share->getSharedBy() === $this->currentUser->getUID()
) {
return true;
}
// If the share is shared with you (or a group you are a member of)
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER &&
- $share->getSharedWith() === $this->currentUser) {
+ $share->getSharedWith() === $this->currentUser->getUID()) {
return true;
}
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP &&
- $share->getSharedWith()->inGroup($this->currentUser)) {
- return true;
+ if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
+ $sharedWith = $this->groupManager->get($share->getSharedWith());
+ if ($sharedWith->inGroup($this->currentUser)) {
+ return true;
+ }
}
return false;
diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js
index f2d6355d76a..bc609f04f79 100644
--- a/apps/files_sharing/js/public.js
+++ b/apps/files_sharing/js/public.js
@@ -155,11 +155,7 @@ OCA.Sharing.PublicApp = {
this.fileList.getDownloadUrl = function (filename, dir, isDir) {
var path = dir || this.getCurrentDirectory();
if (filename && !_.isArray(filename) && !isDir) {
- var portPart = '';
- if (OC.getPort()) {
- portPart = ':' + OC.getPort();
- }
- return OC.getProtocol() + '://' + token + '@' + OC.getHost() + portPart + OC.getRootPath() + '/public.php/webdav' + OC.joinPaths(path, filename);
+ return OC.getProtocol() + '://' + token + '@' + OC.getHost() + OC.getRootPath() + '/public.php/webdav' + OC.joinPaths(path, filename);
}
if (_.isArray(filename)) {
filename = JSON.stringify(filename);
diff --git a/apps/files_sharing/lib/controllers/sharecontroller.php b/apps/files_sharing/lib/controllers/sharecontroller.php
index 6ac585e275c..bbe68096b52 100644
--- a/apps/files_sharing/lib/controllers/sharecontroller.php
+++ b/apps/files_sharing/lib/controllers/sharecontroller.php
@@ -232,8 +232,8 @@ class ShareController extends Controller {
}
$shareTmpl = [];
- $shareTmpl['displayName'] = $share->getShareOwner()->getDisplayName();
- $shareTmpl['owner'] = $share->getShareOwner()->getUID();
+ $shareTmpl['displayName'] = $this->userManager->get($share->getShareOwner())->getDisplayName();
+ $shareTmpl['owner'] = $share->getShareOwner();
$shareTmpl['filename'] = $share->getNode()->getName();
$shareTmpl['directory_path'] = $share->getTarget();
$shareTmpl['mimetype'] = $share->getNode()->getMimetype();
@@ -320,7 +320,7 @@ class ShareController extends Controller {
}
}
- $userFolder = $this->rootFolder->getUserFolder($share->getShareOwner()->getUID());
+ $userFolder = $this->rootFolder->getUserFolder($share->getShareOwner());
$originalSharePath = $userFolder->getRelativePath($share->getNode()->getPath());
// Single file share
@@ -330,7 +330,7 @@ class ShareController extends Controller {
$event->setApp('files_sharing')
->setType(Activity::TYPE_PUBLIC_LINKS)
->setSubject(Activity::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED, [$userFolder->getRelativePath($share->getNode()->getPath())])
- ->setAffectedUser($share->getShareOwner()->getUID())
+ ->setAffectedUser($share->getShareOwner())
->setObject('files', $share->getNode()->getId(), $userFolder->getRelativePath($share->getNode()->getPath()));
$this->activityManager->publish($event);
}
@@ -356,7 +356,7 @@ class ShareController extends Controller {
$event->setApp('files_sharing')
->setType(Activity::TYPE_PUBLIC_LINKS)
->setSubject(Activity::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED, [$userFolder->getRelativePath($node->getPath())])
- ->setAffectedUser($share->getShareOwner()->getUID())
+ ->setAffectedUser($share->getShareOwner())
->setObject('files', $node->getId(), $userFolder->getRelativePath($node->getPath()));
$this->activityManager->publish($event);
} else if (!empty($files_list)) {
@@ -369,7 +369,7 @@ class ShareController extends Controller {
$event = $this->activityManager->generateEvent();
$event->setApp('files_sharing')
->setType(Activity::TYPE_PUBLIC_LINKS)
- ->setAffectedUser($share->getShareOwner()->getUID())
+ ->setAffectedUser($share->getShareOwner())
->setObject('files', $subNode->getId(), $userFolder->getRelativePath($subNode->getPath()));
if ($subNode instanceof \OCP\Files\File) {
@@ -386,7 +386,7 @@ class ShareController extends Controller {
$event->setApp('files_sharing')
->setType(Activity::TYPE_PUBLIC_LINKS)
->setSubject(Activity::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED, [$userFolder->getRelativePath($node->getPath())])
- ->setAffectedUser($share->getShareOwner()->getUID())
+ ->setAffectedUser($share->getShareOwner())
->setObject('files', $node->getId(), $userFolder->getRelativePath($node->getPath()));
$this->activityManager->publish($event);
}
@@ -394,7 +394,7 @@ class ShareController extends Controller {
/* FIXME: We should do this all nicely in OCP */
OC_Util::tearDownFS();
- OC_Util::setupFS($share->getShareOwner()->getUID());
+ OC_Util::setupFS($share->getShareOwner());
/**
* this sets a cookie to be able to recognize the start of the download
diff --git a/apps/files_sharing/tests/api/share20ocstest.php b/apps/files_sharing/tests/api/share20ocstest.php
index 1405f8f441a..a93cd5f58ce 100644
--- a/apps/files_sharing/tests/api/share20ocstest.php
+++ b/apps/files_sharing/tests/api/share20ocstest.php
@@ -55,7 +55,7 @@ class Share20OCSTest extends \Test\TestCase {
private $ocs;
protected function setUp() {
- $this->shareManager = $this->getMockBuilder('OC\Share20\Manager')
+ $this->shareManager = $this->getMockBuilder('OCP\Share\IManager')
->disableOriginalConstructor()
->getMock();
$this->groupManager = $this->getMock('OCP\IGroupManager');
@@ -91,6 +91,10 @@ class Share20OCSTest extends \Test\TestCase {
->getMock();
}
+ private function newShare() {
+ return \OC::$server->getShareManager()->newShare();
+ }
+
public function testDeleteShareShareNotFound() {
$this->shareManager
->expects($this->once())
@@ -103,8 +107,8 @@ class Share20OCSTest extends \Test\TestCase {
}
public function testDeleteShare() {
- $share = $this->getMock('OCP\Share\IShare');
- $share->method('getSharedBy')->willReturn($this->currentUser);
+ $share = $this->newShare();
+ $share->setSharedBy($this->currentUser->getUID());
$this->shareManager
->expects($this->once())
->method('getShareById')
@@ -137,7 +141,7 @@ class Share20OCSTest extends \Test\TestCase {
public function createShare($id, $shareType, $sharedWith, $sharedBy, $shareOwner, $path, $permissions,
$shareTime, $expiration, $parent, $target, $mail_send, $token=null,
$password=null) {
- $share = $this->getMock('OCP\Share\IShare');
+ $share = $this->getMock('\OCP\Share\IShare');
$share->method('getId')->willReturn($id);
$share->method('getShareType')->willReturn($shareType);
$share->method('getSharedWith')->willReturn($sharedWith);
@@ -166,21 +170,6 @@ class Share20OCSTest extends \Test\TestCase {
public function dataGetShare() {
$data = [];
- $initiator = $this->getMock('OCP\IUser');
- $initiator->method('getUID')->willReturn('initiatorId');
- $initiator->method('getDisplayName')->willReturn('initiatorDisplay');
-
- $owner = $this->getMock('OCP\IUser');
- $owner->method('getUID')->willReturn('ownerId');
- $owner->method('getDisplayName')->willReturn('ownerDisplay');
-
- $user = $this->getMock('OCP\IUser');
- $user->method('getUID')->willReturn('userId');
- $user->method('getDisplayName')->willReturn('userDisplay');
-
- $group = $this->getMock('OCP\IGroup');
- $group->method('getGID')->willReturn('groupId');
-
$cache = $this->getMockBuilder('OC\Files\Cache\Cache')
->disableOriginalConstructor()
->getMock();
@@ -211,9 +200,9 @@ class Share20OCSTest extends \Test\TestCase {
$share = $this->createShare(
100,
\OCP\Share::SHARE_TYPE_USER,
- $user,
- $initiator,
- $owner,
+ 'userId',
+ 'initiatorId',
+ 'ownerId',
$file,
4,
5,
@@ -252,9 +241,9 @@ class Share20OCSTest extends \Test\TestCase {
$share = $this->createShare(
101,
\OCP\Share::SHARE_TYPE_GROUP,
- $group,
- $initiator,
- $owner,
+ 'groupId',
+ 'initiatorId',
+ 'ownerId',
$folder,
4,
5,
@@ -295,8 +284,8 @@ class Share20OCSTest extends \Test\TestCase {
101,
\OCP\Share::SHARE_TYPE_LINK,
null,
- $initiator,
- $owner,
+ 'initiatorId',
+ 'ownerId',
$folder,
4,
5,
@@ -367,29 +356,53 @@ class Share20OCSTest extends \Test\TestCase {
->will($this->returnArgument(0));
$this->rootFolder->method('getUserFolder')
- ->with($share->getShareOwner()->getUID())
+ ->with($share->getShareOwner())
->willReturn($userFolder);
$this->urlGenerator
->method('linkToRouteAbsolute')
->willReturn('url');
+ $initiator = $this->getMock('OCP\IUser');
+ $initiator->method('getUID')->willReturn('initiatorId');
+ $initiator->method('getDisplayName')->willReturn('initiatorDisplay');
+
+ $owner = $this->getMock('OCP\IUser');
+ $owner->method('getUID')->willReturn('ownerId');
+ $owner->method('getDisplayName')->willReturn('ownerDisplay');
+
+ $user = $this->getMock('OCP\IUser');
+ $user->method('getUID')->willReturn('userId');
+ $user->method('getDisplayName')->willReturn('userDisplay');
+
+ $group = $this->getMock('OCP\IGroup');
+ $group->method('getGID')->willReturn('groupId');
+
+ $this->userManager->method('get')->will($this->returnValueMap([
+ ['userId', $user],
+ ['initiatorId', $initiator],
+ ['ownerId', $owner],
+ ]));
+ $this->groupManager->method('get')->will($this->returnValueMap([
+ ['group', $group],
+ ]));
+
$expected = new \OC_OCS_Result($result);
$this->assertEquals($expected->getData(), $ocs->getShare($share->getId())->getData());
}
public function testCanAccessShare() {
$share = $this->getMock('OCP\Share\IShare');
- $share->method('getShareOwner')->willReturn($this->currentUser);
+ $share->method('getShareOwner')->willReturn($this->currentUser->getUID());
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
$share = $this->getMock('OCP\Share\IShare');
- $share->method('getSharedBy')->willReturn($this->currentUser);
+ $share->method('getSharedBy')->willReturn($this->currentUser->getUID());
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
$share = $this->getMock('OCP\Share\IShare');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
- $share->method('getSharedWith')->willReturn($this->currentUser);
+ $share->method('getSharedWith')->willReturn($this->currentUser->getUID());
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
$share = $this->getMock('OCP\Share\IShare');
@@ -399,16 +412,25 @@ class Share20OCSTest extends \Test\TestCase {
$share = $this->getMock('OCP\Share\IShare');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
+ $share->method('getSharedWith')->willReturn('group');
+
$group = $this->getMock('OCP\IGroup');
$group->method('inGroup')->with($this->currentUser)->willReturn(true);
- $share->method('getSharedWith')->willReturn($group);
+ $group2 = $this->getMock('OCP\IGroup');
+ $group2->method('inGroup')->with($this->currentUser)->willReturn(false);
+
+
+ $this->groupManager->method('get')->will($this->returnValueMap([
+ ['group', $group],
+ ['group2', $group2],
+ ]));
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
$share = $this->getMock('OCP\Share\IShare');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
- $group = $this->getMock('OCP\IGroup');
- $group->method('inGroup')->with($this->currentUser)->willReturn(false);
- $share->method('getSharedWith')->willReturn($group);
+ $share->method('getSharedWith')->willReturn('group2');
+
+ $this->groupManager->method('get')->with('group2')->willReturn($group);
$this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
$share = $this->getMock('OCP\Share\IShare');
@@ -587,7 +609,6 @@ class Share20OCSTest extends \Test\TestCase {
$user = $this->getMock('\OCP\IUser');
$this->userManager->method('userExists')->with('validUser')->willReturn(true);
- $this->userManager->method('get')->with('validUser')->willReturn($user);
$share->method('setPath')->with($path);
$share->method('setPermissions')
@@ -596,8 +617,8 @@ class Share20OCSTest extends \Test\TestCase {
~\OCP\Constants::PERMISSION_DELETE &
~\OCP\Constants::PERMISSION_CREATE);
$share->method('setShareType')->with(\OCP\Share::SHARE_TYPE_USER);
- $share->method('setSharedWith')->with($user);
- $share->method('setSharedBy')->with($this->currentUser);
+ $share->method('setSharedWith')->with('validUser');
+ $share->method('setSharedBy')->with('currentUser');
$expected = new \OC_OCS_Result();
$result = $ocs->createShare();
@@ -680,13 +701,12 @@ class Share20OCSTest extends \Test\TestCase {
$group = $this->getMock('\OCP\IGroup');
$this->groupManager->method('groupExists')->with('validGroup')->willReturn(true);
- $this->groupManager->method('get')->with('validGroup')->willReturn($group);
$share->method('setPath')->with($path);
$share->method('setPermissions')->with(\OCP\Constants::PERMISSION_ALL);
$share->method('setShareType')->with(\OCP\Share::SHARE_TYPE_GROUP);
- $share->method('setSharedWith')->with($group);
- $share->method('setSharedBy')->with($this->currentUser);
+ $share->method('setSharedWith')->with('validGroup');
+ $share->method('setSharedBy')->with('currentUser');
$expected = new \OC_OCS_Result();
$result = $ocs->createShare();
@@ -784,14 +804,12 @@ class Share20OCSTest extends \Test\TestCase {
$this->shareManager->method('shareApiAllowLinks')->willReturn(true);
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
- $currentUser = $this->currentUser;
-
$this->shareManager->expects($this->once())->method('createShare')->with(
- $this->callback(function (\OCP\Share\IShare $share) use ($path, $currentUser) {
+ $this->callback(function (\OCP\Share\IShare $share) use ($path) {
return $share->getNode() === $path &&
$share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
$share->getPermissions() === \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_DELETE &&
- $share->getSharedBy() === $currentUser &&
+ $share->getSharedBy() === 'currentUser' &&
$share->getPassword() === null &&
$share->getExpirationDate() === null;
})
@@ -825,14 +843,12 @@ class Share20OCSTest extends \Test\TestCase {
$this->shareManager->method('shareApiAllowLinks')->willReturn(true);
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
- $currentUser = $this->currentUser;
-
$this->shareManager->expects($this->once())->method('createShare')->with(
- $this->callback(function (\OCP\Share\IShare $share) use ($path, $currentUser) {
+ $this->callback(function (\OCP\Share\IShare $share) use ($path) {
return $share->getNode() === $path &&
$share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
$share->getPermissions() === \OCP\Constants::PERMISSION_READ &&
- $share->getSharedBy() === $currentUser &&
+ $share->getSharedBy() === 'currentUser' &&
$share->getPassword() === 'password' &&
$share->getExpirationDate() === null;
})
@@ -866,17 +882,15 @@ class Share20OCSTest extends \Test\TestCase {
$this->shareManager->method('shareApiAllowLinks')->willReturn(true);
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
- $currentUser = $this->currentUser;
-
$this->shareManager->expects($this->once())->method('createShare')->with(
- $this->callback(function (\OCP\Share\IShare $share) use ($path, $currentUser) {
+ $this->callback(function (\OCP\Share\IShare $share) use ($path) {
$date = new \DateTime('2000-01-01');
$date->setTime(0,0,0);
return $share->getNode() === $path &&
$share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
$share->getPermissions() === \OCP\Constants::PERMISSION_READ &&
- $share->getSharedBy() === $currentUser &&
+ $share->getSharedBy() === 'currentUser' &&
$share->getPassword() === null &&
$share->getExpirationDate() == $date;
})
@@ -932,7 +946,7 @@ class Share20OCSTest extends \Test\TestCase {
public function testUpdateNoParametersLink() {
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
- ->setSharedBy($this->currentUser)
+ ->setSharedBy($this->currentUser->getUID())
->setShareType(\OCP\Share::SHARE_TYPE_LINK);
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
@@ -947,7 +961,7 @@ class Share20OCSTest extends \Test\TestCase {
public function testUpdateNoParametersOther() {
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
- ->setSharedBy($this->currentUser)
+ ->setSharedBy($this->currentUser->getUID())
->setShareType(\OCP\Share::SHARE_TYPE_GROUP);
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
@@ -964,7 +978,7 @@ class Share20OCSTest extends \Test\TestCase {
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
- ->setSharedBy($this->currentUser)
+ ->setSharedBy($this->currentUser->getUID())
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setPassword('password')
->setExpirationDate(new \DateTime())
@@ -1002,7 +1016,7 @@ class Share20OCSTest extends \Test\TestCase {
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
- ->setSharedBy($this->currentUser)
+ ->setSharedBy($this->currentUser->getUID())
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setNode($folder);
@@ -1042,7 +1056,7 @@ class Share20OCSTest extends \Test\TestCase {
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
- ->setSharedBy($this->currentUser)
+ ->setSharedBy($this->currentUser->getUID())
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setNode($folder);
@@ -1071,7 +1085,7 @@ class Share20OCSTest extends \Test\TestCase {
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
- ->setSharedBy($this->currentUser)
+ ->setSharedBy($this->currentUser->getUID())
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setNode($folder);
@@ -1100,7 +1114,7 @@ class Share20OCSTest extends \Test\TestCase {
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
- ->setSharedBy($this->currentUser)
+ ->setSharedBy($this->currentUser->getUID())
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setNode($file);
@@ -1130,7 +1144,7 @@ class Share20OCSTest extends \Test\TestCase {
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
- ->setSharedBy($this->currentUser)
+ ->setSharedBy($this->currentUser->getUID())
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setPassword('password')
->setExpirationDate($date)
@@ -1164,7 +1178,7 @@ class Share20OCSTest extends \Test\TestCase {
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
- ->setSharedBy($this->currentUser)
+ ->setSharedBy($this->currentUser->getUID())
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setPassword('password')
->setExpirationDate(new \DateTime())
@@ -1205,7 +1219,7 @@ class Share20OCSTest extends \Test\TestCase {
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
- ->setSharedBy($this->currentUser)
+ ->setSharedBy($this->currentUser->getUID())
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setPassword('password')
->setExpirationDate($date)
@@ -1245,7 +1259,7 @@ class Share20OCSTest extends \Test\TestCase {
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
- ->setSharedBy($this->currentUser)
+ ->setSharedBy($this->currentUser->getUID())
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setPassword('password')
->setExpirationDate($date)
@@ -1285,7 +1299,7 @@ class Share20OCSTest extends \Test\TestCase {
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
- ->setSharedBy($this->currentUser)
+ ->setSharedBy($this->currentUser->getUID())
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setPassword('password')
->setExpirationDate($date)
@@ -1315,7 +1329,7 @@ class Share20OCSTest extends \Test\TestCase {
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
- ->setSharedBy($this->currentUser)
+ ->setSharedBy($this->currentUser->getUID())
->setShareType(\OCP\Share::SHARE_TYPE_USER)
->setNode($file);
diff --git a/apps/files_sharing/tests/controller/sharecontroller.php b/apps/files_sharing/tests/controller/sharecontroller.php
index e36ee9e4914..22e15972cd6 100644
--- a/apps/files_sharing/tests/controller/sharecontroller.php
+++ b/apps/files_sharing/tests/controller/sharecontroller.php
@@ -35,6 +35,7 @@ use OCP\AppFramework\Http\NotFoundResponse;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\ISession;
+use OCP\IUserManager;
use OCP\Security\ISecureRandom;
use OCP\IURLGenerator;
@@ -64,6 +65,8 @@ class ShareControllerTest extends \Test\TestCase {
private $config;
/** @var \OC\Share20\Manager | \PHPUnit_Framework_MockObject_MockObject */
private $shareManager;
+ /** @var IUserManager | \PHPUnit_Framework_MockObject_MockObject */
+ private $userManager;
protected function setUp() {
$this->appName = 'files_sharing';
@@ -73,13 +76,14 @@ class ShareControllerTest extends \Test\TestCase {
$this->session = $this->getMock('\OCP\ISession');
$this->previewManager = $this->getMock('\OCP\IPreview');
$this->config = $this->getMock('\OCP\IConfig');
+ $this->userManager = $this->getMock('\OCP\IUserManager');
$this->shareController = new \OCA\Files_Sharing\Controllers\ShareController(
$this->appName,
$this->getMock('\OCP\IRequest'),
$this->config,
$this->urlGenerator,
- $this->getMock('\OCP\IUserManager'),
+ $this->userManager,
$this->getMock('\OCP\ILogger'),
$this->getMock('\OCP\Activity\IManager'),
$this->shareManager,
@@ -116,7 +120,7 @@ class ShareControllerTest extends \Test\TestCase {
}
public function testShowAuthenticateNotAuthenticated() {
- $share = $this->getMock('\OCP\Share\IShare');
+ $share = \OC::$server->getShareManager()->newShare();
$this->shareManager
->expects($this->once())
@@ -130,8 +134,8 @@ class ShareControllerTest extends \Test\TestCase {
}
public function testShowAuthenticateAuthenticatedForDifferentShare() {
- $share = $this->getMock('\OCP\Share\IShare');
- $share->method('getId')->willReturn(1);
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setId(1);
$this->shareManager
->expects($this->once())
@@ -148,8 +152,8 @@ class ShareControllerTest extends \Test\TestCase {
}
public function testShowAuthenticateCorrectShare() {
- $share = $this->getMock('\OCP\Share\IShare');
- $share->method('getId')->willReturn(1);
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setId(1);
$this->shareManager
->expects($this->once())
@@ -183,8 +187,8 @@ class ShareControllerTest extends \Test\TestCase {
}
public function testAuthenticateValidPassword() {
- $share = $this->getMock('\OCP\Share\IShare');
- $share->method('getId')->willReturn(42);
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setId(42);
$this->shareManager
->expects($this->once())
@@ -214,8 +218,8 @@ class ShareControllerTest extends \Test\TestCase {
}
public function testAuthenticateInvalidPassword() {
- $share = $this->getMock('\OCP\Share\IShare');
- $share->method('getId')->willReturn(42);
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setId(42);
$this->shareManager
->expects($this->once())
@@ -252,8 +256,8 @@ class ShareControllerTest extends \Test\TestCase {
}
public function testShowShareNotAuthenticated() {
- $share = $this->getMock('\OCP\Share\IShare');
- $share->method('getPassword')->willReturn('password');
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setPassword('password');
$this->shareManager
->expects($this->once())
@@ -283,12 +287,12 @@ class ShareControllerTest extends \Test\TestCase {
$file->method('getMimetype')->willReturn('text/plain');
$file->method('getSize')->willReturn(33);
- $share = $this->getMock('\OCP\Share\IShare');
- $share->method('getId')->willReturn('42');
- $share->method('getPassword')->willReturn('password');
- $share->method('getShareOwner')->willReturn($owner);
- $share->method('getNode')->willReturn($file);
- $share->method('getTarget')->willReturn('/file1.txt');
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setId(42);
+ $share->setPassword('password')
+ ->setShareOwner('ownerUID')
+ ->setNode($file)
+ ->setTarget('/file1.txt');
$this->session->method('exists')->with('public_link_authenticated')->willReturn(true);
$this->session->method('get')->with('public_link_authenticated')->willReturn('42');
@@ -311,6 +315,8 @@ class ShareControllerTest extends \Test\TestCase {
->with('token')
->willReturn($share);
+ $this->userManager->method('get')->with('ownerUID')->willReturn($owner);
+
$response = $this->shareController->showShare('token');
$sharedTmplParams = array(
'displayName' => 'ownerDisplay',
diff --git a/apps/files_sharing/tests/js/publicAppSpec.js b/apps/files_sharing/tests/js/publicAppSpec.js
index 17b7ffc9798..8561836d77c 100644
--- a/apps/files_sharing/tests/js/publicAppSpec.js
+++ b/apps/files_sharing/tests/js/publicAppSpec.js
@@ -21,13 +21,12 @@
describe('OCA.Sharing.PublicApp tests', function() {
var App = OCA.Sharing.PublicApp;
- var hostStub, portStub, protocolStub, webrootStub;
+ var hostStub, protocolStub, webrootStub;
var $preview;
beforeEach(function() {
protocolStub = sinon.stub(OC, 'getProtocol').returns('https');
- hostStub = sinon.stub(OC, 'getHost').returns('example.com');
- portStub = sinon.stub(OC, 'getPort').returns(9876);
+ hostStub = sinon.stub(OC, 'getHost').returns('example.com:9876');
webrootStub = sinon.stub(OC, 'getRootPath').returns('/owncloud');
$preview = $('<div id="preview"></div>');
$('#testArea').append($preview);
@@ -41,7 +40,6 @@ describe('OCA.Sharing.PublicApp tests', function() {
afterEach(function() {
protocolStub.restore();
hostStub.restore();
- portStub.restore();
webrootStub.restore();
});
@@ -91,7 +89,7 @@ describe('OCA.Sharing.PublicApp tests', function() {
it('Uses public webdav endpoint', function() {
expect(fakeServer.requests.length).toEqual(1);
expect(fakeServer.requests[0].method).toEqual('PROPFIND');
- expect(fakeServer.requests[0].url).toEqual('https://example.com/owncloud/public.php/webdav/subdir');
+ expect(fakeServer.requests[0].url).toEqual('https://example.com:9876/owncloud/public.php/webdav/subdir');
expect(fakeServer.requests[0].requestHeaders.Authorization).toEqual('Basic c2g0dG9rOm51bGw=');
});
diff --git a/apps/systemtags/appinfo/info.xml b/apps/systemtags/appinfo/info.xml
index 5da945db703..d0b4c1fce00 100644
--- a/apps/systemtags/appinfo/info.xml
+++ b/apps/systemtags/appinfo/info.xml
@@ -10,9 +10,6 @@
<dependencies>
<owncloud min-version="9.0" max-version="9.0" />
</dependencies>
- <documentation>
- <user>user-systemtags</user>
- </documentation>
<types>
<logging/>
</types>
diff --git a/core/img/actions/comment.png b/core/img/actions/comment.png
new file mode 100644
index 00000000000..7ca20eba363
--- /dev/null
+++ b/core/img/actions/comment.png
Binary files differ
diff --git a/core/img/actions/comment.svg b/core/img/actions/comment.svg
new file mode 100644
index 00000000000..a8ab95e615b
--- /dev/null
+++ b/core/img/actions/comment.svg
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="16" width="16" version="1.0" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <path style="color:#000000;block-progression:tb;text-transform:none;text-indent:0" d="m2.3496 1.002c-0.1975 0.0382-0.3531 0.2333-0.3496 0.4375v13.122c0 0.23 0.2061 0.438 0.4316 0.438h11.138c0.226 0 0.432-0.208 0.432-0.438v-10.142c-0.004-0.0669-0.023-0.133-0.055-0.1915l-3.312-3.1992c-0.043-0.0164-0.089-0.0255-0.135-0.0273h-8.0684c-0.0268-0.00265-0.0552-0.00265-0.082 0zm1.6504 1.998h6v1h-6v-1zm0 3h5v1h-5v-1zm0 3h8v1h-8v-1zm0 3h4v1h-4v-1z"/>
+</svg>
diff --git a/core/js/js.js b/core/js/js.js
index bc8c51e40d3..83658a537b8 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -243,9 +243,15 @@ var OC={
},
/**
- * Returns the host name used to access this ownCloud instance
+ * Returns the host used to access this ownCloud instance
+ * Host is sometimes the same as the hostname but now always.
*
- * @return {string} host name
+ * Examples:
+ * http://example.com => example.com
+ * https://example.com => exmaple.com
+ * http://example.com:8080 => example.com:8080
+ *
+ * @return {string} host
*
* @since 8.2
*/
@@ -254,6 +260,17 @@ var OC={
},
/**
+ * Returns the hostname used to access this ownCloud instance
+ * The hostname is always stripped of the port
+ *
+ * @return {string} hostname
+ * @since 9.0
+ */
+ getHostName: function() {
+ return window.location.hostname;
+ },
+
+ /**
* Returns the port number used to access this ownCloud instance
*
* @return {int} port number
diff --git a/core/shipped.json b/core/shipped.json
index 5f995326625..069bb210ba7 100644
--- a/core/shipped.json
+++ b/core/shipped.json
@@ -13,7 +13,6 @@
"files_drop",
"files_external",
"files_ldap_home",
- "files_locking",
"files_pdfviewer",
"files_sharing",
"files_sharing_log",
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php
index cbe48f21bd8..22b9f49e528 100644
--- a/lib/private/files/cache/cache.php
+++ b/lib/private/files/cache/cache.php
@@ -201,7 +201,7 @@ class Cache implements ICache {
}
/**
- * store meta data for a file or folder
+ * insert or update meta data for a file or folder
*
* @param string $file
* @param array $data
@@ -214,49 +214,62 @@ class Cache implements ICache {
$this->update($id, $data);
return $id;
} else {
- // normalize file
- $file = $this->normalize($file);
+ return $this->insert($file, $data);
+ }
+ }
- if (isset($this->partial[$file])) { //add any saved partial data
- $data = array_merge($this->partial[$file], $data);
- unset($this->partial[$file]);
- }
+ /**
+ * insert meta data for a new file or folder
+ *
+ * @param string $file
+ * @param array $data
+ *
+ * @return int file id
+ * @throws \RuntimeException
+ */
+ public function insert($file, array $data) {
+ // normalize file
+ $file = $this->normalize($file);
- $requiredFields = array('size', 'mtime', 'mimetype');
- foreach ($requiredFields as $field) {
- if (!isset($data[$field])) { //data not complete save as partial and return
- $this->partial[$file] = $data;
- return -1;
- }
- }
+ if (isset($this->partial[$file])) { //add any saved partial data
+ $data = array_merge($this->partial[$file], $data);
+ unset($this->partial[$file]);
+ }
- $data['path'] = $file;
- $data['parent'] = $this->getParentId($file);
- $data['name'] = \OC_Util::basename($file);
-
- list($queryParts, $params) = $this->buildParts($data);
- $queryParts[] = '`storage`';
- $params[] = $this->getNumericStorageId();
-
- $queryParts = array_map(function ($item) {
- return trim($item, "`");
- }, $queryParts);
- $values = array_combine($queryParts, $params);
- if (\OC::$server->getDatabaseConnection()->insertIfNotExist('*PREFIX*filecache', $values, [
- 'storage',
- 'path_hash',
- ])
- ) {
- return (int)$this->connection->lastInsertId('*PREFIX*filecache');
+ $requiredFields = array('size', 'mtime', 'mimetype');
+ foreach ($requiredFields as $field) {
+ if (!isset($data[$field])) { //data not complete save as partial and return
+ $this->partial[$file] = $data;
+ return -1;
}
+ }
- // The file was created in the mean time
- if (($id = $this->getId($file)) > -1) {
- $this->update($id, $data);
- return $id;
- } else {
- throw new \RuntimeException('File entry could not be inserted with insertIfNotExist() but could also not be selected with getId() in order to perform an update. Please try again.');
- }
+ $data['path'] = $file;
+ $data['parent'] = $this->getParentId($file);
+ $data['name'] = \OC_Util::basename($file);
+
+ list($queryParts, $params) = $this->buildParts($data);
+ $queryParts[] = '`storage`';
+ $params[] = $this->getNumericStorageId();
+
+ $queryParts = array_map(function ($item) {
+ return trim($item, "`");
+ }, $queryParts);
+ $values = array_combine($queryParts, $params);
+ if (\OC::$server->getDatabaseConnection()->insertIfNotExist('*PREFIX*filecache', $values, [
+ 'storage',
+ 'path_hash',
+ ])
+ ) {
+ return (int)$this->connection->lastInsertId('*PREFIX*filecache');
+ }
+
+ // The file was created in the mean time
+ if (($id = $this->getId($file)) > -1) {
+ $this->update($id, $data);
+ return $id;
+ } else {
+ throw new \RuntimeException('File entry could not be inserted with insertIfNotExist() but could also not be selected with getId() in order to perform an update. Please try again.');
}
}
diff --git a/lib/private/files/cache/wrapper/cachejail.php b/lib/private/files/cache/wrapper/cachejail.php
index 32bd3626fcb..868e63cdf81 100644
--- a/lib/private/files/cache/wrapper/cachejail.php
+++ b/lib/private/files/cache/wrapper/cachejail.php
@@ -95,15 +95,16 @@ class CacheJail extends CacheWrapper {
}
/**
- * store meta data for a file or folder
+ * insert meta data for a new file or folder
*
* @param string $file
* @param array $data
*
* @return int file id
+ * @throws \RuntimeException
*/
- public function put($file, array $data) {
- return $this->cache->put($this->getSourcePath($file), $data);
+ public function insert($file, array $data) {
+ return $this->cache->insert($this->getSourcePath($file), $data);
}
/**
diff --git a/lib/private/files/cache/wrapper/cachewrapper.php b/lib/private/files/cache/wrapper/cachewrapper.php
index 1ce4f028c75..4080883419e 100644
--- a/lib/private/files/cache/wrapper/cachewrapper.php
+++ b/lib/private/files/cache/wrapper/cachewrapper.php
@@ -90,15 +90,34 @@ class CacheWrapper extends Cache {
}
/**
- * store meta data for a file or folder
+ * insert or update meta data for a file or folder
*
* @param string $file
* @param array $data
*
* @return int file id
+ * @throws \RuntimeException
*/
public function put($file, array $data) {
- return $this->cache->put($file, $data);
+ if (($id = $this->getId($file)) > -1) {
+ $this->update($id, $data);
+ return $id;
+ } else {
+ return $this->insert($file, $data);
+ }
+ }
+
+ /**
+ * insert meta data for a new file or folder
+ *
+ * @param string $file
+ * @param array $data
+ *
+ * @return int file id
+ * @throws \RuntimeException
+ */
+ public function insert($file, array $data) {
+ return $this->cache->insert($file, $data);
}
/**
diff --git a/lib/private/server.php b/lib/private/server.php
index d3dbcba86ba..69406c2203f 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -617,7 +617,8 @@ class Server extends ServerContainer implements IServerContainer {
$c->getMountManager(),
$c->getGroupManager(),
$c->getL10N('core'),
- $factory
+ $factory,
+ $c->getUserManager()
);
return $manager;
diff --git a/lib/private/share20/defaultshareprovider.php b/lib/private/share20/defaultshareprovider.php
index 7b78be2b61d..38d1dae316d 100644
--- a/lib/private/share20/defaultshareprovider.php
+++ b/lib/private/share20/defaultshareprovider.php
@@ -29,7 +29,6 @@ use OC\Share20\Exception\BackendError;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Files\NotFoundException;
use OCP\IGroup;
-use OCP\IUser;
use OCP\IGroupManager;
use OCP\IUserManager;
use OCP\Files\IRootFolder;
@@ -102,14 +101,10 @@ class DefaultShareProvider implements IShareProvider {
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
//Set the UID of the user we share with
- /** @var IUser $sharedWith */
- $sharedWith = $share->getSharedWith();
- $qb->setValue('share_with', $qb->createNamedParameter($sharedWith->getUID()));
+ $qb->setValue('share_with', $qb->createNamedParameter($share->getSharedWith()));
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
//Set the GID of the group we share with
- /** @var IGroup $sharedWith */
- $sharedWith = $share->getSharedWith();
- $qb->setValue('share_with', $qb->createNamedParameter($sharedWith->getGID()));
+ $qb->setValue('share_with', $qb->createNamedParameter($share->getSharedWith()));
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
//Set the token of the share
$qb->setValue('token', $qb->createNamedParameter($share->getToken()));
@@ -143,10 +138,10 @@ class DefaultShareProvider implements IShareProvider {
$qb->setValue('permissions', $qb->createNamedParameter($share->getPermissions()));
// Set who created this share
- $qb->setValue('uid_initiator', $qb->createNamedParameter($share->getSharedBy()->getUID()));
+ $qb->setValue('uid_initiator', $qb->createNamedParameter($share->getSharedBy()));
// Set who is the owner of this file/folder (and this the owner of the share)
- $qb->setValue('uid_owner', $qb->createNamedParameter($share->getShareOwner()->getUID()));
+ $qb->setValue('uid_owner', $qb->createNamedParameter($share->getShareOwner()));
// Set the file target
$qb->setValue('file_target', $qb->createNamedParameter($share->getTarget()));
@@ -192,9 +187,9 @@ class DefaultShareProvider implements IShareProvider {
$qb = $this->dbConn->getQueryBuilder();
$qb->update('share')
->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId())))
- ->set('share_with', $qb->createNamedParameter($share->getSharedWith()->getUID()))
- ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()->getUID()))
- ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()->getUID()))
+ ->set('share_with', $qb->createNamedParameter($share->getSharedWith()))
+ ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()))
+ ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()))
->set('permissions', $qb->createNamedParameter($share->getPermissions()))
->set('item_source', $qb->createNamedParameter($share->getNode()->getId()))
->set('file_source', $qb->createNamedParameter($share->getNode()->getId()))
@@ -203,8 +198,8 @@ class DefaultShareProvider implements IShareProvider {
$qb = $this->dbConn->getQueryBuilder();
$qb->update('share')
->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId())))
- ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()->getUID()))
- ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()->getUID()))
+ ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()))
+ ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()))
->set('permissions', $qb->createNamedParameter($share->getPermissions()))
->set('item_source', $qb->createNamedParameter($share->getNode()->getId()))
->set('file_source', $qb->createNamedParameter($share->getNode()->getId()))
@@ -216,8 +211,8 @@ class DefaultShareProvider implements IShareProvider {
$qb = $this->dbConn->getQueryBuilder();
$qb->update('share')
->where($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId())))
- ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()->getUID()))
- ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()->getUID()))
+ ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()))
+ ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()))
->set('item_source', $qb->createNamedParameter($share->getNode()->getId()))
->set('file_source', $qb->createNamedParameter($share->getNode()->getId()))
->execute();
@@ -237,8 +232,8 @@ class DefaultShareProvider implements IShareProvider {
$qb->update('share')
->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId())))
->set('share_with', $qb->createNamedParameter($share->getPassword()))
- ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()->getUID()))
- ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()->getUID()))
+ ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()))
+ ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()))
->set('permissions', $qb->createNamedParameter($share->getPermissions()))
->set('item_source', $qb->createNamedParameter($share->getNode()->getId()))
->set('file_source', $qb->createNamedParameter($share->getNode()->getId()))
@@ -255,7 +250,7 @@ class DefaultShareProvider implements IShareProvider {
* FIXME: remove once https://github.com/owncloud/core/pull/21660 is in
*
* @param \OCP\Share\IShare $parent
- * @return IShare[]
+ * @return \OCP\Share\IShare[]
*/
public function getChildren(\OCP\Share\IShare $parent) {
$children = [];
@@ -311,17 +306,17 @@ class DefaultShareProvider implements IShareProvider {
* this means we need a special entry in the share db.
*
* @param \OCP\Share\IShare $share
- * @param IUser $recipient
+ * @param string $recipient UserId of recipient
* @throws BackendError
* @throws ProviderException
*/
- public function deleteFromSelf(\OCP\Share\IShare $share, IUser $recipient) {
+ public function deleteFromSelf(\OCP\Share\IShare $share, $recipient) {
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
- /** @var IGroup $group */
- $group = $share->getSharedWith();
+ $group = $this->groupManager->get($share->getSharedWith());
+ $user = $this->userManager->get($recipient);
- if (!$group->inGroup($recipient)) {
+ if (!$group->inGroup($user)) {
throw new ProviderException('Recipient not in receiving group');
}
@@ -330,7 +325,7 @@ class DefaultShareProvider implements IShareProvider {
$stmt = $qb->select('*')
->from('share')
->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP)))
- ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($recipient->getUID())))
+ ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($recipient)))
->andWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId())))
->execute();
@@ -349,9 +344,9 @@ class DefaultShareProvider implements IShareProvider {
$qb->insert('share')
->values([
'share_type' => $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP),
- 'share_with' => $qb->createNamedParameter($recipient->getUID()),
- 'uid_owner' => $qb->createNamedParameter($share->getShareOwner()->getUID()),
- 'uid_initiator' => $qb->createNamedParameter($share->getSharedBy()->getUID()),
+ 'share_with' => $qb->createNamedParameter($recipient),
+ 'uid_owner' => $qb->createNamedParameter($share->getShareOwner()),
+ 'uid_initiator' => $qb->createNamedParameter($share->getSharedBy()),
'parent' => $qb->createNamedParameter($share->getId()),
'item_type' => $qb->createNamedParameter($type),
'item_source' => $qb->createNamedParameter($share->getNode()->getId()),
@@ -387,7 +382,7 @@ class DefaultShareProvider implements IShareProvider {
/**
* @inheritdoc
*/
- public function move(\OCP\Share\IShare $share, IUser $recipient) {
+ public function move(\OCP\Share\IShare $share, $recipient) {
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
// Just update the target
$qb = $this->dbConn->getQueryBuilder();
@@ -403,7 +398,7 @@ class DefaultShareProvider implements IShareProvider {
$stmt = $qb->select('id')
->from('share')
->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP)))
- ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($recipient->getUID())))
+ ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($recipient)))
->andWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId())))
->setMaxResults(1)
->execute();
@@ -417,9 +412,9 @@ class DefaultShareProvider implements IShareProvider {
$qb->insert('share')
->values([
'share_type' => $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP),
- 'share_with' => $qb->createNamedParameter($recipient->getUID()),
- 'uid_owner' => $qb->createNamedParameter($share->getShareOwner()->getUID()),
- 'uid_initiator' => $qb->createNamedParameter($share->getSharedBy()->getUID()),
+ 'share_with' => $qb->createNamedParameter($recipient),
+ 'uid_owner' => $qb->createNamedParameter($share->getShareOwner()),
+ 'uid_initiator' => $qb->createNamedParameter($share->getSharedBy()),
'parent' => $qb->createNamedParameter($share->getId()),
'item_type' => $qb->createNamedParameter($share->getNode() instanceof File ? 'file' : 'folder'),
'item_source' => $qb->createNamedParameter($share->getNode()->getId()),
@@ -444,7 +439,7 @@ class DefaultShareProvider implements IShareProvider {
/**
* Get all shares by the given user. Sharetype and path can be used to filter.
*
- * @param IUser $user
+ * @param string $userId
* @param int $shareType
* @param \OCP\Files\File|\OCP\Files\Folder $node
* @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator
@@ -452,7 +447,7 @@ class DefaultShareProvider implements IShareProvider {
* @param int $offset
* @return Share[]
*/
- public function getSharesBy(IUser $user, $shareType, $node, $reshares, $limit, $offset) {
+ public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset) {
$qb = $this->dbConn->getQueryBuilder();
$qb->select('*')
->from('share');
@@ -465,21 +460,21 @@ class DefaultShareProvider implements IShareProvider {
if ($reshares === false) {
//Special case for old shares created via the web UI
$or1 = $qb->expr()->andX(
- $qb->expr()->eq('uid_owner', $qb->createNamedParameter($user->getUID())),
+ $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)),
$qb->expr()->isNull('uid_initiator')
);
$qb->andWhere(
$qb->expr()->orX(
- $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($user->getUID())),
+ $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)),
$or1
)
);
} else {
$qb->andWhere(
$qb->expr()->orX(
- $qb->expr()->eq('uid_owner', $qb->createNamedParameter($user->getUID())),
- $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($user->getUID()))
+ $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)),
+ $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId))
)
);
}
@@ -508,7 +503,7 @@ class DefaultShareProvider implements IShareProvider {
/**
* @inheritdoc
*/
- public function getShareById($id, $recipient = null) {
+ public function getShareById($id, $recipientId = null) {
$qb = $this->dbConn->getQueryBuilder();
$qb->select('*')
@@ -540,8 +535,8 @@ class DefaultShareProvider implements IShareProvider {
}
// If the recipient is set for a group share resolve to that user
- if ($recipient !== null && $share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
- $share = $this->resolveGroupShare($share, $recipient);
+ if ($recipientId !== null && $share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
+ $share = $this->resolveGroupShare($share, $recipientId);
}
return $share;
@@ -551,7 +546,7 @@ class DefaultShareProvider implements IShareProvider {
* Get shares for a given path
*
* @param \OCP\Files\Node $path
- * @return IShare[]
+ * @return \OCP\Share\IShare[]
*/
public function getSharesByPath(Node $path) {
$qb = $this->dbConn->getQueryBuilder();
@@ -578,7 +573,7 @@ class DefaultShareProvider implements IShareProvider {
/**
* @inheritdoc
*/
- public function getSharedWith(IUser $user, $shareType, $node, $limit, $offset) {
+ public function getSharedWith($userId, $shareType, $node, $limit, $offset) {
/** @var Share[] $shares */
$shares = [];
@@ -598,7 +593,7 @@ class DefaultShareProvider implements IShareProvider {
$qb->setFirstResult($offset);
$qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_USER)));
- $qb->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($user->getUID())));
+ $qb->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($userId)));
// Filter by node if provided
if ($node !== null) {
@@ -613,6 +608,7 @@ class DefaultShareProvider implements IShareProvider {
$cursor->closeCursor();
} else if ($shareType === \OCP\Share::SHARE_TYPE_GROUP) {
+ $user = $this->userManager->get($userId);
$allGroups = $this->groupManager->getUserGroups($user);
/** @var Share[] $shares2 */
@@ -666,7 +662,7 @@ class DefaultShareProvider implements IShareProvider {
* TODO: Optmize this!
*/
foreach($shares2 as $share) {
- $shares[] = $this->resolveGroupShare($share, $user);
+ $shares[] = $this->resolveGroupShare($share, $userId);
}
} else {
throw new BackendError('Invalid backend');
@@ -680,7 +676,7 @@ class DefaultShareProvider implements IShareProvider {
* Get a share by token
*
* @param string $token
- * @return IShare
+ * @return \OCP\Share\IShare
* @throws ShareNotFound
*/
public function getShareByToken($token) {
@@ -727,17 +723,9 @@ class DefaultShareProvider implements IShareProvider {
$share->setShareTime($shareTime);
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
- $sharedWith = $this->userManager->get($data['share_with']);
- if ($sharedWith === null) {
- throw new InvalidShare();
- }
- $share->setSharedWith($sharedWith);
+ $share->setSharedWith($data['share_with']);
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
- $sharedWith = $this->groupManager->get($data['share_with']);
- if ($sharedWith === null) {
- throw new InvalidShare();
- }
- $share->setSharedWith($sharedWith);
+ $share->setSharedWith($data['share_with']);
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
$share->setPassword($data['share_with']);
$share->setToken($data['token']);
@@ -745,24 +733,15 @@ class DefaultShareProvider implements IShareProvider {
if ($data['uid_initiator'] === null) {
//OLD SHARE
- $sharedBy = $this->userManager->get($data['uid_owner']);
- if ($sharedBy === null) {
- throw new InvalidShare();
- }
- $share->setSharedBy($sharedBy);
+ $share->setSharedBy($data['uid_owner']);
$path = $this->getNode($share->getSharedBy(), (int)$data['file_source']);
$owner = $path->getOwner();
- $share->setShareOwner($owner);
+ $share->setShareOwner($owner->getUID());
} else {
//New share!
- $sharedBy = $this->userManager->get($data['uid_initiator']);
- $shareOwner = $this->userManager->get($data['uid_owner']);
- if ($sharedBy === null || $shareOwner === null) {
- throw new InvalidShare();
- }
- $share->setSharedBy($sharedBy);
- $share->setShareOwner($shareOwner);
+ $share->setSharedBy($data['uid_initiator']);
+ $share->setShareOwner($data['uid_owner']);
}
$path = $this->getNode($share->getShareOwner(), (int)$data['file_source']);
@@ -781,14 +760,14 @@ class DefaultShareProvider implements IShareProvider {
/**
* Get the node with file $id for $user
*
- * @param IUser $user
+ * @param string $user The userId
* @param int $id
* @return \OCP\Files\File|\OCP\Files\Folder
* @throws InvalidShare
*/
- private function getNode(IUser $user, $id) {
+ private function getNode($user, $id) {
try {
- $userFolder = $this->rootFolder->getUserFolder($user->getUID());
+ $userFolder = $this->rootFolder->getUserFolder($user);
} catch (NotFoundException $e) {
throw new InvalidShare();
}
@@ -806,18 +785,18 @@ class DefaultShareProvider implements IShareProvider {
* Resolve a group share to a user specific share
* Thus if the user moved their group share make sure this is properly reflected here.
*
- * @param Share $share
- * @param IUser $user
+ * @param \OCP\Share\IShare $share
+ * @param string $userId
* @return Share Returns the updated share if one was found else return the original share.
*/
- private function resolveGroupShare(Share $share, IUser $user) {
+ private function resolveGroupShare(\OCP\Share\IShare $share, $userId) {
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->select('*')
->from('share')
->where($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId())))
->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP)))
- ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($user->getUID())))
+ ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($userId)))
->setMaxResults(1)
->execute();
diff --git a/lib/private/share20/manager.php b/lib/private/share20/manager.php
index 520b5a53762..db42f76d7a2 100644
--- a/lib/private/share20/manager.php
+++ b/lib/private/share20/manager.php
@@ -21,7 +21,7 @@
namespace OC\Share20;
-use OCP\Files\Node;
+use OCP\IUserManager;
use OCP\Share\IManager;
use OCP\Share\IProviderFactory;
use OC\Share20\Exception\BackendError;
@@ -34,7 +34,6 @@ use OCP\Files\Mount\IMountManager;
use OCP\IGroupManager;
use OCP\Files\File;
use OCP\Files\Folder;
-use OCP\IUser;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\Exceptions\GenericShareException;
@@ -68,6 +67,9 @@ class Manager implements IManager {
/** @var IL10N */
private $l;
+ /** @var IUserManager */
+ private $userManager;
+
/**
* Manager constructor.
*
@@ -79,6 +81,7 @@ class Manager implements IManager {
* @param IGroupManager $groupManager
* @param IL10N $l
* @param IProviderFactory $factory
+ * @param IUserManager $userManager
*/
public function __construct(
ILogger $logger,
@@ -88,7 +91,8 @@ class Manager implements IManager {
IMountManager $mountManager,
IGroupManager $groupManager,
IL10N $l,
- IProviderFactory $factory
+ IProviderFactory $factory,
+ IUserManager $userManager
) {
$this->logger = $logger;
$this->config = $config;
@@ -98,6 +102,7 @@ class Manager implements IManager {
$this->groupManager = $groupManager;
$this->l = $l;
$this->factory = $factory;
+ $this->userManager = $userManager;
}
/**
@@ -150,13 +155,13 @@ class Manager implements IManager {
protected function generalCreateChecks(\OCP\Share\IShare $share) {
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
// We expect a valid user as sharedWith for user shares
- if (!($share->getSharedWith() instanceof \OCP\IUser)) {
- throw new \InvalidArgumentException('SharedWith should be an IUser');
+ if (!$this->userManager->userExists($share->getSharedWith())) {
+ throw new \InvalidArgumentException('SharedWith is not a valid user');
}
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
// We expect a valid group as sharedWith for group shares
- if (!($share->getSharedWith() instanceof \OCP\IGroup)) {
- throw new \InvalidArgumentException('SharedWith should be an IGroup');
+ if (!$this->groupManager->groupExists($share->getSharedWith())) {
+ throw new \InvalidArgumentException('SharedWith is not a valid group');
}
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
if ($share->getSharedWith() !== null) {
@@ -173,7 +178,8 @@ class Manager implements IManager {
}
// Cannot share with yourself
- if ($share->getSharedWith() === $share->getSharedBy()) {
+ if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER &&
+ $share->getSharedWith() === $share->getSharedBy()) {
throw new \InvalidArgumentException('Can\'t share with yourself');
}
@@ -215,7 +221,7 @@ class Manager implements IManager {
* Validate if the expiration date fits the system settings
*
* @param \OCP\Share\IShare $share The share to validate the expiration date of
- * @return \DateTime|null The expiration date or null if $expireDate was null and it is not required
+ * @return \OCP\Share\IShare The expiration date or null if $expireDate was null and it is not required
* @throws GenericShareException
* @throws \InvalidArgumentException
* @throws \Exception
@@ -285,10 +291,12 @@ class Manager implements IManager {
protected function userCreateChecks(\OCP\Share\IShare $share) {
// Check if we can share with group members only
if ($this->shareWithGroupMembersOnly()) {
+ $sharedBy = $this->userManager->get($share->getSharedBy());
+ $sharedWith = $this->userManager->get($share->getSharedWith());
// Verify we can share with this user
$groups = array_intersect(
- $this->groupManager->getUserGroupIds($share->getSharedBy()),
- $this->groupManager->getUserGroupIds($share->getSharedWith())
+ $this->groupManager->getUserGroupIds($sharedBy),
+ $this->groupManager->getUserGroupIds($sharedWith)
);
if (empty($groups)) {
throw new \Exception('Only sharing with group members is allowed');
@@ -314,10 +322,13 @@ class Manager implements IManager {
}
// The share is already shared with this user via a group share
- if ($existingShare->getShareType() === \OCP\Share::SHARE_TYPE_GROUP &&
- $existingShare->getSharedWith()->inGroup($share->getSharedWith()) &&
- $existingShare->getShareOwner() !== $share->getShareOwner()) {
- throw new \Exception('Path already shared with this user');
+ if ($existingShare->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
+ $group = $this->groupManager->get($existingShare->getSharedWith());
+ $user = $this->userManager->get($share->getSharedWith());
+
+ if ($group->inGroup($user) && $existingShare->getShareOwner() !== $share->getShareOwner()) {
+ throw new \Exception('Path already shared with this user');
+ }
}
}
}
@@ -331,7 +342,9 @@ class Manager implements IManager {
protected function groupCreateChecks(\OCP\Share\IShare $share) {
// Verify if the user can share with this group
if ($this->shareWithGroupMembersOnly()) {
- if (!$share->getSharedWith()->inGroup($share->getSharedBy())) {
+ $sharedBy = $this->userManager->get($share->getSharedBy());
+ $sharedWith = $this->groupManager->get($share->getSharedWith());
+ if (!$sharedWith->inGroup($sharedBy)) {
throw new \Exception('Only sharing within your own groups is allowed');
}
}
@@ -468,10 +481,11 @@ class Manager implements IManager {
$this->pathCreateChecks($share->getNode());
// On creation of a share the owner is always the owner of the path
- $share->setShareOwner($share->getNode()->getOwner());
+ $share->setShareOwner($share->getNode()->getOwner()->getUID());
// Cannot share with the owner
- if ($share->getSharedWith() === $share->getShareOwner()) {
+ if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER &&
+ $share->getSharedWith() === $share->getShareOwner()) {
throw new \InvalidArgumentException('Can\'t share with the share owner');
}
@@ -480,16 +494,6 @@ class Manager implements IManager {
$target = \OC\Files\Filesystem::normalizePath($target);
$share->setTarget($target);
- //Get sharewith for hooks
- $sharedWith = null;
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
- $sharedWith = $share->getSharedWith()->getUID();
- } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
- $sharedWith = $share->getSharedWith()->getGID();
- } else {
- $sharedWith = $share->getSharedWith();
- }
-
// Pre share hook
$run = true;
$error = '';
@@ -497,13 +501,13 @@ class Manager implements IManager {
'itemType' => $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder',
'itemSource' => $share->getNode()->getId(),
'shareType' => $share->getShareType(),
- 'uidOwner' => $share->getSharedBy()->getUID(),
+ 'uidOwner' => $share->getSharedBy(),
'permissions' => $share->getPermissions(),
'fileSource' => $share->getNode()->getId(),
'expiration' => $share->getExpirationDate(),
'token' => $share->getToken(),
'itemTarget' => $share->getTarget(),
- 'shareWith' => $sharedWith,
+ 'shareWith' => $share->getSharedWith(),
'run' => &$run,
'error' => &$error,
];
@@ -521,13 +525,13 @@ class Manager implements IManager {
'itemType' => $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder',
'itemSource' => $share->getNode()->getId(),
'shareType' => $share->getShareType(),
- 'uidOwner' => $share->getSharedBy()->getUID(),
+ 'uidOwner' => $share->getSharedBy(),
'permissions' => $share->getPermissions(),
'fileSource' => $share->getNode()->getId(),
'expiration' => $share->getExpirationDate(),
'token' => $share->getToken(),
'id' => $share->getId(),
- 'shareWith' => $sharedWith,
+ 'shareWith' => $share->getSharedWith(),
'itemTarget' => $share->getTarget(),
'fileTarget' => $share->getTarget(),
];
@@ -542,6 +546,7 @@ class Manager implements IManager {
*
* @param \OCP\Share\IShare $share
* @return \OCP\Share\IShare The share object
+ * @throws \InvalidArgumentException
*/
public function updateShare(\OCP\Share\IShare $share) {
$expirationDateUpdated = false;
@@ -564,7 +569,8 @@ class Manager implements IManager {
}
// Cannot share with the owner
- if ($share->getSharedWith() === $share->getShareOwner()) {
+ if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER &&
+ $share->getSharedWith() === $share->getShareOwner()) {
throw new \InvalidArgumentException('Can\'t share with the share owner');
}
@@ -606,7 +612,7 @@ class Manager implements IManager {
'itemType' => $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder',
'itemSource' => $share->getNode()->getId(),
'date' => $share->getExpirationDate(),
- 'uidOwner' => $share->getSharedBy()->getUID(),
+ 'uidOwner' => $share->getSharedBy(),
]);
}
@@ -651,9 +657,9 @@ class Manager implements IManager {
$shareType = $share->getShareType();
$sharedWith = '';
if ($shareType === \OCP\Share::SHARE_TYPE_USER) {
- $sharedWith = $share->getSharedWith()->getUID();
+ $sharedWith = $share->getSharedWith();
} else if ($shareType === \OCP\Share::SHARE_TYPE_GROUP) {
- $sharedWith = $share->getSharedWith()->getGID();
+ $sharedWith = $share->getSharedWith();
} else if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE) {
$sharedWith = $share->getSharedWith();
}
@@ -665,7 +671,7 @@ class Manager implements IManager {
'shareType' => $shareType,
'shareWith' => $sharedWith,
'itemparent' => $share->getParent(),
- 'uidOwner' => $share->getSharedBy()->getUID(),
+ 'uidOwner' => $share->getSharedBy(),
'fileSource' => $share->getNode()->getId(),
'fileTarget' => $share->getTarget()
];
@@ -706,38 +712,45 @@ class Manager implements IManager {
* handle this.
*
* @param \OCP\Share\IShare $share
- * @param IUser $recipient
+ * @param string $recipientId
*/
- public function deleteFromSelf(\OCP\Share\IShare $share, IUser $recipient) {
- list($providerId, $id) = $this->splitFullId($share->getId());
+ public function deleteFromSelf(\OCP\Share\IShare $share, $recipientId) {
+ list($providerId, ) = $this->splitFullId($share->getId());
$provider = $this->factory->getProvider($providerId);
- $provider->deleteFromSelf($share, $recipient);
+ $provider->deleteFromSelf($share, $recipientId);
}
/**
* @inheritdoc
*/
- public function moveShare(\OCP\Share\IShare $share, IUser $recipient) {
+ public function moveShare(\OCP\Share\IShare $share, $recipientId) {
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
throw new \InvalidArgumentException('Can\'t change target of link share');
}
- if (($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && $share->getSharedWith() !== $recipient) ||
- ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP && !$share->getSharedWith()->inGroup($recipient))) {
+ if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && $share->getSharedWith() !== $recipientId) {
throw new \InvalidArgumentException('Invalid recipient');
}
+ if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
+ $sharedWith = $this->groupManager->get($share->getSharedWith());
+ $recipient = $this->userManager->get($recipientId);
+ if (!$sharedWith->inGroup($recipient)) {
+ throw new \InvalidArgumentException('Invalid recipient');
+ }
+ }
+
list($providerId, ) = $this->splitFullId($share->getId());
$provider = $this->factory->getProvider($providerId);
- $provider->move($share, $recipient);
+ $provider->move($share, $recipientId);
}
/**
* Get shares shared by (initiated) by the provided user.
*
- * @param IUser $user
+ * @param string $userId
* @param int $shareType
* @param \OCP\Files\File|\OCP\Files\Folder $path
* @param bool $reshares
@@ -745,7 +758,7 @@ class Manager implements IManager {
* @param int $offset
* @return \OCP\Share\IShare[]
*/
- public function getSharesBy(IUser $user, $shareType, $path = null, $reshares = false, $limit = 50, $offset = 0) {
+ public function getSharesBy($userId, $shareType, $path = null, $reshares = false, $limit = 50, $offset = 0) {
if ($path !== null &&
!($path instanceof \OCP\Files\File) &&
!($path instanceof \OCP\Files\Folder)) {
@@ -754,16 +767,16 @@ class Manager implements IManager {
$provider = $this->factory->getProviderForType($shareType);
- return $provider->getSharesBy($user, $shareType, $path, $reshares, $limit, $offset);
+ return $provider->getSharesBy($userId, $shareType, $path, $reshares, $limit, $offset);
}
/**
* @inheritdoc
*/
- public function getSharedWith(IUser $user, $shareType, $node = null, $limit = 50, $offset = 0) {
+ public function getSharedWith($userId, $shareType, $node = null, $limit = 50, $offset = 0) {
$provider = $this->factory->getProviderForType($shareType);
- return $provider->getSharedWith($user, $shareType, $node, $limit, $offset);
+ return $provider->getSharedWith($userId, $shareType, $node, $limit, $offset);
}
/**
@@ -955,10 +968,10 @@ class Manager implements IManager {
*
* TODO: Deprecate fuction from OC_Util
*
- * @param IUser $user
+ * @param string $userId
* @return bool
*/
- public function sharingDisabledForUser(IUser $user) {
+ public function sharingDisabledForUser($userId) {
if ($this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes') {
$groupsList = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
$excludedGroups = json_decode($groupsList);
@@ -967,6 +980,7 @@ class Manager implements IManager {
$newValue = json_encode($excludedGroups);
$this->config->setAppValue('core', 'shareapi_exclude_groups_list', $newValue);
}
+ $user = $this->userManager->get($userId);
$usersGroups = $this->groupManager->getUserGroupIds($user);
if (!empty($usersGroups)) {
$remainingGroups = array_diff($usersGroups, $excludedGroups);
diff --git a/lib/private/share20/share.php b/lib/private/share20/share.php
index f9cba10a07a..db91ad4a91d 100644
--- a/lib/private/share20/share.php
+++ b/lib/private/share20/share.php
@@ -121,6 +121,9 @@ class Share implements \OCP\Share\IShare {
* @inheritdoc
*/
public function setSharedWith($sharedWith) {
+ if (!is_string($sharedWith)) {
+ throw new \InvalidArgumentException();
+ }
$this->sharedWith = $sharedWith;
return $this;
}
@@ -170,6 +173,9 @@ class Share implements \OCP\Share\IShare {
* @inheritdoc
*/
public function setSharedBy($sharedBy) {
+ if (!is_string($sharedBy)) {
+ throw new \InvalidArgumentException();
+ }
//TODO checks
$this->sharedBy = $sharedBy;
@@ -188,6 +194,9 @@ class Share implements \OCP\Share\IShare {
* @inheritdoc
*/
public function setShareOwner($shareOwner) {
+ if (!is_string($shareOwner)) {
+ throw new \InvalidArgumentException();
+ }
//TODO checks
$this->shareOwner = $shareOwner;
diff --git a/lib/private/user/manager.php b/lib/private/user/manager.php
index 86750dcd994..6798a7340c3 100644
--- a/lib/private/user/manager.php
+++ b/lib/private/user/manager.php
@@ -265,6 +265,10 @@ class Manager extends PublicEmitter implements IUserManager {
if (trim($uid) == '') {
throw new \Exception($l->t('A valid username must be provided'));
}
+ // No whitespace at the beginning or at the end
+ if (strlen(trim($uid, "\t\n\r\0\x0B\xe2\x80\x8b")) !== strlen(trim($uid))) {
+ throw new \Exception($l->t('Username contains whitespace at the beginning or at the end'));
+ }
// No empty password
if (trim($password) == '') {
throw new \Exception($l->t('A valid password must be provided'));
diff --git a/lib/public/files/cache/icache.php b/lib/public/files/cache/icache.php
index e80c6fa2cb0..4ffb298a9e2 100644
--- a/lib/public/files/cache/icache.php
+++ b/lib/public/files/cache/icache.php
@@ -76,6 +76,7 @@ interface ICache {
/**
* store meta data for a file or folder
+ * This will automatically call either insert or update depending on if the file exists
*
* @param string $file
* @param array $data
@@ -87,6 +88,18 @@ interface ICache {
public function put($file, array $data);
/**
+ * insert meta data for a new file or folder
+ *
+ * @param string $file
+ * @param array $data
+ *
+ * @return int file id
+ * @throws \RuntimeException
+ * @since 9.0.0
+ */
+ public function insert($file, array $data);
+
+ /**
* update the metadata of an existing file or folder in the cache
*
* @param int $id the fileid of the existing file or folder
diff --git a/lib/public/share/imanager.php b/lib/public/share/imanager.php
index 15b9f34764e..4d79f97c31a 100644
--- a/lib/public/share/imanager.php
+++ b/lib/public/share/imanager.php
@@ -69,27 +69,27 @@ interface IManager {
* handle this.
*
* @param IShare $share
- * @param IUser $recipient
+ * @param string $recipientId
* @since 9.0.0
*/
- public function deleteFromSelf(IShare $share, IUser $recipient);
+ public function deleteFromSelf(IShare $share, $recipientId);
/**
* Move the share as a recipient of the share.
* This is updating the share target. So where the recipient has the share mounted.
*
* @param IShare $share
- * @param IUser $recipient
+ * @param string $recipientId
* @return IShare
* @throws \InvalidArgumentException If $share is a link share or the $recipient does not match
* @since 9.0.0
*/
- public function moveShare(IShare $share, IUser $recipient);
+ public function moveShare(IShare $share, $recipientId);
/**
* Get shares shared by (initiated) by the provided user.
*
- * @param IUser $user
+ * @param string $userId
* @param int $shareType
* @param \OCP\Files\File|\OCP\Files\Folder $path
* @param bool $reshares
@@ -98,13 +98,13 @@ interface IManager {
* @return IShare[]
* @since 9.0.0
*/
- public function getSharesBy(IUser $user, $shareType, $path = null, $reshares = false, $limit = 50, $offset = 0);
+ public function getSharesBy($userId, $shareType, $path = null, $reshares = false, $limit = 50, $offset = 0);
/**
* Get shares shared with $user.
* Filter by $node if provided
*
- * @param IUser $user
+ * @param string $userId
* @param int $shareType
* @param File|Folder|null $node
* @param int $limit The maximum number of shares returned, -1 for all
@@ -112,7 +112,7 @@ interface IManager {
* @return IShare[]
* @since 9.0.0
*/
- public function getSharedWith(IUser $user, $shareType, $node = null, $limit = 50, $offset = 0);
+ public function getSharedWith($userId, $shareType, $node = null, $limit = 50, $offset = 0);
/**
* Retrieve a share by the share id.
@@ -223,10 +223,10 @@ interface IManager {
/**
* Check if sharing is disabled for the given user
*
- * @param IUser $user
+ * @param string $userId
* @return bool
* @since 9.0.0
*/
- public function sharingDisabledForUser(IUser $user);
+ public function sharingDisabledForUser($userId);
}
diff --git a/lib/public/share/ishare.php b/lib/public/share/ishare.php
index 80e7f7f56ef..5a82436c720 100644
--- a/lib/public/share/ishare.php
+++ b/lib/public/share/ishare.php
@@ -89,7 +89,7 @@ interface IShare {
/**
* Set the receiver of this share.
*
- * @param IUser|IGroup
+ * @param string $sharedWith
* @return \OCP\Share\IShare The modified object
* @since 9.0.0
*/
@@ -98,7 +98,7 @@ interface IShare {
/**
* Get the receiver of this share.
*
- * @return IUser|IGroup
+ * @return string
* @since 9.0.0
*/
public function getSharedWith();
@@ -142,7 +142,7 @@ interface IShare {
/**
* Set the sharer of the path.
*
- * @param IUser $sharedBy
+ * @param string $sharedBy
* @return \OCP\Share\IShare The modified object
* @since 9.0.0
*/
@@ -151,7 +151,7 @@ interface IShare {
/**
* Get share sharer
*
- * @return IUser
+ * @return string
* @since 9.0.0
*/
public function getSharedBy();
@@ -159,7 +159,7 @@ interface IShare {
/**
* Set the original share owner (who owns the path that is shared)
*
- * @param IUser
+ * @param string $shareOwner
* @return \OCP\Share\IShare The modified object
* @since 9.0.0
*/
@@ -168,7 +168,7 @@ interface IShare {
/**
* Get the original share owner (who owns the path that is shared)
*
- * @return IUser
+ * @return string
* @since 9.0.0
*/
public function getShareOwner();
diff --git a/lib/public/share/ishareprovider.php b/lib/public/share/ishareprovider.php
index 42a2881718e..25fa76369ab 100644
--- a/lib/public/share/ishareprovider.php
+++ b/lib/public/share/ishareprovider.php
@@ -74,10 +74,10 @@ interface IShareProvider {
* share from their self then the original group share should still exist.
*
* @param \OCP\Share\IShare $share
- * @param IUser $recipient
+ * @param string $recipient UserId of the recipient
* @since 9.0.0
*/
- public function deleteFromSelf(\OCP\Share\IShare $share, IUser $recipient);
+ public function deleteFromSelf(\OCP\Share\IShare $share, $recipient);
/**
* Move a share as a recipient.
@@ -86,36 +86,36 @@ interface IShareProvider {
* the target should only be changed for them.
*
* @param \OCP\Share\IShare $share
- * @param IUser $recipient
+ * @param string $recipient userId of recipient
* @return \OCP\Share\IShare
* @since 9.0.0
*/
- public function move(\OCP\Share\IShare $share, IUser $recipient);
+ public function move(\OCP\Share\IShare $share, $recipient);
/**
* Get all shares by the given user
*
- * @param IUser $user
+ * @param string $userId
* @param int $shareType
* @param \OCP\Files\File|\OCP\Files\Folder $node
* @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator
* @param int $limit The maximum number of shares to be returned, -1 for all shares
* @param int $offset
- * @return \OCP\Share\I Share[]
+ * @return \OCP\Share\IShare Share[]
* @since 9.0.0
*/
- public function getSharesBy(IUser $user, $shareType, $node, $reshares, $limit, $offset);
+ public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset);
/**
* Get share by id
*
* @param int $id
- * @param IUser|null $recipient
+ * @param string|null $recipientId
* @return \OCP\Share\IShare
* @throws ShareNotFound
* @since 9.0.0
*/
- public function getShareById($id, $recipient = null);
+ public function getShareById($id, $recipientId = null);
/**
* Get shares for a given path
@@ -129,7 +129,7 @@ interface IShareProvider {
/**
* Get shared with the given user
*
- * @param IUser $user get shares where this user is the recipient
+ * @param string $userId get shares where this user is the recipient
* @param int $shareType
* @param Node|null $node
* @param int $limit The max number of entries returned, -1 for all
@@ -137,7 +137,7 @@ interface IShareProvider {
* @return \OCP\Share\IShare[]
* @since 9.0.0
*/
- public function getSharedWith(IUser $user, $shareType, $node, $limit, $offset);
+ public function getSharedWith($userId, $shareType, $node, $limit, $offset);
/**
* Get a share by token
diff --git a/resources/codesigning/core.crt b/resources/codesigning/core.crt
index 475a59bddce..0692e940186 100644
--- a/resources/codesigning/core.crt
+++ b/resources/codesigning/core.crt
@@ -1,28 +1,24 @@
-----BEGIN CERTIFICATE-----
-MIIEvjCCAqagAwIBAgIUc/0FxYrsgSs9rDxp03EJmbjN0NwwDQYJKoZIhvcNAQEF
-BQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTEw
-MzIxMDMzM1oXDTE2MTEwMzIxMDMzM1owDzENMAsGA1UEAwwEY29yZTCCAiIwDQYJ
-KoZIhvcNAQEBBQADggIPADCCAgoCggIBALb6EgHpkAqZbO5vRO8XSh7G7XGWHw5s
-iOf4RwPXR6SE9bWZEm/b72SfWk//J6AbrD8WiOzBuT/ODy6k5T1arEdHO+Pux0W1
-MxYJJI4kH74KKgMpC0SB0Rt+8WrMqV1r3hhJ46df6Xr/xolP3oD+eLbShPcblhdS
-VtkZEkoev8Sh6L2wDCeHDyPxzvj1w2dTdGVO9Kztn0xIlyfEBakqvBWtcxyi3Ln0
-klnxlMx3tPDUE4kqvpia9qNiB1AN2PV93eNr5/2riAzIssMFSCarWCx0AKYb54+d
-xLpcYFyqPJ0ydBCkF78DD45RCZet6PNYkdzgbqlUWEGGomkuDoJbBg4wzgzO0D77
-H87KFhYW8tKFFvF1V3AHl/sFQ9tDHaxM9Y0pZ2jPp/ccdiqnmdkBxBDqsiRvHvVB
-Cn6qpb4vWGFC7vHOBfYspmEL1zLlKXZv3ezMZEZw7O9ZvUP3VO/wAtd2vUW8UFiq
-s2v1QnNLN6jNh51obcwmrBvWhJy9vQIdtIjQbDxqWTHh1zUSrw9wrlklCBZ/zrM0
-i8nfCFwTxWRxp3H9KoECzO/zS5R5KIS7s3/wq/w9T2Ie4rcecgXwDizwnn0C/aKc
-bDIjujpL1s9HO05pcD/V3wKcPZ1izymBkmMyIbL52iRVN5FTVHeZdXPpFuq+CTQJ
-Q238lC+A/KOVAgMBAAEwDQYJKoZIhvcNAQEFBQADggIBAGoKTnh8RfJV4sQItVC2
-AvfJagkrIqZ3iiQTUBQGTKBsTnAqE1H7QgUSV9vSd+8rgvHkyZsRjmtyR1e3A6Ji
-oNCXUbExC/0iCPUqdHZIVb+Lc/vWuv4ByFMybGPydgtLoEUX2ZrKFWmcgZFDUSRd
-9Uj26vtUhCC4bU4jgu6hIrR9IuxOBLQUxGTRZyAcXvj7obqRAEZwFAKQgFpfpqTb
-H+kjcbZSaAlLVSF7vBc1syyI8RGYbqpwvtREqJtl5IEIwe6huEqJ3zPnlP2th/55
-cf3Fovj6JJgbb9XFxrdnsOsDOu/tpnaRWlvv5ib4+SzG5wWFT5UUEo4Wg2STQiiX
-uVSRQxK1LE1yg84bs3NZk9FSQh4B8vZVuRr5FaJsZZkwlFlhRO//+TJtXRbyNgsf
-oMRZGi8DLGU2SGEAHcRH/QZHq/XDUWVzdxrSBYcy7GSpT7UDVzGv1rEJUrn5veP1
-0KmauAqtiIaYRm4f6YBsn0INcZxzIPZ0p8qFtVZBPeHhvQtvOt0iXI/XUxEWOa2F
-K2EqhErgMK/N07U1JJJay5tYZRtvkGq46oP/5kQG8hYST0MDK6VihJoPpvCmAm4E
-pEYKQ96x6A4EH9Y9mZlYozH/eqmxPbTK8n89/p7Ydun4rI+B2iiLnY8REWWy6+UQ
-V204fGUkJqW5CrKy3P3XvY9X
+MIID/TCCAeUCAhAAMA0GCSqGSIb3DQEBCwUAMHkxFjAUBgNVBAoTDW93bkNsb3Vk
+IEluYy4xEjAQBgNVBAcTCUxleGluZ3RvbjEPMA0GA1UECBMGQm9zdG9uMQswCQYD
+VQQGEwJVUzEtMCsGA1UEAxMkb3duQ2xvdWQgQ29kZSBTaWduaW5nIFJvb3QgQXV0
+aG9yaXR5MB4XDTE2MDIwMzE3MTM0NVoXDTI2MDEzMTE3MTM0NVowDzENMAsGA1UE
+AwwEY29yZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKzP4ujnvS9l
+otPJ7zHZMD8IGgcuYVtZ40n4pWSArhJboazhMdadpfxEZAghZtzkK+AKz4V+92GV
+UOf+FgFRMcsaaBFr9INE4tdYKPVfHq19sDZVhYySfg7/z9qWc9XTMAm1lWpFyDQb
+CC0i1YFogk0JdPr5Ay2Ftgbbr+TtMduL0RshdClqoiwntLnFhu8VRZi3+/yHH2cN
+M5ANjm/MXT8Ae6KMVOzsYhBcxMLNVL08Ih1ubtu4LbKgyT5ShYzxqRnJ8U1KlmVT
+w/wsSGMvVTEJkozkQEyg88vkxwvqLLYs5bOvXY93S6YKb2gO7RAA2c/IaEDbL32t
+TJJhRoPif9cCAwEAATANBgkqhkiG9w0BAQsFAAOCAgEAiRhcef1Tc0Lj4BWIxYDV
+Fjkrd4HHe3FyZRdD1+NU4LSb/4xXknmrwu5tITrnoGqNfUGn9BlP5Ek7Iu15PMPi
+8Us8xszvgMZ7BG3x4zTMHwUseLT56/+qE76VN2vXusQBuEhOll/WN2qHvPi8BOCk
+fOL6/EIUdqfMh9FKGNKOJ5f95eKogyVVxVcUpGWoqZRQTJaNMBTdT8Zwv1aTLRgp
+Vf8JFzmxG9Atc/00w7cg4tV4lUpZafn1RYaIi4DWZhI43yR+Z8CKQBXt7iufu0QD
+VwWOqYjmK7aKB2bL3+8I2bL9pm9DUKrAPYSObdmasJQGFVNCILisWJjX5wlUC2IL
+FtMfZ4egyWZTLeQ+VQt92cJeVZYins5GECm1SqgXGnmQWv01/wNIqUhLuVFoLyVv
+aPhCYcjNcbwJm8m++kz/G6+5AhRv2JrZq3i1Cw/yRQuiotXrJE+ukIvvSEjlLJ0C
+Njm7EMy1mNfhIi1Xel/aUaf0y92GMsfnCuzI+tRG50HHupLEXHItlg2RILmNQNpo
+woqHpUZs5G5HZlE5ZnffJlZpJyqA1EpQDh1XXJqcVwV50V9o+CMvxXO8s2lUA+i6
+Kay+t3mz2dX6qflRUPLsPS4XLdB9MUiIHCOgMJfsK+9SZ+i1VymhV5UYx8rqglC7
+8crw8NpiIuOqQZW8LcZXZBU=
-----END CERTIFICATE----- \ No newline at end of file
diff --git a/resources/codesigning/core.key b/resources/codesigning/core.key
deleted file mode 100644
index 4a588d47356..00000000000
--- a/resources/codesigning/core.key
+++ /dev/null
@@ -1,51 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIJKQIBAAKCAgEAtvoSAemQCpls7m9E7xdKHsbtcZYfDmyI5/hHA9dHpIT1tZkS
-b9vvZJ9aT/8noBusPxaI7MG5P84PLqTlPVqsR0c74+7HRbUzFgkkjiQfvgoqAykL
-RIHRG37xasypXWveGEnjp1/pev/GiU/egP54ttKE9xuWF1JW2RkSSh6/xKHovbAM
-J4cPI/HO+PXDZ1N0ZU70rO2fTEiXJ8QFqSq8Fa1zHKLcufSSWfGUzHe08NQTiSq+
-mJr2o2IHUA3Y9X3d42vn/auIDMiywwVIJqtYLHQAphvnj53EulxgXKo8nTJ0EKQX
-vwMPjlEJl63o81iR3OBuqVRYQYaiaS4OglsGDjDODM7QPvsfzsoWFhby0oUW8XVX
-cAeX+wVD20MdrEz1jSlnaM+n9xx2KqeZ2QHEEOqyJG8e9UEKfqqlvi9YYULu8c4F
-9iymYQvXMuUpdm/d7MxkRnDs71m9Q/dU7/AC13a9RbxQWKqza/VCc0s3qM2HnWht
-zCasG9aEnL29Ah20iNBsPGpZMeHXNRKvD3CuWSUIFn/OszSLyd8IXBPFZHGncf0q
-gQLM7/NLlHkohLuzf/Cr/D1PYh7itx5yBfAOLPCefQL9opxsMiO6OkvWz0c7Tmlw
-P9XfApw9nWLPKYGSYzIhsvnaJFU3kVNUd5l1c+kW6r4JNAlDbfyUL4D8o5UCAwEA
-AQKCAgBOkCKpNYqGMogF/DqB2eMWQd1zdryQ6eMCjqSXLpjxN7F0LmwvISSxdIZH
-cMunwBn94IQb+7W5gpUcNurCpCryU9CQNlbTRFDR9kz+xt3mL+EICFhxKrgI8UFg
-1M0ncogir58Sn2jVSfsJvARSKHDWNp+mpe6UxuLJRi2HK5q1J7uRroQZeLD0gv+V
-/5fNxpRkZzlBAqnyC/zyswSnNNUbDaUuN3NEWJF6EvMLs546BST6MSMyzN53GkD/
-i2KLTWa3Hf62+S5qJsYyXBM1nz41n/0jVTngfSIZzk4Fm4Z5DE+vUXVsqzjDp2HS
-AXbS/UVrq+V3yOI4CEG1nXPXXpPDS/werQcSvANGHd/LLiQ3qfcs1S/SBihDjSFQ
-CBgH3y06qDdnKxdPjpRYZpOBnkdQLHF4OwlhPXBd083Ep7jiF1WIgzwBP9o9wEWi
-dVT0Vr5vsB61MQ+4p26Us1yWm51g6AxpTu5y2RPmbuDh1IvNbheeITQMSmbtGf1R
-JZ4yqrnYpd3akja9hwko1xoWuHT15rr2pTs8g/PtHH7sNkZdThMtJscEt4YIIxoN
-CQ+VM4lGYogtySbYEiUkRNF3t06AsPhBehcH7oldUqb6UKKoi6NCZOiC5RsdpOY3
-JJX2nkCMk52264sI+kWl6kEVBpMzeLW+BM0Xi1AQRyHPIY+VZQKCAQEA4sjNh35x
-ezjiOWsq84UOUHdvei9HAm+MQMM2pEgdHWjjawhoH122gi2G/tpgNGONl/XNmZkk
-ni00jFtNRA9xDF6mv1CynxiWhKGLdEH3MELQqGyeNOE9GBQVMo2W2J2mvOj+GzC+
-cRrEBjR1MDGx+XLO8FbYyKiwVg8/OIT9hIYSlBIsu0bPwYb6X3KlfZfmdh/MZvCs
-HDthzRYnJlkVerB/2ZnfTVYflQh7XoKFipVXFMs+oG0mKCUT4HpqXWTek1Jqt8bQ
-og9235C0jEcFWjSHtp2Jhena8yMD4YKQGI7tFVFm9UkHkKPcdfIW+hoVC4vLI0fs
-LMwhzOvFof4pawKCAQEAzoyGHKUA2KG8JVV49C5LKLmJv0nBj7aT5EXcg1J9OZn7
-zP/o/BHJQpeLNI2UD5c0Ron33iRLVqNvU4sTdo597Qoc2jWsZWRmdTz2Q4VvnxHu
-VBvao0vUG4xqIbMtv4VRkuNg9EmlF4luT5+x30E6DWDMK0RhSmM9yWG7My6JG2IN
-LZ457tWvk7F1HTKNt3uFJTAOx0VqjJsbaw7Gsq7hTmObTUa+q8Ss0oK+iRkP5Obv
-9F9zUWv2UjKs/G4JYADfFhS1Ovha8pu5p+NszlGBGvG99EErRpiUPcxCTjSiUvDl
-ALn3YTDc9oSC+6b/sI7/4uQVSri5ybXLGzbtMWKm/wKCAQEAvO12M6uF1Ja1+Ams
-lYTCQQzO5OZf7MqK+CTo74FYJ/kKhE9TltXWRqqw7L12Kg7Jlc/jgVNQaynTvh4N
-x2Zp0llD5tvOgrXUJxgBek++Iwl2lOkv/3OpFtccNao5AaqMjpI3puU7sjQPG/A1
-tHmh/+LCPPzMypWlmXxIOcio/u9GqO5fL4E1cM8G4985uOCD0OJ6wUM8zqQ1vMn4
-wXyzZSuGxvvmSKI320teo4Ruxd3V1u/e830arZT98yNoWve+aNLfLszFYE0rxeHi
-V36PGe/rI5ooSFRi3+zKveKsMplXL0xKTouRbtDjx6pvs9losN6701+GhGdmvTWp
-xmNbkwKCAQEAmY94FcvG+UglbUxChKf2UOzAMGtRcNs40Lnv2+J0H2MQBbUtLlq6
-2rt4TzYDIiQ0RU1F7u3k5SDVH7OCYN5HWPfvw3usFCW01uzf2gtWlVjra7TZtBYo
-N+MI9M0V8hHYN/C8oGIwT3Npg+EiiO0hj9ircm+ANaHayeHTH5Y1cRpQ2d2NDLfp
-tVB11aNEIWm/74nvMs+1C5w1oj52E1pZP8JmL+ms0F+EbW2u4pazbmcTdweP4LT3
-iN0MJxBX//wl33C93H3QgBauzNcUib+m0LVxmCrrVa0SaW92zFXtaOSYHRYliSie
-3thd2WKrLkTikXkpK0hzODfkLPOFHPZPWQKCAQAG0Yz7eQblxIHII60ReeYIovum
-Gmn+ot0jeuPg5gYpopQygL87ygc00ER+SHgZLBjIx3uCYDbC6Q4SzEPLa/aUS3/e
-94vYBVoWYvTYUazuwgJBA1Xm7BnlqG7cQziJOQxBIJBXaX96xUptcmlKrIIYD9Jz
-qeUbbbqN4bBYjXJdNdMqU1f6t2IK7hcjFXJMpS2wJdv1AlYCUWDquQ0BUePCJAPf
-N0rKm12ffhi564NqN/6PtT7iEkSPKT2CEyqrvXwx0Lajz0ZokFzRm2iYUTxik2fI
-Lcq5zXyM4gs1hDnrasn1g0JyfeUgnPNNuWeFG0cMb8o7FeYQImhqheIgMJLP
------END RSA PRIVATE KEY----- \ No newline at end of file
diff --git a/resources/codesigning/root.crt b/resources/codesigning/root.crt
index 539bd9a199f..201164feb0c 100644
--- a/resources/codesigning/root.crt
+++ b/resources/codesigning/root.crt
@@ -1,28 +1,36 @@
-----BEGIN CERTIFICATE-----
-MIIE1DCCArygAwIBAgIUFgEnT7tUWNgEKfbMiRTOm3Z8figwDQYJKoZIhvcNAQEF
-BQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMCAXDTE1MTEw
-MzIxMDMzMloYDzk5OTkxMjMxMjM1OTU5WjAjMSEwHwYDVQQKDBhvd25DbG91ZCBD
-b2RlIFNpZ25pbmcgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCt
-rYEwiwpuhzRNx1L2SntkL/zalA7OkwEcsBn4Ysw47nEdvp648AVohT7d+U7+DWix
-O06xvlAJUhqYTXX7EG9n+mBnG+TIMq2zlei0Jj3uq1pEZE9elfGZael2uc8gRXMZ
-YFmSlTvzexqvfK4B3DwoZaMaWJecEO9iyuUyzHMBpE8bHtGDOUGy/oTO9WASbtl9
-Rfk38VLLV6csCPwKjii6Q3YZ+AYU0YqLg22BwZlqlTexUjWAmVIqaoxmSEuKa41X
-nuAIHfP65oiob86s4IvJXVr3r7NjdF2IJ/ZrwmjGKaWgSZKcoZBPLArZJeJiIQ4Y
-KzLZATwba5dWswV0mbDj8eP2BG+02NVKxylOBbeoBESnahZeZ5nJ5XKZr+ErJAUW
-b417fEnYaQNBlNnijjkqXaDipmTktUfnv4lm30sUAgho6I3Ga7gQrFPzKg9V4j2S
-+LOTc1HmJOnR6Kfttx+yAHYLKtvV5yIMMpz+rZ2X5g/N2GdgleZj5VU9nmKzTPeG
-x6V+dBaIkqNe8/AXaVnxt9KSb03Q/+CFjKTNDtEN5fNJuXS0+h+oop6nhpktM2i7
-gCpxeLNEaQaeoxR5093VN00oOJOYBvQoVGEDftEwdG6dWbTZsIykBF7aK+p8DMy9
-tCdc2GnGMEuFlUNA9ucv2Rv7IcuPdspnK31CZoMNKwIDAQABMA0GCSqGSIb3DQEB
-BQUAA4ICAQBROWec0HOsnLPN40gkBQ62mNBUJgcAr5K2eMIEMSRFRD2ldEVOvmCO
-u1Q62umy9tiSRiFQTcG1J9k0zlOjy/hfpBl2G1Zce0OoEeuNkH7c0W/idHSloWRZ
-YlK3tVJD6DzY6s9VbO6e/ncecNsXkirkWp/cvMYquH2d4OmSl0/hW0VMdxOCLxkA
-xbW+3Dh05u7tgKVRD67/GRvLtg+xHaOJqiOh3MpMaHy+6xT5Fd5K2QC0pcGtZuqF
-EnnfdeUI/Dy76yQE8pBfjaUFf3TS1n1E6kun1Nkf0X4pvwi8W1goLsPu5sWDNNga
-1RGYj0o5OdIo27qebfmu76WX0fNNd47VabtzNV+W7Msj0yeZg+hxAtAvs0ZEyJh+
-4biWsv+ALSlqz4sSdoOVGUEBdnkUrWN19lou62ix9vTmuCrVEA3TuZA3PR0+hqqQ
-/A/DcmWwxWYKyaBgxwHc/nGo1qWrDh22P5Rp7++Zw3kOCY6QmeJkAiHFs6Crw4ub
-HKVMw3fV5H9oiUFjadPZoCU51uXKX4YRqKxWJ5djlp4r1GCEQHyxngTsmH3komnw
-kh4LsEQRqdhuT0A4sZN7CenMJfQiFqupL7RVSycJFQpgzwVFmOzjCVT4PT/W5ARv
-9YtqEkvyoRTwErwuN/FIVvhWnIP/C69Z1/T/nXyj86P2G7PMgnchIQ==
------END CERTIFICATE-----
+MIIGVDCCBDygAwIBAgIJAJGMJhEr5q3dMA0GCSqGSIb3DQEBCwUAMHkxFjAUBgNV
+BAoTDW93bkNsb3VkIEluYy4xEjAQBgNVBAcTCUxleGluZ3RvbjEPMA0GA1UECBMG
+Qm9zdG9uMQswCQYDVQQGEwJVUzEtMCsGA1UEAxMkb3duQ2xvdWQgQ29kZSBTaWdu
+aW5nIFJvb3QgQXV0aG9yaXR5MB4XDTE2MDIwMzE3MDYyOVoXDTI2MDEzMTE3MDYy
+OVoweTEWMBQGA1UEChMNb3duQ2xvdWQgSW5jLjESMBAGA1UEBxMJTGV4aW5ndG9u
+MQ8wDQYDVQQIEwZCb3N0b24xCzAJBgNVBAYTAlVTMS0wKwYDVQQDEyRvd25DbG91
+ZCBDb2RlIFNpZ25pbmcgUm9vdCBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUA
+A4ICDwAwggIKAoICAQDGAqfV+pZuKD9rKsny6PxQWYV35bJYo2xdYxFpd8oI/Fco
+Ygjv5iZc9U4/iY0mN3wSDjYXJtMQnO96qthSI/bqsxrD9wutRKXYo/VEZALWL8vR
+F+cRpgmCrq98tF7fNEhEX2PdVlmwEWV8c7wL+QAd+qXrVz+MyJyw6jlh5JzEEqAR
+kNNRFm2d5+FPgWZeBNE0tbj7XxBTFTn/OMAOndhLo2dwhTXu6t2Caq15IZt6YoPM
+Ibn/Y3c2E76vpfWCznB4uEsEx4C4Hkdmzu5BwjPjcnPoFGobHaURMnwrEOI1s0cn
+V7kl2120I2Dr29NTL4vgnxRM2SQp3253NVmy9EbabszwfHy9bGH5G6IKQyTLyJHG
+AIAN3QHfr86N3t/ELekNb8bbh+2OBzuytMbTPlauKny7isVfciGUfnJgU54mMbIc
+1XBiYEgKjdkq/IEiYkjtOToS29AvCnDkH82piEeW0TMmcNN7/Vq79S1YR4ceZ4PQ
+d0Qm0y59nXPVZMso5em39TJH1PRwe93RPDN8NM434sfbdjqMqDi+3E+urG01AzwT
+BZj8lUvD/FvDB1no2p4/JKeHmlR/AQmfWFA0c6dv5DlzeIldwar4paDER9McGXvy
+GSTDVEhdEJrbK8pQh2pIkHZ6WkuMyTXDMTvyRtuPwlk68MVmYic/AHUSLrGT0wID
+AQABo4HeMIHbMAwGA1UdEwQFMAMBAf8wHQYDVR0OBBYEFM2KMEEv31J4fR3ufEH6
+yiLvmRPmMIGrBgNVHSMEgaMwgaCAFM2KMEEv31J4fR3ufEH6yiLvmRPmoX2kezB5
+MRYwFAYDVQQKEw1vd25DbG91ZCBJbmMuMRIwEAYDVQQHEwlMZXhpbmd0b24xDzAN
+BgNVBAgTBkJvc3RvbjELMAkGA1UEBhMCVVMxLTArBgNVBAMTJG93bkNsb3VkIENv
+ZGUgU2lnbmluZyBSb290IEF1dGhvcml0eYIJAJGMJhEr5q3dMA0GCSqGSIb3DQEB
+CwUAA4ICAQBDLisFDvjYv8nbAAfqU9A8q9nTtA5XAmRPBE4zoawesFnyYRPD5xf8
++/L9p3z7c5V4ui3yERd6PeNpMKW3NsY0TL6k3rYONQRwkNWE5eLcTelhVbqUBWoQ
+vTPJqQzP6HvOuErHv2yDBhO8graQiw8S3OOhQycrcPtSzGnenhvcYSJgJscx1EcE
+DAbTxfrTIyPgX4ouyoQPpPufUFYqYL/rNf9Ca03Gekyn9WFe9WGR7PzaKjn0dOQq
+wA9cPNitvwG//0emWZeH9naE4NPerzhwITyMDJUmQgZ/hW+lTTaZfISPQmMi24za
+00PbfeMYRNrkw21VkwkqLHqj9l7ud3hmyoTjKHdO8zOfeVyv3OfJmRLubv+x+wDE
+JSJNSyvgtMIlQ4WsM3mXUesN//3NsSGt/QUy9ARD7Nf8u1igchdxJLavXCJmnwYa
+jxxnGk16q1R5OJqDN9IbSbxRiS/WWKTJkhMBVQtsHMD2MK4Gtbw/J2n/4M/zioiS
+iZW1Eg1kI163oD/obEa5KzxJz+RXBGZef07q37Um8RTQ2kjI65sr/9oZ9tHdF9Zb
+vPGFcj/viac6O8Z9fDovTCfMHiGKwgDhrsQFkQz1/BEl2P1FIzNQeDBfyI7bI82x
+GIt/Th0uI+YIkhA0kLlq4cCoBjl0fL6hCy5DADdAMWFOwmUzG8EJWA==
+-----END CERTIFICATE----- \ No newline at end of file
diff --git a/resources/codesigning/root.key b/resources/codesigning/root.key
deleted file mode 100644
index 557b0a26e3a..00000000000
--- a/resources/codesigning/root.key
+++ /dev/null
@@ -1,51 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIJKgIBAAKCAgEAra2BMIsKboc0TcdS9kp7ZC/82pQOzpMBHLAZ+GLMOO5xHb6e
-uPAFaIU+3flO/g1osTtOsb5QCVIamE11+xBvZ/pgZxvkyDKts5XotCY97qtaRGRP
-XpXxmWnpdrnPIEVzGWBZkpU783sar3yuAdw8KGWjGliXnBDvYsrlMsxzAaRPGx7R
-gzlBsv6EzvVgEm7ZfUX5N/FSy1enLAj8Co4oukN2GfgGFNGKi4NtgcGZapU3sVI1
-gJlSKmqMZkhLimuNV57gCB3z+uaIqG/OrOCLyV1a96+zY3RdiCf2a8JoximloEmS
-nKGQTywK2SXiYiEOGCsy2QE8G2uXVrMFdJmw4/Hj9gRvtNjVSscpTgW3qAREp2oW
-XmeZyeVyma/hKyQFFm+Ne3xJ2GkDQZTZ4o45Kl2g4qZk5LVH57+JZt9LFAIIaOiN
-xmu4EKxT8yoPVeI9kvizk3NR5iTp0ein7bcfsgB2Cyrb1eciDDKc/q2dl+YPzdhn
-YJXmY+VVPZ5is0z3hselfnQWiJKjXvPwF2lZ8bfSkm9N0P/ghYykzQ7RDeXzSbl0
-tPofqKKep4aZLTNou4AqcXizRGkGnqMUedPd1TdNKDiTmAb0KFRhA37RMHRunVm0
-2bCMpARe2ivqfAzMvbQnXNhpxjBLhZVDQPbnL9kb+yHLj3bKZyt9QmaDDSsCAwEA
-AQKCAgEAnR6/JkRTPqTQW6D8W9YMBRoovTF+p8F0GxjxlbUDnmmQKeGeRB7YNbN9
-qWD25n0I/nVx/vj1/UiqyKgjGOvIbZ+kAQPKGJdIb5Qp/nguRTH9qqu45g/ujuSz
-EfaM/Fv4AbgZsLOTlfUDskiwPvyX68/vG1GUbtsfRhfZ+/fb/1s/OYDK99Ufq6f4
-TCbOMD7aQSvBh6upRE5a7Up/gakUDVYkjN/F2KWsmgRfWCjl+vddd+ywfFO4cqkL
-tSioNmSQbPlNIeq/I3fVn9PufJVzwMrVFgh82HeYein1E43ALa3VqcmFem/rVsS4
-V7SfNjlDP/gsuwcT8paGRigUwmScEkyXYJ7oSNEN8Xe4kWWakfwGpa1HmaYPdHx+
-O+G8coHp2kcc/tUZma+Ffo3tNRMfGcpowG+PetbCh4uSNPo5U5U5W53+vxgyZHFi
-lY7gc5HVi5JBSxmWwTa3RDcz1dByWS83NdObrxAntp3W9g8tVj2N9gfUnJS+wp3d
-m8HvO3bzIUuhQcWAtcnXqRAGsl+uc/xgdF2membV/yOHdn2Z1zXKEnjC1T6cEV06
-qocwgp0/EAMhzL4FP8xA9MvztZR7bJOyUihTIadG7Zb18XBea7yA73KvfYGrzjsg
-lmqV4CbGuo0If8SJD03xXthMqi5cBXu4V13sYAbNO8pPDjhfPIkCggEBAOUjScLN
-RoaoOBO3JUWoYauZrf9sa72/zzTOg+c8unQquExMjnsyEVJPD4+TpKGN5/sewwb5
-zksI5c1njOrdFdSKoKlgB/6owv2v70Uqe+HeVA+m5Qy6JSgMAAXZgJ5PtaCCu+Xq
-MOqTd/xInfP1oCecJF9UvqeQJBJN16fMXBib9J5+sLCRJnFNywfmlfAiIOa4MIoY
-Tz7LW+r4Zot0x2o6KcCT8AB3LJIz2seHmTf9Jjk17kw7pFJWtZf6eA1lgDlzadKJ
-iHgrdSbchDZv410B0df/ZV+gZ7PMgK/cbo3H3JOXPV1dxmTONTIIvxYj1LmOdMP4
-p5oeM367LUWQN20CggEBAMIJykbsm7IVthkMeCm/VhG/wd44iB0g5+us8q8pUO1+
-KfTzytHPjMack5a/XaEApRRiJpCAJNcBpUNbJqaOZQ1QqnX6ozlSR2aUi27noVz6
-/heG+3qZElejYfLMpJAF1crjdFJIqKucizc+E6AZ+nOixpJcDABYWby9QQw4O1Pr
-Ii3E7xyFvqizYzE7P/HG6P0gMxta9aKHKGhGHX51Uc+BUfF0T0ymXVvWLlfMg+HI
-SBPqMphW+YR0xwK21A2LvqYBM2MyaThY2wyVSZs9akjiAukRwX8l7lA5A/try0Q0
-1POyN6oo1H7iSHuraqXfDjcSpK5M/QOpXMuoPyTI//cCggEBAKCn00mwH6i+PUMl
-gA6M9p4YTDTwUcJiv+cofLcejyRv53QnoSajfh2VrTVfsWhMVMBvWxKDB674eBdC
-aT0q8elpoSfgWvqkXML+HecC2IUPGyU2QRZhVTf04fc3/sQA4zm9L/0N7GosJ05N
-o+Gu8DGVerMUefCGUaQ7y96snE3s2uBdt4i03J1Ii/foJmyNoT/jGLVaQgWnE7V1
-oIBayo6iZS/PCdFpvWhszxJi8nydE7W9KG1uy9GnVf9O7+mEpxig4StqnrKS1br/
-lfuNC37kjbrCKNOZZdxcoEWtah4iaXdZ7P6Ph1CafBWuqDvft4C6bwgQSYL3ded/
-WUiSyykCggEAePeThF3TvtUsPjd43kXriYsreLdzm/08uL+MWEkAq96gl5Y5Fk43
-LEbG+A77dvko8Skzc5h/3w6mkfRMhz90njVw37ZOddjmrHvk5VJAVfAf4lkDhG3T
-cpFn6e9MlIEexKrChN3JUZt5awonQAOSEO8krm/2B20NHM47tDuGOQ34s+H3U6fJ
-sfCL4VBX0Ao6jDu7wM0XH6j1NvSnRIQtaZjslgP1wApjX3KKV7Anc+XhkZDK1BA8
-5CfNPdLvJja9t04+VBREZp12ikSzq7VBAojsWZL5N6RVCuxQoDiWc0IglIDBlTJ5
-L1Uw7PBzv07s1MappgRXJCY8tLaCDxPEBwKCAQEA1Rxj0YpQ1D+8oFQ3ck0b4ODy
-DCSCNe6Xw+Wzv5BqGVsQCmW14uVBT+S/qij5dTrGIPXudLSHtdjs9tmoDqnkxY/o
-Nj5rx6J2brnNLTD7yo/j74kgaRwSuHafpGX1C0zge0rgIgVu8DhWHan7F/38K0cO
-T1jYJbYcTAvEcO1XXXItnaHR1ETY4p0G5FvUTLWaNQnQTU3r5ZaCkjXN9UBA2k6U
-6j6A9/JXIlNPFNoB103iAD5jvHa96AlivHSyp4UTlsiwAxec316CY2zdWrVWQCF4
-J8DspH3ygeLtvKOveEYsiaiNuJLKREC2GIRUm6O4C/RdP0s0QAODpk+yGCfukg==
------END RSA PRIVATE KEY-----
diff --git a/tests/karma.config.js b/tests/karma.config.js
index 4a7a9ad236e..2b569fb7584 100644
--- a/tests/karma.config.js
+++ b/tests/karma.config.js
@@ -89,8 +89,9 @@ module.exports = function(config) {
'apps/comments/js/app.js',
'apps/comments/js/commentmodel.js',
'apps/comments/js/commentcollection.js',
+ 'apps/comments/js/commentsummarymodel.js',
'apps/comments/js/commentstabview.js',
- 'apps/comments/js/filesplugin'
+ 'apps/comments/js/filesplugin.js'
],
testFiles: ['apps/comments/tests/js/**/*.js']
},
diff --git a/tests/lib/appframework/AppTest.php b/tests/lib/appframework/AppTest.php
index 7cba0e6db6b..3d41d6590aa 100644
--- a/tests/lib/appframework/AppTest.php
+++ b/tests/lib/appframework/AppTest.php
@@ -79,9 +79,9 @@ class AppTest extends \Test\TestCase {
$this->container['OCP\\AppFramework\\Http\\IOutput'] = $this->io;
$this->container['urlParams'] = array();
- $this->appPath = __DIR__ . '/../../../apps/namespacetestapp/appinfo';
- $infoXmlPath = $this->appPath . '/info.xml';
- mkdir($this->appPath, 0777, true);
+ $this->appPath = __DIR__ . '/../../../apps/namespacetestapp';
+ $infoXmlPath = $this->appPath . '/appinfo/info.xml';
+ mkdir($this->appPath . '/appinfo', 0777, true);
$xml = '<?xml version="1.0" encoding="UTF-8"?>' .
'<info>' .
diff --git a/tests/lib/share20/defaultshareprovidertest.php b/tests/lib/share20/defaultshareprovidertest.php
index 32c0b342c41..19f21fba7b1 100644
--- a/tests/lib/share20/defaultshareprovidertest.php
+++ b/tests/lib/share20/defaultshareprovidertest.php
@@ -157,21 +157,13 @@ class DefaultShareProviderTest extends \Test\TestCase {
['shareOwner', $shareOwnerFolder],
]));
- $this->userManager
- ->method('get')
- ->will($this->returnValueMap([
- ['sharedWith', $sharedWith],
- ['sharedBy', $sharedBy],
- ['shareOwner', $shareOwner],
- ]));
-
$share = $this->provider->getShareById($id);
$this->assertEquals($id, $share->getId());
$this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
- $this->assertEquals($sharedWith, $share->getSharedWith());
- $this->assertEquals($sharedBy, $share->getSharedBy());
- $this->assertEquals($shareOwner, $share->getShareOwner());
+ $this->assertEquals('sharedWith', $share->getSharedWith());
+ $this->assertEquals('sharedBy', $share->getSharedBy());
+ $this->assertEquals('shareOwner', $share->getShareOwner());
$this->assertEquals($ownerPath, $share->getNode());
$this->assertEquals(13, $share->getPermissions());
$this->assertEquals(null, $share->getToken());
@@ -221,25 +213,13 @@ class DefaultShareProviderTest extends \Test\TestCase {
['shareOwner', $shareOwnerFolder],
]));
- $this->userManager
- ->method('get')
- ->will($this->returnValueMap([
- ['sharedBy', $sharedBy],
- ['shareOwner', $shareOwner],
- ]));
- $this->groupManager
- ->expects($this->once())
- ->method('get')
- ->with('sharedWith')
- ->willReturn($sharedWith);
-
$share = $this->provider->getShareById($id);
$this->assertEquals($id, $share->getId());
$this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
- $this->assertEquals($sharedWith, $share->getSharedWith());
- $this->assertEquals($sharedBy, $share->getSharedBy());
- $this->assertEquals($shareOwner, $share->getShareOwner());
+ $this->assertEquals('sharedWith', $share->getSharedWith());
+ $this->assertEquals('sharedBy', $share->getSharedBy());
+ $this->assertEquals('shareOwner', $share->getShareOwner());
$this->assertEquals($ownerPath, $share->getNode());
$this->assertEquals(13, $share->getPermissions());
$this->assertEquals(null, $share->getToken());
@@ -271,13 +251,13 @@ class DefaultShareProviderTest extends \Test\TestCase {
]));
$this->groupManager->method('get')->with('group0')->willReturn($group0);
- $share = $this->provider->getShareById($id, $user1);
+ $share = $this->provider->getShareById($id, 'user1');
$this->assertEquals($id, $share->getId());
$this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
- $this->assertSame($group0, $share->getSharedWith());
- $this->assertSame($user0, $share->getSharedBy());
- $this->assertSame($user0, $share->getShareOwner());
+ $this->assertSame('group0', $share->getSharedWith());
+ $this->assertSame('user0', $share->getSharedBy());
+ $this->assertSame('user0', $share->getShareOwner());
$this->assertSame($node, $share->getNode());
$this->assertEquals(0, $share->getPermissions());
$this->assertEquals(null, $share->getToken());
@@ -339,8 +319,8 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals($id, $share->getId());
$this->assertEquals(\OCP\Share::SHARE_TYPE_LINK, $share->getShareType());
$this->assertEquals('sharedWith', $share->getPassword());
- $this->assertEquals($sharedBy, $share->getSharedBy());
- $this->assertEquals($shareOwner, $share->getShareOwner());
+ $this->assertEquals('sharedBy', $share->getSharedBy());
+ $this->assertEquals('shareOwner', $share->getShareOwner());
$this->assertEquals($ownerPath, $share->getNode());
$this->assertEquals(13, $share->getPermissions());
$this->assertEquals('token', $share->getToken());
@@ -559,9 +539,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
//Child1
$this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $children[0]->getShareType());
- $this->assertEquals($user1, $children[0]->getSharedWith());
- $this->assertEquals($user2, $children[0]->getSharedBy());
- $this->assertEquals($shareOwner, $children[0]->getShareOwner());
+ $this->assertEquals('user1', $children[0]->getSharedWith());
+ $this->assertEquals('user2', $children[0]->getSharedBy());
+ $this->assertEquals('shareOwner', $children[0]->getShareOwner());
$this->assertEquals($ownerPath, $children[0]->getNode());
$this->assertEquals(2, $children[0]->getPermissions());
$this->assertEquals(null, $children[0]->getToken());
@@ -570,9 +550,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
//Child2
$this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $children[1]->getShareType());
- $this->assertEquals($group1, $children[1]->getSharedWith());
- $this->assertEquals($user3, $children[1]->getSharedBy());
- $this->assertEquals($shareOwner, $children[1]->getShareOwner());
+ $this->assertEquals('group1', $children[1]->getSharedWith());
+ $this->assertEquals('user3', $children[1]->getSharedBy());
+ $this->assertEquals('shareOwner', $children[1]->getShareOwner());
$this->assertEquals($ownerPath, $children[1]->getNode());
$this->assertEquals(4, $children[1]->getPermissions());
$this->assertEquals(null, $children[1]->getToken());
@@ -583,21 +563,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
public function testCreateUserShare() {
$share = new \OC\Share20\Share();
- $sharedWith = $this->getMock('OCP\IUser');
- $sharedWith->method('getUID')->willReturn('sharedWith');
- $sharedBy = $this->getMock('OCP\IUser');
- $sharedBy->method('getUID')->willReturn('sharedBy');
$shareOwner = $this->getMock('OCP\IUser');
$shareOwner->method('getUID')->WillReturn('shareOwner');
- $this->userManager
- ->method('get')
- ->will($this->returnValueMap([
- ['sharedWith', $sharedWith],
- ['sharedBy', $sharedBy],
- ['shareOwner', $shareOwner],
- ]));
-
$path = $this->getMock('\OCP\Files\File');
$path->method('getId')->willReturn(100);
$path->method('getOwner')->willReturn($shareOwner);
@@ -619,9 +587,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
->willReturn([$path]);
$share->setShareType(\OCP\Share::SHARE_TYPE_USER);
- $share->setSharedWith($sharedWith);
- $share->setSharedBy($sharedBy);
- $share->setShareOwner($shareOwner);
+ $share->setSharedWith('sharedWith');
+ $share->setSharedBy('sharedBy');
+ $share->setShareOwner('shareOwner');
$share->setNode($path);
$share->setPermissions(1);
$share->setTarget('/target');
@@ -631,9 +599,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertNotNull($share2->getId());
$this->assertSame('ocinternal:'.$share2->getId(), $share2->getFullId());
$this->assertSame(\OCP\Share::SHARE_TYPE_USER, $share2->getShareType());
- $this->assertSame($sharedWith, $share2->getSharedWith());
- $this->assertSame($sharedBy, $share2->getSharedBy());
- $this->assertSame($shareOwner, $share2->getShareOwner());
+ $this->assertSame('sharedWith', $share2->getSharedWith());
+ $this->assertSame('sharedBy', $share2->getSharedBy());
+ $this->assertSame('shareOwner', $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
$this->assertSame('/target', $share2->getTarget());
$this->assertLessThanOrEqual(new \DateTime(), $share2->getShareTime());
@@ -643,23 +611,8 @@ class DefaultShareProviderTest extends \Test\TestCase {
public function testCreateGroupShare() {
$share = new \OC\Share20\Share();
- $sharedWith = $this->getMock('OCP\IGroup');
- $sharedWith->method('getGID')->willReturn('sharedWith');
- $sharedBy = $this->getMock('OCP\IUser');
- $sharedBy->method('getUID')->willReturn('sharedBy');
- $shareOwner = $this->getMock('OCP\IUser');
- $shareOwner->method('getUID')->WillReturn('shareOwner');
-
- $this->userManager
- ->method('get')
- ->will($this->returnValueMap([
- ['sharedBy', $sharedBy],
- ['shareOwner', $shareOwner],
- ]));
- $this->groupManager
- ->method('get')
- ->with('sharedWith')
- ->willReturn($sharedWith);
+ $shareOwner = $this->getMock('\OCP\IUser');
+ $shareOwner->method('getUID')->willReturn('shareOwner');
$path = $this->getMock('\OCP\Files\Folder');
$path->method('getId')->willReturn(100);
@@ -682,9 +635,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
->willReturn([$path]);
$share->setShareType(\OCP\Share::SHARE_TYPE_GROUP);
- $share->setSharedWith($sharedWith);
- $share->setSharedBy($sharedBy);
- $share->setShareOwner($shareOwner);
+ $share->setSharedWith('sharedWith');
+ $share->setSharedBy('sharedBy');
+ $share->setShareOwner('shareOwner');
$share->setNode($path);
$share->setPermissions(1);
$share->setTarget('/target');
@@ -694,9 +647,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertNotNull($share2->getId());
$this->assertSame('ocinternal:'.$share2->getId(), $share2->getFullId());
$this->assertSame(\OCP\Share::SHARE_TYPE_GROUP, $share2->getShareType());
- $this->assertSame($sharedWith, $share2->getSharedWith());
- $this->assertSame($sharedBy, $share2->getSharedBy());
- $this->assertSame($shareOwner, $share2->getShareOwner());
+ $this->assertSame('sharedWith', $share2->getSharedWith());
+ $this->assertSame('sharedBy', $share2->getSharedBy());
+ $this->assertSame('shareOwner', $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
$this->assertSame('/target', $share2->getTarget());
$this->assertLessThanOrEqual(new \DateTime(), $share2->getShareTime());
@@ -706,17 +659,8 @@ class DefaultShareProviderTest extends \Test\TestCase {
public function testCreateLinkShare() {
$share = new \OC\Share20\Share();
- $sharedBy = $this->getMock('OCP\IUser');
- $sharedBy->method('getUID')->willReturn('sharedBy');
- $shareOwner = $this->getMock('OCP\IUser');
- $shareOwner->method('getUID')->WillReturn('shareOwner');
-
- $this->userManager
- ->method('get')
- ->will($this->returnValueMap([
- ['sharedBy', $sharedBy],
- ['shareOwner', $shareOwner],
- ]));
+ $shareOwner = $this->getMock('\OCP\IUser');
+ $shareOwner->method('getUID')->willReturn('shareOwner');
$path = $this->getMock('\OCP\Files\Folder');
$path->method('getId')->willReturn(100);
@@ -739,8 +683,8 @@ class DefaultShareProviderTest extends \Test\TestCase {
->willReturn([$path]);
$share->setShareType(\OCP\Share::SHARE_TYPE_LINK);
- $share->setSharedBy($sharedBy);
- $share->setShareOwner($shareOwner);
+ $share->setSharedBy('sharedBy');
+ $share->setShareOwner('shareOwner');
$share->setNode($path);
$share->setPermissions(1);
$share->setPassword('password');
@@ -754,8 +698,8 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertNotNull($share2->getId());
$this->assertSame('ocinternal:'.$share2->getId(), $share2->getFullId());
$this->assertSame(\OCP\Share::SHARE_TYPE_LINK, $share2->getShareType());
- $this->assertSame($sharedBy, $share2->getSharedBy());
- $this->assertSame($shareOwner, $share2->getShareOwner());
+ $this->assertSame('sharedBy', $share2->getSharedBy());
+ $this->assertSame('shareOwner', $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
$this->assertSame('/target', $share2->getTarget());
$this->assertLessThanOrEqual(new \DateTime(), $share2->getShareTime());
@@ -783,17 +727,6 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb->execute();
$id = $qb->getLastInsertId();
- $owner = $this->getMock('\OCP\IUser');
- $owner->method('getUID')->willReturn('shareOwner');
- $initiator = $this->getMock('\OCP\IUser');
- $initiator->method('getUID')->willReturn('sharedBy');
-
- $this->userManager->method('get')
- ->will($this->returnValueMap([
- ['sharedBy', $initiator],
- ['shareOwner', $owner],
- ]));
-
$file = $this->getMock('\OCP\Files\File');
$this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf());
@@ -801,8 +734,8 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $this->provider->getShareByToken('secrettoken');
$this->assertEquals($id, $share->getId());
- $this->assertSame($owner, $share->getShareOwner());
- $this->assertSame($initiator, $share->getSharedBy());
+ $this->assertSame('shareOwner', $share->getShareOwner());
+ $this->assertSame('sharedBy', $share->getSharedBy());
$this->assertSame('secrettoken', $share->getToken());
$this->assertSame('password', $share->getPassword());
$this->assertSame(null, $share->getSharedWith());
@@ -845,31 +778,18 @@ class DefaultShareProviderTest extends \Test\TestCase {
]);
$this->assertEquals(1, $qb->execute());
- $user = $this->getMock('\OCP\IUser');
- $user->method('getUID')->willReturn('sharedWith');
- $owner = $this->getMock('\OCP\IUser');
- $owner->method('getUID')->willReturn('shareOwner');
- $initiator = $this->getMock('\OCP\IUser');
- $initiator->method('getUID')->willReturn('sharedBy');
-
- $this->userManager->method('get')->willReturnMap([
- ['sharedWith', $user],
- ['shareOwner', $owner],
- ['sharedBy', $initiator],
- ]);
-
$file = $this->getMock('\OCP\Files\File');
$this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf());
$this->rootFolder->method('getById')->with(42)->willReturn([$file]);
- $share = $this->provider->getSharedWith($user, \OCP\Share::SHARE_TYPE_USER, null, 1 , 0);
+ $share = $this->provider->getSharedWith('sharedWith', \OCP\Share::SHARE_TYPE_USER, null, 1 , 0);
$this->assertCount(1, $share);
$share = $share[0];
$this->assertEquals($id, $share->getId());
- $this->assertEquals($user, $share->getSharedWith());
- $this->assertEquals($owner, $share->getShareOwner());
- $this->assertEquals($initiator, $share->getSharedBy());
+ $this->assertEquals('sharedWith', $share->getSharedWith());
+ $this->assertEquals('shareOwner', $share->getShareOwner());
+ $this->assertEquals('sharedBy', $share->getSharedBy());
$this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
}
@@ -922,6 +842,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$initiator->method('getUID')->willReturn('sharedBy');
$this->userManager->method('get')->willReturnMap([
+ ['sharedWith', $user],
['shareOwner', $owner],
['sharedBy', $initiator],
]);
@@ -932,14 +853,14 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf());
$this->rootFolder->method('getById')->with(42)->willReturn([$file]);
- $share = $this->provider->getSharedWith($user, \OCP\Share::SHARE_TYPE_GROUP, null, 20 , 1);
+ $share = $this->provider->getSharedWith('sharedWith', \OCP\Share::SHARE_TYPE_GROUP, null, 20 , 1);
$this->assertCount(1, $share);
$share = $share[0];
$this->assertEquals($id, $share->getId());
- $this->assertEquals($group, $share->getSharedWith());
- $this->assertEquals($owner, $share->getShareOwner());
- $this->assertEquals($initiator, $share->getSharedBy());
+ $this->assertEquals('sharedWith', $share->getSharedWith());
+ $this->assertEquals('shareOwner', $share->getShareOwner());
+ $this->assertEquals('sharedBy', $share->getSharedBy());
$this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
}
@@ -1007,6 +928,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$initiator->method('getUID')->willReturn('sharedBy');
$this->userManager->method('get')->willReturnMap([
+ ['user', $user],
['shareOwner', $owner],
['sharedBy', $initiator],
]);
@@ -1017,14 +939,14 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf());
$this->rootFolder->method('getById')->with(42)->willReturn([$file]);
- $share = $this->provider->getSharedWith($user, \OCP\Share::SHARE_TYPE_GROUP, null, -1, 0);
+ $share = $this->provider->getSharedWith('user', \OCP\Share::SHARE_TYPE_GROUP, null, -1, 0);
$this->assertCount(1, $share);
$share = $share[0];
$this->assertSame($id, $share->getId());
- $this->assertSame($group, $share->getSharedWith());
- $this->assertSame($owner, $share->getShareOwner());
- $this->assertSame($initiator, $share->getSharedBy());
+ $this->assertSame('sharedWith', $share->getSharedWith());
+ $this->assertSame('shareOwner', $share->getShareOwner());
+ $this->assertSame('sharedBy', $share->getSharedBy());
$this->assertSame(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
$this->assertSame(0, $share->getPermissions());
$this->assertSame('userTarget', $share->getTarget());
@@ -1051,14 +973,14 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf());
$this->rootFolder->method('getById')->with(43)->willReturn([$file]);
- $share = $this->provider->getSharedWith($user0, \OCP\Share::SHARE_TYPE_USER, $file, -1, 0);
+ $share = $this->provider->getSharedWith('user0', \OCP\Share::SHARE_TYPE_USER, $file, -1, 0);
$this->assertCount(1, $share);
$share = $share[0];
$this->assertEquals($id, $share->getId());
- $this->assertSame($user0, $share->getSharedWith());
- $this->assertSame($user1, $share->getShareOwner());
- $this->assertSame($user1, $share->getSharedBy());
+ $this->assertSame('user0', $share->getSharedWith());
+ $this->assertSame('user1', $share->getShareOwner());
+ $this->assertSame('user1', $share->getSharedBy());
$this->assertSame($file, $share->getNode());
$this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
}
@@ -1090,14 +1012,14 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf());
$this->rootFolder->method('getById')->with(43)->willReturn([$node]);
- $share = $this->provider->getSharedWith($user0, \OCP\Share::SHARE_TYPE_GROUP, $node, -1, 0);
+ $share = $this->provider->getSharedWith('user0', \OCP\Share::SHARE_TYPE_GROUP, $node, -1, 0);
$this->assertCount(1, $share);
$share = $share[0];
$this->assertEquals($id, $share->getId());
- $this->assertSame($group0, $share->getSharedWith());
- $this->assertSame($user1, $share->getShareOwner());
- $this->assertSame($user1, $share->getSharedBy());
+ $this->assertSame('group0', $share->getSharedWith());
+ $this->assertSame('user1', $share->getShareOwner());
+ $this->assertSame('user1', $share->getSharedBy());
$this->assertSame($node, $share->getNode());
$this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
}
@@ -1133,31 +1055,18 @@ class DefaultShareProviderTest extends \Test\TestCase {
]);
$this->assertEquals(1, $qb->execute());
- $user = $this->getMock('\OCP\IUser');
- $user->method('getUID')->willReturn('sharedWith');
- $owner = $this->getMock('\OCP\IUser');
- $owner->method('getUID')->willReturn('shareOwner');
- $initiator = $this->getMock('\OCP\IUser');
- $initiator->method('getUID')->willReturn('sharedBy');
-
- $this->userManager->method('get')->willReturnMap([
- ['sharedWith', $user],
- ['shareOwner', $owner],
- ['sharedBy', $initiator],
- ]);
-
$file = $this->getMock('\OCP\Files\File');
$this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf());
$this->rootFolder->method('getById')->with(42)->willReturn([$file]);
- $share = $this->provider->getSharesBy($initiator, \OCP\Share::SHARE_TYPE_USER, null, false, 1, 0);
+ $share = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_USER, null, false, 1, 0);
$this->assertCount(1, $share);
$share = $share[0];
$this->assertEquals($id, $share->getId());
- $this->assertEquals($user, $share->getSharedWith());
- $this->assertEquals($owner, $share->getShareOwner());
- $this->assertEquals($initiator, $share->getSharedBy());
+ $this->assertEquals('sharedWith', $share->getSharedWith());
+ $this->assertEquals('shareOwner', $share->getShareOwner());
+ $this->assertEquals('sharedBy', $share->getSharedBy());
$this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
$this->assertEquals(13, $share->getPermissions());
$this->assertEquals('myTarget', $share->getTarget());
@@ -1194,32 +1103,19 @@ class DefaultShareProviderTest extends \Test\TestCase {
]);
$this->assertEquals(1, $qb->execute());
- $user = $this->getMock('\OCP\IUser');
- $user->method('getUID')->willReturn('sharedWith');
- $owner = $this->getMock('\OCP\IUser');
- $owner->method('getUID')->willReturn('shareOwner');
- $initiator = $this->getMock('\OCP\IUser');
- $initiator->method('getUID')->willReturn('sharedBy');
-
- $this->userManager->method('get')->willReturnMap([
- ['sharedWith', $user],
- ['shareOwner', $owner],
- ['sharedBy', $initiator],
- ]);
-
$file = $this->getMock('\OCP\Files\File');
$file->method('getId')->willReturn(42);
$this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf());
$this->rootFolder->method('getById')->with(42)->willReturn([$file]);
- $share = $this->provider->getSharesBy($initiator, \OCP\Share::SHARE_TYPE_USER, $file, false, 1, 0);
+ $share = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_USER, $file, false, 1, 0);
$this->assertCount(1, $share);
$share = $share[0];
$this->assertEquals($id, $share->getId());
- $this->assertEquals($user, $share->getSharedWith());
- $this->assertEquals($owner, $share->getShareOwner());
- $this->assertEquals($initiator, $share->getSharedBy());
+ $this->assertEquals('sharedWith', $share->getSharedWith());
+ $this->assertEquals('shareOwner', $share->getShareOwner());
+ $this->assertEquals('sharedBy', $share->getSharedBy());
$this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
$this->assertEquals(13, $share->getPermissions());
$this->assertEquals('myTarget', $share->getTarget());
@@ -1256,41 +1152,28 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals(1, $qb->execute());
$id2 = $qb->getLastInsertId();
- $user = $this->getMock('\OCP\IUser');
- $user->method('getUID')->willReturn('sharedWith');
- $owner = $this->getMock('\OCP\IUser');
- $owner->method('getUID')->willReturn('shareOwner');
- $initiator = $this->getMock('\OCP\IUser');
- $initiator->method('getUID')->willReturn('sharedBy');
-
- $this->userManager->method('get')->willReturnMap([
- ['sharedWith', $user],
- ['shareOwner', $owner],
- ['sharedBy', $initiator],
- ]);
-
$file = $this->getMock('\OCP\Files\File');
$file->method('getId')->willReturn(42);
$this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf());
$this->rootFolder->method('getById')->with(42)->willReturn([$file]);
- $shares = $this->provider->getSharesBy($owner, \OCP\Share::SHARE_TYPE_USER, null, true, -1, 0);
+ $shares = $this->provider->getSharesBy('shareOwner', \OCP\Share::SHARE_TYPE_USER, null, true, -1, 0);
$this->assertCount(2, $shares);
$share = $shares[0];
$this->assertEquals($id1, $share->getId());
- $this->assertSame($user, $share->getSharedWith());
- $this->assertSame($owner, $share->getShareOwner());
- $this->assertSame($owner, $share->getSharedBy());
+ $this->assertSame('sharedWith', $share->getSharedWith());
+ $this->assertSame('shareOwner', $share->getShareOwner());
+ $this->assertSame('shareOwner', $share->getSharedBy());
$this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
$this->assertEquals(13, $share->getPermissions());
$this->assertEquals('myTarget', $share->getTarget());
$share = $shares[1];
$this->assertEquals($id2, $share->getId());
- $this->assertSame($user, $share->getSharedWith());
- $this->assertSame($owner, $share->getShareOwner());
- $this->assertSame($initiator, $share->getSharedBy());
+ $this->assertSame('sharedWith', $share->getSharedWith());
+ $this->assertSame('shareOwner', $share->getShareOwner());
+ $this->assertSame('sharedBy', $share->getSharedBy());
$this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
$this->assertEquals(0, $share->getPermissions());
$this->assertEquals('userTarget', $share->getTarget());
@@ -1334,7 +1217,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $this->provider->getShareById($id);
- $this->provider->deleteFromSelf($share, $user2);
+ $this->provider->deleteFromSelf($share, 'user2');
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->select('*')
@@ -1405,7 +1288,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $this->provider->getShareById($id);
- $this->provider->deleteFromSelf($share, $user2);
+ $this->provider->deleteFromSelf($share, 'user2');
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->select('*')
@@ -1465,7 +1348,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $this->provider->getShareById($id);
- $this->provider->deleteFromSelf($share, $user2);
+ $this->provider->deleteFromSelf($share, 'user2');
}
public function testDeleteFromSelfUser() {
@@ -1501,7 +1384,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $this->provider->getShareById($id);
- $this->provider->deleteFromSelf($share, $user2);
+ $this->provider->deleteFromSelf($share, 'user2');
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->select('*')
@@ -1627,18 +1510,18 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $this->provider->getShareById($id);
- $share->setSharedWith($users['user3']);
- $share->setSharedBy($users['user4']);
- $share->setShareOwner($users['user5']);
+ $share->setSharedWith('user3');
+ $share->setSharedBy('user4');
+ $share->setShareOwner('user5');
$share->setNode($file2);
$share->setPermissions(1);
$share2 = $this->provider->update($share);
$this->assertEquals($id, $share2->getId());
- $this->assertSame($users['user3'], $share2->getSharedWith());
- $this->assertSame($users['user4'], $share2->getSharedBy());
- $this->assertSame($users['user5'], $share2->getShareOwner());
+ $this->assertSame('user3', $share2->getSharedWith());
+ $this->assertSame('user4', $share2->getSharedBy());
+ $this->assertSame('user5', $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
}
@@ -1677,8 +1560,8 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $this->provider->getShareById($id);
$share->setPassword('password');
- $share->setSharedBy($users['user4']);
- $share->setShareOwner($users['user5']);
+ $share->setSharedBy('user4');
+ $share->setShareOwner('user5');
$share->setNode($file2);
$share->setPermissions(1);
@@ -1686,8 +1569,8 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals($id, $share2->getId());
$this->assertEquals('password', $share->getPassword());
- $this->assertSame($users['user4'], $share2->getSharedBy());
- $this->assertSame($users['user5'], $share2->getShareOwner());
+ $this->assertSame('user4', $share2->getSharedBy());
+ $this->assertSame('user5', $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
}
@@ -1726,8 +1609,8 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $this->provider->getShareById($id);
$share->setPassword(null);
- $share->setSharedBy($users['user4']);
- $share->setShareOwner($users['user5']);
+ $share->setSharedBy('user4');
+ $share->setShareOwner('user5');
$share->setNode($file2);
$share->setPermissions(1);
@@ -1735,8 +1618,8 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals($id, $share2->getId());
$this->assertEquals(null, $share->getPassword());
- $this->assertSame($users['user4'], $share2->getSharedBy());
- $this->assertSame($users['user5'], $share2->getShareOwner());
+ $this->assertSame('user4', $share2->getSharedBy());
+ $this->assertSame('user5', $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
}
@@ -1787,9 +1670,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $this->provider->getShareById($id);
- $share->setSharedWith($groups['group0']);
- $share->setSharedBy($users['user4']);
- $share->setShareOwner($users['user5']);
+ $share->setSharedWith('group0');
+ $share->setSharedBy('user4');
+ $share->setShareOwner('user5');
$share->setNode($file2);
$share->setPermissions(1);
@@ -1797,9 +1680,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals($id, $share2->getId());
// Group shares do not allow updating the recipient
- $this->assertSame($groups['group0'], $share2->getSharedWith());
- $this->assertSame($users['user4'], $share2->getSharedBy());
- $this->assertSame($users['user5'], $share2->getShareOwner());
+ $this->assertSame('group0', $share2->getSharedWith());
+ $this->assertSame('user4', $share2->getSharedBy());
+ $this->assertSame('user5', $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
}
@@ -1856,9 +1739,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $this->provider->getShareById($id);
- $share->setSharedWith($groups['group0']);
- $share->setSharedBy($users['user4']);
- $share->setShareOwner($users['user5']);
+ $share->setSharedWith('group0');
+ $share->setSharedBy('user4');
+ $share->setShareOwner('user5');
$share->setNode($file2);
$share->setPermissions(1);
@@ -1866,9 +1749,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals($id, $share2->getId());
// Group shares do not allow updating the recipient
- $this->assertSame($groups['group0'], $share2->getSharedWith());
- $this->assertSame($users['user4'], $share2->getSharedBy());
- $this->assertSame($users['user5'], $share2->getShareOwner());
+ $this->assertSame('group0', $share2->getSharedWith());
+ $this->assertSame('user4', $share2->getSharedBy());
+ $this->assertSame('user5', $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
$qb = $this->dbConn->getQueryBuilder();
@@ -1949,18 +1832,18 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf());
$this->rootFolder->method('getById')->willReturn([$folder]);
- $share = $this->provider->getShareById($id, $user0);
+ $share = $this->provider->getShareById($id, 'user0');
$share->setTarget('/newTarget');
- $this->provider->move($share, $user0);
+ $this->provider->move($share, 'user0');
- $share = $this->provider->getShareById($id, $user0);
+ $share = $this->provider->getShareById($id, 'user0');
$this->assertSame('/newTarget', $share->getTarget());
$share->setTarget('/ultraNewTarget');
- $this->provider->move($share, $user0);
+ $this->provider->move($share, 'user0');
- $share = $this->provider->getShareById($id, $user0);
+ $share = $this->provider->getShareById($id, 'user0');
$this->assertSame('/ultraNewTarget', $share->getTarget());
}
}
diff --git a/tests/lib/share20/managertest.php b/tests/lib/share20/managertest.php
index 34cc39a77df..aa286cc4719 100644
--- a/tests/lib/share20/managertest.php
+++ b/tests/lib/share20/managertest.php
@@ -20,6 +20,7 @@
*/
namespace Test\Share20;
+use OCP\IUserManager;
use OCP\Share\IProviderFactory;
use OCP\Share\IShare;
use OC\Share20\Manager;
@@ -74,6 +75,9 @@ class ManagerTest extends \Test\TestCase {
/** @var DummyFactory */
protected $factory;
+ /** @var IUserManager */
+ protected $userManager;
+
public function setUp() {
$this->logger = $this->getMock('\OCP\ILogger');
@@ -82,6 +86,7 @@ class ManagerTest extends \Test\TestCase {
$this->hasher = $this->getMock('\OCP\Security\IHasher');
$this->mountManager = $this->getMock('\OCP\Files\Mount\IMountManager');
$this->groupManager = $this->getMock('\OCP\IGroupManager');
+ $this->userManager = $this->getMock('\OCP\IUserManager');
$this->l = $this->getMock('\OCP\IL10N');
$this->l->method('t')
@@ -99,7 +104,8 @@ class ManagerTest extends \Test\TestCase {
$this->mountManager,
$this->groupManager,
$this->l,
- $this->factory
+ $this->factory,
+ $this->userManager
);
$this->defaultProvider = $this->getMockBuilder('\OC\Share20\DefaultShareProvider')
@@ -124,7 +130,8 @@ class ManagerTest extends \Test\TestCase {
$this->mountManager,
$this->groupManager,
$this->l,
- $this->factory
+ $this->factory,
+ $this->userManager
]);
}
@@ -151,24 +158,21 @@ class ManagerTest extends \Test\TestCase {
$group->method('getGID')->willReturn('sharedWithGroup');
return [
- [\OCP\Share::SHARE_TYPE_USER, $user, 'sharedWithUser'],
- [\OCP\Share::SHARE_TYPE_GROUP, $group, 'sharedWithGroup'],
- [\OCP\Share::SHARE_TYPE_LINK, '', ''],
- [\OCP\Share::SHARE_TYPE_REMOTE, 'foo@bar.com', 'foo@bar.com'],
+ [\OCP\Share::SHARE_TYPE_USER, 'sharedWithUser'],
+ [\OCP\Share::SHARE_TYPE_GROUP, 'sharedWithGroup'],
+ [\OCP\Share::SHARE_TYPE_LINK, ''],
+ [\OCP\Share::SHARE_TYPE_REMOTE, 'foo@bar.com'],
];
}
/**
* @dataProvider dataTestDelete
*/
- public function testDelete($shareType, $sharedWith, $sharedWith_string) {
+ public function testDelete($shareType, $sharedWith) {
$manager = $this->createManagerMock()
->setMethods(['getShareById', 'deleteChildren'])
->getMock();
- $sharedBy = $this->getMock('\OCP\IUser');
- $sharedBy->method('getUID')->willReturn('sharedBy');
-
$path = $this->getMock('\OCP\Files\File');
$path->method('getId')->willReturn(1);
@@ -177,7 +181,7 @@ class ManagerTest extends \Test\TestCase {
->setProviderId('prov')
->setShareType($shareType)
->setSharedWith($sharedWith)
- ->setSharedBy($sharedBy)
+ ->setSharedBy('sharedBy')
->setNode($path)
->setTarget('myTarget');
@@ -198,7 +202,7 @@ class ManagerTest extends \Test\TestCase {
'itemType' => 'file',
'itemSource' => 1,
'shareType' => $shareType,
- 'shareWith' => $sharedWith_string,
+ 'shareWith' => $sharedWith,
'itemparent' => null,
'uidOwner' => 'sharedBy',
'fileSource' => 1,
@@ -210,7 +214,7 @@ class ManagerTest extends \Test\TestCase {
'itemType' => 'file',
'itemSource' => 1,
'shareType' => $shareType,
- 'shareWith' => $sharedWith_string,
+ 'shareWith' => $sharedWith,
'itemparent' => null,
'uidOwner' => 'sharedBy',
'fileSource' => 1,
@@ -221,7 +225,7 @@ class ManagerTest extends \Test\TestCase {
'itemType' => 'file',
'itemSource' => 1,
'shareType' => $shareType,
- 'shareWith' => $sharedWith_string,
+ 'shareWith' => $sharedWith,
'itemparent' => null,
'uidOwner' => 'sharedBy',
'fileSource' => 1,
@@ -248,18 +252,6 @@ class ManagerTest extends \Test\TestCase {
->setMethods(['getShareById'])
->getMock();
- $sharedBy1 = $this->getMock('\OCP\IUser');
- $sharedBy1->method('getUID')->willReturn('sharedBy1');
- $sharedBy2 = $this->getMock('\OCP\IUser');
- $sharedBy2->method('getUID')->willReturn('sharedBy2');
- $sharedBy3 = $this->getMock('\OCP\IUser');
- $sharedBy3->method('getUID')->willReturn('sharedBy3');
-
- $sharedWith1 = $this->getMock('\OCP\IUser');
- $sharedWith1->method('getUID')->willReturn('sharedWith1');
- $sharedWith2 = $this->getMock('\OCP\IGroup');
- $sharedWith2->method('getGID')->willReturn('sharedWith2');
-
$path = $this->getMock('\OCP\Files\File');
$path->method('getId')->willReturn(1);
@@ -267,8 +259,8 @@ class ManagerTest extends \Test\TestCase {
$share1->setId(42)
->setProviderId('prov')
->setShareType(\OCP\Share::SHARE_TYPE_USER)
- ->setSharedWith($sharedWith1)
- ->setSharedBy($sharedBy1)
+ ->setSharedWith('sharedWith1')
+ ->setSharedBy('sharedBy1')
->setNode($path)
->setTarget('myTarget1');
@@ -276,8 +268,8 @@ class ManagerTest extends \Test\TestCase {
$share2->setId(43)
->setProviderId('prov')
->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
- ->setSharedWith($sharedWith2)
- ->setSharedBy($sharedBy2)
+ ->setSharedWith('sharedWith2')
+ ->setSharedBy('sharedBy2')
->setNode($path)
->setTarget('myTarget2')
->setParent(42);
@@ -286,7 +278,7 @@ class ManagerTest extends \Test\TestCase {
$share3->setId(44)
->setProviderId('prov')
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
- ->setSharedBy($sharedBy3)
+ ->setSharedBy('sharedBy3')
->setNode($path)
->setTarget('myTarget3')
->setParent(43);
@@ -504,72 +496,72 @@ class ManagerTest extends \Test\TestCase {
}
public function dataGeneralChecks() {
- $user = $this->getMock('\OCP\IUser');
- $user2 = $this->getMock('\OCP\IUser');
- $group = $this->getMock('\OCP\IGroup');
+ $user0 = 'user0';
+ $user2 = 'user1';
+ $group0 = 'group0';
$file = $this->getMock('\OCP\Files\File');
$node = $this->getMock('\OCP\Files\Node');
$data = [
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, null, $user, $user, 31, null, null), 'SharedWith should be an IUser', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, $group, $user, $user, 31, null, null), 'SharedWith should be an IUser', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, 'foo@bar.com', $user, $user, 31, null, null), 'SharedWith should be an IUser', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, null, $user, $user, 31, null, null), 'SharedWith should be an IGroup', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, $user2, $user, $user, 31, null, null), 'SharedWith should be an IGroup', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, 'foo@bar.com', $user, $user, 31, null, null), 'SharedWith should be an IGroup', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, $user2, $user, $user, 31, null, null), 'SharedWith should be empty', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, $group, $user, $user, 31, null, null), 'SharedWith should be empty', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, 'foo@bar.com', $user, $user, 31, null, null), 'SharedWith should be empty', true],
- [$this->createShare(null, -1, $file, null, $user, $user, 31, null, null), 'unkown share type', true],
-
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, $user2, null, $user, 31, null, null), 'SharedBy should be set', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, $group, null, $user, 31, null, null), 'SharedBy should be set', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, null, null, $user, 31, null, null), 'SharedBy should be set', true],
-
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, $user, $user, $user, 31, null, null), 'Can\'t share with yourself', true],
-
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, null, $user2, $user, $user, 31, null, null), 'Path should be set', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, null, $group, $user, $user, 31, null, null), 'Path should be set', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, null, null, $user, $user, 31, null, null), 'Path should be set', true],
-
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $node, $user2, $user, $user, 31, null, null), 'Path should be either a file or a folder', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $node, $group, $user, $user, 31, null, null), 'Path should be either a file or a folder', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $node, null, $user, $user, 31, null, null), 'Path should be either a file or a folder', true],
+ [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, null, $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true],
+ [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, $group0, $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true],
+ [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true],
+ [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, null, $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true],
+ [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, $user2, $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true],
+ [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true],
+ [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, $user2, $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
+ [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, $group0, $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
+ [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
+ [$this->createShare(null, -1, $file, null, $user0, $user0, 31, null, null), 'unkown share type', true],
+
+ [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, $user2, null, $user0, 31, null, null), 'SharedBy should be set', true],
+ [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, $group0, null, $user0, 31, null, null), 'SharedBy should be set', true],
+ [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, null, null, $user0, 31, null, null), 'SharedBy should be set', true],
+
+ [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, $user0, $user0, $user0, 31, null, null), 'Can\'t share with yourself', true],
+
+ [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, null, $user2, $user0, $user0, 31, null, null), 'Path should be set', true],
+ [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, null, $group0, $user0, $user0, 31, null, null), 'Path should be set', true],
+ [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, null, null, $user0, $user0, 31, null, null), 'Path should be set', true],
+
+ [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $node, $user2, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true],
+ [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $node, $group0, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true],
+ [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $node, null, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true],
];
$nonShareAble = $this->getMock('\OCP\Files\Folder');
$nonShareAble->method('isShareable')->willReturn(false);
$nonShareAble->method('getPath')->willReturn('path');
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $nonShareAble, $user2, $user, $user, 31, null, null), 'You are not allowed to share path', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $nonShareAble, $group, $user, $user, 31, null, null), 'You are not allowed to share path', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $nonShareAble, null, $user, $user, 31, null, null), 'You are not allowed to share path', true];
+ $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $nonShareAble, $user2, $user0, $user0, 31, null, null), 'You are not allowed to share path', true];
+ $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $nonShareAble, $group0, $user0, $user0, 31, null, null), 'You are not allowed to share path', true];
+ $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $nonShareAble, null, $user0, $user0, 31, null, null), 'You are not allowed to share path', true];
$limitedPermssions = $this->getMock('\OCP\Files\File');
$limitedPermssions->method('isShareable')->willReturn(true);
$limitedPermssions->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_READ);
$limitedPermssions->method('getPath')->willReturn('path');
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $limitedPermssions, $user2, $user, $user, null, null, null), 'A share requires permissions', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $limitedPermssions, $group, $user, $user, null, null, null), 'A share requires permissions', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $limitedPermssions, null, $user, $user, null, null, null), 'A share requires permissions', true];
+ $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $limitedPermssions, $user2, $user0, $user0, null, null, null), 'A share requires permissions', true];
+ $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $limitedPermssions, $group0, $user0, $user0, null, null, null), 'A share requires permissions', true];
+ $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $limitedPermssions, null, $user0, $user0, null, null, null), 'A share requires permissions', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $limitedPermssions, $user2, $user, $user, 31, null, null), 'Cannot increase permissions of path', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $limitedPermssions, $group, $user, $user, 17, null, null), 'Cannot increase permissions of path', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $limitedPermssions, null, $user, $user, 3, null, null), 'Cannot increase permissions of path', true];
+ $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $limitedPermssions, $user2, $user0, $user0, 31, null, null), 'Cannot increase permissions of path', true];
+ $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $limitedPermssions, $group0, $user0, $user0, 17, null, null), 'Cannot increase permissions of path', true];
+ $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $limitedPermssions, null, $user0, $user0, 3, null, null), 'Cannot increase permissions of path', true];
$allPermssions = $this->getMock('\OCP\Files\Folder');
$allPermssions->method('isShareable')->willReturn(true);
$allPermssions->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_ALL);
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $allPermssions, $user2, $user, $user, 30, null, null), 'Shares need at least read permissions', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $allPermssions, $group, $user, $user, 2, null, null), 'Shares need at least read permissions', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $allPermssions, null, $user, $user, 16, null, null), 'Shares need at least read permissions', true];
+ $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $allPermssions, $user2, $user0, $user0, 30, null, null), 'Shares need at least read permissions', true];
+ $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $allPermssions, $group0, $user0, $user0, 2, null, null), 'Shares need at least read permissions', true];
+ $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $allPermssions, null, $user0, $user0, 16, null, null), 'Shares need at least read permissions', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $allPermssions, $user2, $user, $user, 31, null, null), null, false];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $allPermssions, $group, $user, $user, 3, null, null), null, false];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $allPermssions, null, $user, $user, 17, null, null), null, false];
+ $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $allPermssions, $user2, $user0, $user0, 31, null, null), null, false];
+ $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $allPermssions, $group0, $user0, $user0, 3, null, null), null, false];
+ $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $allPermssions, null, $user0, $user0, 17, null, null), null, false];
return $data;
}
@@ -583,6 +575,15 @@ class ManagerTest extends \Test\TestCase {
public function testGeneralChecks($share, $exceptionMessage, $exception) {
$thrown = null;
+ $this->userManager->method('userExists')->will($this->returnValueMap([
+ ['user0', true],
+ ['user1', true],
+ ]));
+
+ $this->groupManager->method('groupExists')->will($this->returnValueMap([
+ ['group0', true],
+ ]));
+
try {
$this->invokePrivate($this->manager, 'generalCreateChecks', [$share]);
$thrown = false;
@@ -795,7 +796,7 @@ class ManagerTest extends \Test\TestCase {
$sharedBy = $this->getMock('\OCP\IUser');
$sharedWith = $this->getMock('\OCP\IUser');
- $share->setSharedBy($sharedBy)->setSharedWith($sharedWith);
+ $share->setSharedBy('sharedBy')->setSharedWith('sharedWith');
$this->groupManager
->method('getUserGroupIds')
@@ -806,6 +807,11 @@ class ManagerTest extends \Test\TestCase {
])
);
+ $this->userManager->method('get')->will($this->returnValueMap([
+ ['sharedBy', $sharedBy],
+ ['sharedWith', $sharedWith],
+ ]));
+
$this->config
->method('getAppValue')
->will($this->returnValueMap([
@@ -820,7 +826,7 @@ class ManagerTest extends \Test\TestCase {
$sharedBy = $this->getMock('\OCP\IUser');
$sharedWith = $this->getMock('\OCP\IUser');
- $share->setSharedBy($sharedBy)->setSharedWith($sharedWith);
+ $share->setSharedBy('sharedBy')->setSharedWith('sharedWith');
$path = $this->getMock('\OCP\Files\Node');
$share->setNode($path);
@@ -834,6 +840,11 @@ class ManagerTest extends \Test\TestCase {
])
);
+ $this->userManager->method('get')->will($this->returnValueMap([
+ ['sharedBy', $sharedBy],
+ ['sharedWith', $sharedWith],
+ ]));
+
$this->config
->method('getAppValue')
->will($this->returnValueMap([
@@ -859,10 +870,10 @@ class ManagerTest extends \Test\TestCase {
$sharedWith = $this->getMock('\OCP\IUser');
$path = $this->getMock('\OCP\Files\Node');
- $share->setSharedWith($sharedWith)->setNode($path)
+ $share->setSharedWith('sharedWith')->setNode($path)
->setProviderId('foo')->setId('bar');
- $share2->setSharedWith($sharedWith)->setNode($path)
+ $share2->setSharedWith('sharedWith')->setNode($path)
->setProviderId('foo')->setId('baz');
$this->defaultProvider
@@ -881,28 +892,32 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$sharedWith = $this->getMock('\OCP\IUser');
- $owner = $this->getMock('\OCP\IUser');
+ $sharedWith->method('getUID')->willReturn('sharedWith');
+
+ $this->userManager->method('get')->with('sharedWith')->willReturn($sharedWith);
+
$path = $this->getMock('\OCP\Files\Node');
- $share->setSharedWith($sharedWith)
+ $share->setSharedWith('sharedWith')
->setNode($path)
- ->setShareOwner($owner)
+ ->setShareOwner('shareOwner')
->setProviderId('foo')
->setId('bar');
$share2 = new \OC\Share20\Share();
$owner2 = $this->getMock('\OCP\IUser');
$share2->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
- ->setShareOwner($owner2)
+ ->setShareOwner('shareOwner2')
->setProviderId('foo')
- ->setId('baz');
+ ->setId('baz')
+ ->setSharedWith('group');
$group = $this->getMock('\OCP\IGroup');
$group->method('inGroup')
->with($sharedWith)
->willReturn(true);
- $share2->setSharedWith($group);
+ $this->groupManager->method('get')->with('group')->willReturn($group);
$this->defaultProvider
->method('getSharesByPath')
@@ -915,18 +930,18 @@ class ManagerTest extends \Test\TestCase {
public function testUserCreateChecksIdenticalPathNotSharedWithUser() {
$share = new \OC\Share20\Share();
$sharedWith = $this->getMock('\OCP\IUser');
- $owner = $this->getMock('\OCP\IUser');
$path = $this->getMock('\OCP\Files\Node');
- $share->setSharedWith($sharedWith)
+ $share->setSharedWith('sharedWith')
->setNode($path)
- ->setShareOwner($owner)
+ ->setShareOwner('shareOwner')
->setProviderId('foo')
->setId('bar');
+ $this->userManager->method('get')->with('sharedWith')->willReturn($sharedWith);
+
$share2 = new \OC\Share20\Share();
- $owner2 = $this->getMock('\OCP\IUser');
$share2->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
- ->setShareOwner($owner2)
+ ->setShareOwner('shareOwner2')
->setProviderId('foo')
->setId('baz');
@@ -935,7 +950,9 @@ class ManagerTest extends \Test\TestCase {
->with($sharedWith)
->willReturn(false);
- $share2->setSharedWith($group);
+ $this->groupManager->method('get')->with('group')->willReturn($group);
+
+ $share2->setSharedWith('group');
$this->defaultProvider
->method('getSharesByPath')
@@ -952,11 +969,14 @@ class ManagerTest extends \Test\TestCase {
public function testGroupCreateChecksShareWithGroupMembersOnlyNotInGroup() {
$share = new \OC\Share20\Share();
- $sharedBy = $this->getMock('\OCP\IUser');
- $sharedWith = $this->getMock('\OCP\IGroup');
- $share->setSharedBy($sharedBy)->setSharedWith($sharedWith);
+ $user = $this->getMock('\OCP\IUser');
+ $group = $this->getMock('\OCP\IGroup');
+ $share->setSharedBy('user')->setSharedWith('group');
- $sharedWith->method('inGroup')->with($sharedBy)->willReturn(false);
+ $group->method('inGroup')->with($user)->willReturn(false);
+
+ $this->groupManager->method('get')->with('group')->willReturn($group);
+ $this->userManager->method('get')->with('user')->willReturn($user);
$this->config
->method('getAppValue')
@@ -970,11 +990,14 @@ class ManagerTest extends \Test\TestCase {
public function testGroupCreateChecksShareWithGroupMembersOnlyInGroup() {
$share = new \OC\Share20\Share();
- $sharedBy = $this->getMock('\OCP\IUser');
- $sharedWith = $this->getMock('\OCP\IGroup');
- $share->setSharedBy($sharedBy)->setSharedWith($sharedWith);
+ $user = $this->getMock('\OCP\IUser');
+ $group = $this->getMock('\OCP\IGroup');
+ $share->setSharedBy('user')->setSharedWith('group');
- $sharedWith->method('inGroup')->with($sharedBy)->willReturn(true);
+ $this->userManager->method('get')->with('user')->willReturn($user);
+ $this->groupManager->method('get')->with('group')->willReturn($group);
+
+ $group->method('inGroup')->with($user)->willReturn(true);
$path = $this->getMock('\OCP\Files\Node');
$share->setNode($path);
@@ -999,15 +1022,14 @@ class ManagerTest extends \Test\TestCase {
public function testGroupCreateChecksPathAlreadySharedWithSameGroup() {
$share = $this->manager->newShare();
- $sharedWith = $this->getMock('\OCP\IGroup');
$path = $this->getMock('\OCP\Files\Node');
- $share->setSharedWith($sharedWith)
+ $share->setSharedWith('sharedWith')
->setNode($path)
->setProviderId('foo')
->setId('bar');
$share2 = new \OC\Share20\Share();
- $share2->setSharedWith($sharedWith)
+ $share2->setSharedWith('sharedWith')
->setProviderId('foo')
->setId('baz');
@@ -1021,15 +1043,13 @@ class ManagerTest extends \Test\TestCase {
public function testGroupCreateChecksPathAlreadySharedWithDifferentGroup() {
$share = new \OC\Share20\Share();
- $sharedWith = $this->getMock('\OCP\IGroup');
- $share->setSharedWith($sharedWith);
+ $share->setSharedWith('sharedWith');
$path = $this->getMock('\OCP\Files\Node');
$share->setNode($path);
$share2 = new \OC\Share20\Share();
- $sharedWith2 = $this->getMock('\OCP\IGroup');
- $share2->setSharedWith($sharedWith2);
+ $share2->setSharedWith('sharedWith2');
$this->defaultProvider->method('getSharesByPath')
->with($path)
@@ -1238,7 +1258,9 @@ class ManagerTest extends \Test\TestCase {
->with($user)
->willReturn($groupIds);
- $res = $this->manager->sharingDisabledForUser($user);
+ $this->userManager->method('get')->with('user')->willReturn($user);
+
+ $res = $this->manager->sharingDisabledForUser('user');
$this->assertEquals($expected, $res);
}
@@ -1278,7 +1300,7 @@ class ManagerTest extends \Test\TestCase {
$user = $this->getMock('\OCP\IUser');
$share = $this->manager->newShare();
- $share->setSharedBy($user);
+ $share->setSharedBy('user');
$res = $this->invokePrivate($manager, 'canShare', [$share]);
$this->assertEquals($expected, $res);
@@ -1303,9 +1325,8 @@ class ManagerTest extends \Test\TestCase {
->setMethods(['canShare', 'generalCreateChecks', 'userCreateChecks', 'pathCreateChecks'])
->getMock();
- $sharedWith = $this->getMock('\OCP\IUser');
- $sharedBy = $this->getMock('\OCP\IUser');
$shareOwner = $this->getMock('\OCP\IUser');
+ $shareOwner->method('getUID')->willReturn('shareOwner');
$path = $this->getMock('\OCP\Files\File');
$path->method('getOwner')->willReturn($shareOwner);
@@ -1315,8 +1336,8 @@ class ManagerTest extends \Test\TestCase {
null,
\OCP\Share::SHARE_TYPE_USER,
$path,
- $sharedWith,
- $sharedBy,
+ 'sharedWith',
+ 'sharedBy',
null,
\OCP\Constants::PERMISSION_ALL);
@@ -1342,7 +1363,7 @@ class ManagerTest extends \Test\TestCase {
$share->expects($this->once())
->method('setShareOwner')
- ->with($shareOwner);
+ ->with('shareOwner');
$share->expects($this->once())
->method('setTarget')
->with('/target');
@@ -1355,9 +1376,8 @@ class ManagerTest extends \Test\TestCase {
->setMethods(['canShare', 'generalCreateChecks', 'groupCreateChecks', 'pathCreateChecks'])
->getMock();
- $sharedWith = $this->getMock('\OCP\IGroup');
- $sharedBy = $this->getMock('\OCP\IUser');
$shareOwner = $this->getMock('\OCP\IUser');
+ $shareOwner->method('getUID')->willReturn('shareOwner');
$path = $this->getMock('\OCP\Files\File');
$path->method('getOwner')->willReturn($shareOwner);
@@ -1367,8 +1387,8 @@ class ManagerTest extends \Test\TestCase {
null,
\OCP\Share::SHARE_TYPE_GROUP,
$path,
- $sharedWith,
- $sharedBy,
+ 'sharedWith',
+ 'sharedBy',
null,
\OCP\Constants::PERMISSION_ALL);
@@ -1394,7 +1414,7 @@ class ManagerTest extends \Test\TestCase {
$share->expects($this->once())
->method('setShareOwner')
- ->with($shareOwner);
+ ->with('shareOwner');
$share->expects($this->once())
->method('setTarget')
->with('/target');
@@ -1414,9 +1434,8 @@ class ManagerTest extends \Test\TestCase {
])
->getMock();
- $sharedBy = $this->getMock('\OCP\IUser');
- $sharedBy->method('getUID')->willReturn('sharedBy');
$shareOwner = $this->getMock('\OCP\IUser');
+ $shareOwner->method('getUID')->willReturn('shareOwner');
$path = $this->getMock('\OCP\Files\File');
$path->method('getOwner')->willReturn($shareOwner);
@@ -1428,7 +1447,7 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setNode($path)
- ->setSharedBy($sharedBy)
+ ->setSharedBy('sharedBy')
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setExpirationDate($date)
->setPassword('password');
@@ -1515,7 +1534,7 @@ class ManagerTest extends \Test\TestCase {
/** @var IShare $share */
$share = $manager->createShare($share);
- $this->assertSame($shareOwner, $share->getShareOwner());
+ $this->assertSame('shareOwner', $share->getShareOwner());
$this->assertEquals('/target', $share->getTarget());
$this->assertSame($date, $share->getExpirationDate());
$this->assertEquals('token', $share->getToken());
@@ -1536,9 +1555,8 @@ class ManagerTest extends \Test\TestCase {
])
->getMock();
- $sharedWith = $this->getMock('\OCP\IUser');
- $sharedBy = $this->getMock('\OCP\IUser');
$shareOwner = $this->getMock('\OCP\IUser');
+ $shareOwner->method('getUID')->willReturn('shareOwner');
$path = $this->getMock('\OCP\Files\File');
$path->method('getOwner')->willReturn($shareOwner);
@@ -1548,8 +1566,8 @@ class ManagerTest extends \Test\TestCase {
null,
\OCP\Share::SHARE_TYPE_USER,
$path,
- $sharedWith,
- $sharedBy,
+ 'sharedWith',
+ 'sharedBy',
null,
\OCP\Constants::PERMISSION_ALL);
@@ -1569,7 +1587,7 @@ class ManagerTest extends \Test\TestCase {
$share->expects($this->once())
->method('setShareOwner')
- ->with($shareOwner);
+ ->with('shareOwner');
$share->expects($this->once())
->method('setTarget')
->with('/target');
@@ -1591,7 +1609,8 @@ class ManagerTest extends \Test\TestCase {
$this->mountManager,
$this->groupManager,
$this->l,
- $factory
+ $factory,
+ $this->userManager
);
$share = $this->getMock('\OCP\Share\IShare');
@@ -1718,12 +1737,9 @@ class ManagerTest extends \Test\TestCase {
])
->getMock();
- $origGroup = $this->getMock('\OCP\IGroup');
- $newGroup = $this->getMock('\OCP\IGroup');
-
$originalShare = new \OC\Share20\Share();
$originalShare->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
- ->setSharedWith($origGroup);
+ ->setSharedWith('origGroup');
$manager->expects($this->once())->method('canShare')->willReturn(true);
$manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare);
@@ -1732,7 +1748,7 @@ class ManagerTest extends \Test\TestCase {
$share->setProviderId('foo')
->setId('42')
->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
- ->setSharedWith($newGroup);
+ ->setSharedWith('newGroup');
$manager->updateShare($share);
}
@@ -1749,12 +1765,9 @@ class ManagerTest extends \Test\TestCase {
])
->getMock();
- $origUser = $this->getMock('\OCP\IUser');
- $newUser = $this->getMock('\OCP\IUser');
-
$originalShare = new \OC\Share20\Share();
$originalShare->setShareType(\OCP\Share::SHARE_TYPE_USER)
- ->setSharedWith($origUser);
+ ->setSharedWith('sharedWith');
$manager->expects($this->once())->method('canShare')->willReturn(true);
$manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare);
@@ -1763,8 +1776,8 @@ class ManagerTest extends \Test\TestCase {
$share->setProviderId('foo')
->setId('42')
->setShareType(\OCP\Share::SHARE_TYPE_USER)
- ->setSharedWith($newUser)
- ->setShareOwner($newUser);
+ ->setSharedWith('newUser')
+ ->setShareOwner('newUser');
$manager->updateShare($share);
}
@@ -1780,12 +1793,9 @@ class ManagerTest extends \Test\TestCase {
])
->getMock();
- $origUser = $this->getMock('\OCP\IUser');
- $newUser = $this->getMock('\OCP\IUser');
-
$originalShare = new \OC\Share20\Share();
$originalShare->setShareType(\OCP\Share::SHARE_TYPE_USER)
- ->setSharedWith($origUser);
+ ->setSharedWith('origUser');
$manager->expects($this->once())->method('canShare')->willReturn(true);
$manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare);
@@ -1794,8 +1804,8 @@ class ManagerTest extends \Test\TestCase {
$share->setProviderId('foo')
->setId('42')
->setShareType(\OCP\Share::SHARE_TYPE_USER)
- ->setSharedWith($origUser)
- ->setShareOwner($newUser);
+ ->setSharedWith('origUser')
+ ->setShareOwner('newUser');
$this->defaultProvider->expects($this->once())
->method('update')
@@ -1821,12 +1831,9 @@ class ManagerTest extends \Test\TestCase {
])
->getMock();
- $origGroup = $this->getMock('\OCP\IGroup');
- $user = $this->getMock('\OCP\IUser');
-
$originalShare = new \OC\Share20\Share();
$originalShare->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
- ->setSharedWith($origGroup);
+ ->setSharedWith('origUser');
$manager->expects($this->once())->method('canShare')->willReturn(true);
$manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare);
@@ -1835,8 +1842,8 @@ class ManagerTest extends \Test\TestCase {
$share->setProviderId('foo')
->setId('42')
->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
- ->setSharedWith($origGroup)
- ->setShareOwner($user);
+ ->setSharedWith('origUser')
+ ->setShareOwner('owner');
$this->defaultProvider->expects($this->once())
->method('update')
@@ -1864,9 +1871,6 @@ class ManagerTest extends \Test\TestCase {
])
->getMock();
- $user = $this->getMock('\OCP\IUser');
- $user->method('getUID')->willReturn('owner');
-
$originalShare = new \OC\Share20\Share();
$originalShare->setShareType(\OCP\Share::SHARE_TYPE_LINK);
@@ -1881,8 +1885,8 @@ class ManagerTest extends \Test\TestCase {
$share->setProviderId('foo')
->setId('42')
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
- ->setSharedBy($user)
- ->setShareOwner($user)
+ ->setSharedBy('owner')
+ ->setShareOwner('owner')
->setPassword('password')
->setExpirationDate($tomorrow)
->setNode($file);
@@ -1930,24 +1934,20 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setShareType(\OCP\Share::SHARE_TYPE_USER);
- $sharedWith = $this->getMock('\OCP\IUser');
- $share->setSharedWith($sharedWith);
-
- $recipient = $this->getMock('\OCP\IUser');
+ $share->setSharedWith('sharedWith');
- $this->manager->moveShare($share, $recipient);
+ $this->manager->moveShare($share, 'recipient');
}
public function testMoveShareUser() {
$share = $this->manager->newShare();
$share->setShareType(\OCP\Share::SHARE_TYPE_USER);
- $recipient = $this->getMock('\OCP\IUser');
- $share->setSharedWith($recipient);
+ $share->setSharedWith('recipient');
- $this->defaultProvider->method('move')->with($share, $recipient)->will($this->returnArgument(0));
+ $this->defaultProvider->method('move')->with($share, 'recipient')->will($this->returnArgument(0));
- $this->manager->moveShare($share, $recipient);
+ $this->manager->moveShare($share, 'recipient');
}
/**
@@ -1959,27 +1959,33 @@ class ManagerTest extends \Test\TestCase {
$share->setShareType(\OCP\Share::SHARE_TYPE_GROUP);
$sharedWith = $this->getMock('\OCP\IGroup');
- $share->setSharedWith($sharedWith);
+ $share->setSharedWith('shareWith');
$recipient = $this->getMock('\OCP\IUser');
$sharedWith->method('inGroup')->with($recipient)->willReturn(false);
- $this->manager->moveShare($share, $recipient);
+ $this->groupManager->method('get')->with('shareWith')->willReturn($sharedWith);
+ $this->userManager->method('get')->with('recipient')->willReturn($recipient);
+
+ $this->manager->moveShare($share, 'recipient');
}
public function testMoveShareGroup() {
$share = $this->manager->newShare();
$share->setShareType(\OCP\Share::SHARE_TYPE_GROUP);
- $sharedWith = $this->getMock('\OCP\IGroup');
- $share->setSharedWith($sharedWith);
+ $group = $this->getMock('\OCP\IGroup');
+ $share->setSharedWith('group');
$recipient = $this->getMock('\OCP\IUser');
- $sharedWith->method('inGroup')->with($recipient)->willReturn(true);
+ $group->method('inGroup')->with($recipient)->willReturn(true);
- $this->defaultProvider->method('move')->with($share, $recipient)->will($this->returnArgument(0));
+ $this->groupManager->method('get')->with('group')->willReturn($group);
+ $this->userManager->method('get')->with('recipient')->willReturn($recipient);
- $this->manager->moveShare($share, $recipient);
+ $this->defaultProvider->method('move')->with($share, 'recipient')->will($this->returnArgument(0));
+
+ $this->manager->moveShare($share, 'recipient');
}
}