aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-05-13 11:07:21 +0200
committerVincent Petry <pvince81@owncloud.com>2016-05-20 17:56:02 +0200
commit5963128342cc6ae386a1a59d81784d0fb4a88fd4 (patch)
tree3d15bde33fd6f4f04671a9d44695db6a2f8dc53e /apps/dav/lib
parent91d4249ed87cc04af1f264d3271566b62fe69657 (diff)
downloadnextcloud-server-5963128342cc6ae386a1a59d81784d0fb4a88fd4.tar.gz
nextcloud-server-5963128342cc6ae386a1a59d81784d0fb4a88fd4.zip
Adjust DAV SystemTagPlugin unit tests for groups
Diffstat (limited to 'apps/dav/lib')
-rw-r--r--apps/dav/lib/SystemTag/SystemTagPlugin.php41
1 files changed, 25 insertions, 16 deletions
diff --git a/apps/dav/lib/SystemTag/SystemTagPlugin.php b/apps/dav/lib/SystemTag/SystemTagPlugin.php
index fa6010a5bf5..af683954b87 100644
--- a/apps/dav/lib/SystemTag/SystemTagPlugin.php
+++ b/apps/dav/lib/SystemTag/SystemTagPlugin.php
@@ -24,12 +24,13 @@ namespace OCA\DAV\SystemTag;
use OCP\IGroupManager;
use OCP\IUserSession;
-use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\PropFind;
use Sabre\DAV\PropPatch;
use Sabre\DAV\Exception\BadRequest;
-use Sabre\DAV\Exception\UnsupportedMediaType;
use Sabre\DAV\Exception\Conflict;
+use Sabre\DAV\Exception\Forbidden;
+use Sabre\DAV\Exception\NotFound;
+use Sabre\DAV\Exception\UnsupportedMediaType;
use OCP\SystemTag\ISystemTag;
use OCP\SystemTag\ISystemTagManager;
@@ -246,16 +247,18 @@ class SystemTagPlugin extends \Sabre\DAV\ServerPlugin {
return $this->tagManager->canUserAssignTag($node->getSystemTag(), $this->userSession->getUser()) ? 'true' : 'false';
});
- if ($this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
- $propFind->handle(self::GROUPS_PROPERTYNAME, function() use ($node) {
- $groups = [];
- // no need to retrieve groups for namespaces that don't qualify
- if ($node->getSystemTag()->isUserVisible() && !$node->getSystemTag()->isUserAssignable()) {
- $groups = $this->tagManager->getTagGroups($node->getSystemTag());
- }
- return implode('|', $groups);
- });
- }
+ $propFind->handle(self::GROUPS_PROPERTYNAME, function() use ($node) {
+ if (!$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
+ // property only available for admins
+ throw new Forbidden();
+ }
+ $groups = [];
+ // no need to retrieve groups for namespaces that don't qualify
+ if ($node->getSystemTag()->isUserVisible() && !$node->getSystemTag()->isUserAssignable()) {
+ $groups = $this->tagManager->getTagGroups($node->getSystemTag());
+ }
+ return implode('|', $groups);
+ });
}
/**
@@ -302,15 +305,21 @@ class SystemTagPlugin extends \Sabre\DAV\ServerPlugin {
$updateTag = true;
}
- if ($updateTag) {
- $node->update($name, $userVisible, $userAssignable);
- }
-
if (isset($props[self::GROUPS_PROPERTYNAME])) {
+ if (!$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
+ // property only available for admins
+ throw new Forbidden();
+ }
+
$propValue = $props[self::GROUPS_PROPERTYNAME];
$groupIds = explode('|', $propValue);
$this->tagManager->setTagGroups($tag, $groupIds);
}
+
+ if ($updateTag) {
+ $node->update($name, $userVisible, $userAssignable);
+ }
+
return true;
});