diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-11 17:05:20 +0300 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-11 17:05:20 +0300 |
commit | b752a08d639ce4006e4259cc3cf81ae91927e34b (patch) | |
tree | 24c19a345dee7aa48ec7b8c2c4fedd07320c49a9 /apps | |
parent | e3de44ea5192d29a43fffc23c83b58b750a5e85a (diff) | |
parent | e89f27e191c363ddd608a4b29e5cd9e683d48715 (diff) |
Merge pull request #23127 from owncloud/fix-getOwner-on-fileshome-stable9
getOwner is not available on FileHome - fixes #23116
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/lib/connector/sabre/filesplugin.php | 20 | ||||
-rw-r--r-- | apps/dav/lib/files/fileshome.php | 5 | ||||
-rw-r--r-- | apps/dav/tests/unit/connector/sabre/filesplugin.php | 52 |
3 files changed, 65 insertions, 12 deletions
diff --git a/apps/dav/lib/connector/sabre/filesplugin.php b/apps/dav/lib/connector/sabre/filesplugin.php index 4b05922adfd..e973b4e8682 100644 --- a/apps/dav/lib/connector/sabre/filesplugin.php +++ b/apps/dav/lib/connector/sabre/filesplugin.php @@ -235,6 +235,16 @@ class FilesPlugin extends \Sabre\DAV\ServerPlugin { $propFind->handle(self::GETETAG_PROPERTYNAME, function() use ($node) { return $node->getEtag(); }); + + $propFind->handle(self::OWNER_ID_PROPERTYNAME, function() use ($node) { + $owner = $node->getOwner(); + return $owner->getUID(); + }); + $propFind->handle(self::OWNER_DISPLAY_NAME_PROPERTYNAME, function() use ($node) { + $owner = $node->getOwner(); + $displayName = $owner->getDisplayName(); + return $displayName; + }); } if ($node instanceof \OCA\DAV\Connector\Sabre\File) { @@ -267,16 +277,6 @@ class FilesPlugin extends \Sabre\DAV\ServerPlugin { return $node->getSize(); }); } - - $propFind->handle(self::OWNER_ID_PROPERTYNAME, function() use ($node) { - $owner = $node->getOwner(); - return $owner->getUID(); - }); - $propFind->handle(self::OWNER_DISPLAY_NAME_PROPERTYNAME, function() use ($node) { - $owner = $node->getOwner(); - $displayName = $owner->getDisplayName(); - return $displayName; - }); } /** diff --git a/apps/dav/lib/files/fileshome.php b/apps/dav/lib/files/fileshome.php index d56b95881c3..ef572d6618b 100644 --- a/apps/dav/lib/files/fileshome.php +++ b/apps/dav/lib/files/fileshome.php @@ -29,6 +29,11 @@ use Sabre\HTTP\URLUtil; class FilesHome implements ICollection { /** + * @var array + */ + private $principalInfo; + + /** * FilesHome constructor. * * @param array $principalInfo diff --git a/apps/dav/tests/unit/connector/sabre/filesplugin.php b/apps/dav/tests/unit/connector/sabre/filesplugin.php index c363ece374a..0a790ec6fc9 100644 --- a/apps/dav/tests/unit/connector/sabre/filesplugin.php +++ b/apps/dav/tests/unit/connector/sabre/filesplugin.php @@ -109,8 +109,6 @@ class FilesPlugin extends \Test\TestCase { return $node; } - /** - */ public function testGetPropertiesForFile() { $node = $this->createTestNode('\OCA\DAV\Connector\Sabre\File'); @@ -165,6 +163,56 @@ class FilesPlugin extends \Test\TestCase { $this->assertEquals(array(self::SIZE_PROPERTYNAME), $propFind->get404Properties()); } + public function testGetPropertiesForFileHome() { + $node = $this->createTestNode('\OCA\DAV\Files\FilesHome'); + + $propFind = new \Sabre\DAV\PropFind( + '/dummyPath', + array( + self::GETETAG_PROPERTYNAME, + self::FILEID_PROPERTYNAME, + self::INTERNAL_FILEID_PROPERTYNAME, + self::SIZE_PROPERTYNAME, + self::PERMISSIONS_PROPERTYNAME, + self::DOWNLOADURL_PROPERTYNAME, + self::OWNER_ID_PROPERTYNAME, + self::OWNER_DISPLAY_NAME_PROPERTYNAME + ), + 0 + ); + + $user = $this->getMockBuilder('\OC\User\User') + ->disableOriginalConstructor()->getMock(); + $user->expects($this->never())->method('getUID'); + $user->expects($this->never())->method('getDisplayName'); + $node->expects($this->never())->method('getDirectDownload'); + $node->expects($this->never())->method('getOwner'); + $node->expects($this->never())->method('getSize'); + + $this->plugin->handleGetProperties( + $propFind, + $node + ); + + $this->assertEquals(null, $propFind->get(self::GETETAG_PROPERTYNAME)); + $this->assertEquals(null, $propFind->get(self::FILEID_PROPERTYNAME)); + $this->assertEquals(null, $propFind->get(self::INTERNAL_FILEID_PROPERTYNAME)); + $this->assertEquals(null, $propFind->get(self::SIZE_PROPERTYNAME)); + $this->assertEquals(null, $propFind->get(self::PERMISSIONS_PROPERTYNAME)); + $this->assertEquals(null, $propFind->get(self::DOWNLOADURL_PROPERTYNAME)); + $this->assertEquals(null, $propFind->get(self::OWNER_ID_PROPERTYNAME)); + $this->assertEquals(null, $propFind->get(self::OWNER_DISPLAY_NAME_PROPERTYNAME)); + $this->assertEquals(['{DAV:}getetag', + '{http://owncloud.org/ns}id', + '{http://owncloud.org/ns}fileid', + '{http://owncloud.org/ns}size', + '{http://owncloud.org/ns}permissions', + '{http://owncloud.org/ns}downloadURL', + '{http://owncloud.org/ns}owner-id', + '{http://owncloud.org/ns}owner-display-name' + ], $propFind->get404Properties()); + } + public function testGetPropertiesStorageNotAvailable() { $node = $this->createTestNode('\OCA\DAV\Connector\Sabre\File'); |