summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2018-11-02 14:54:46 +0100
committerGitHub <noreply@github.com>2018-11-02 14:54:46 +0100
commit30a1237f8115683fc375395d842f3f4fc555b1e0 (patch)
tree5ed2518c0d581fa565b6f286bc2350a69e614891 /apps
parent337cd251872371f064968cdd8731929124ac4fb3 (diff)
parentf57b07e2c2c6a2ff7cc027eeeeab6ab8da123ad5 (diff)
downloadnextcloud-server-30a1237f8115683fc375395d842f3f4fc555b1e0.tar.gz
nextcloud-server-30a1237f8115683fc375395d842f3f4fc555b1e0.zip
Merge pull request #11875 from nextcloud/add-support-for-sending-the-password-for-a-link-share-by-nextcloud-talk
Add support for sending the password for a link share by Nextcloud Talk
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php20
-rw-r--r--apps/files_sharing/tests/Controller/ShareAPIControllerTest.php373
2 files changed, 379 insertions, 14 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index 61fad5d2b14..42d0218de8c 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -212,6 +212,8 @@ class ShareAPIController extends OCSController {
$result['share_with'] = $share->getPassword();
$result['share_with_displayname'] = $share->getPassword();
+ $result['send_password_by_talk'] = $share->getSendPasswordByTalk();
+
$result['token'] = $share->getToken();
$result['url'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.showShare', ['token' => $share->getToken()]);
@@ -477,10 +479,19 @@ class ShareAPIController extends OCSController {
$share->setPassword($password);
}
+
if (!empty($label)) {
$share->setLabel($label);
}
+ if ($sendPasswordByTalk === 'true') {
+ if (!$this->appManager->isEnabledForUser('spreed')) {
+ throw new OCSForbiddenException($this->l->t('Sharing %s sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled', [$path->getPath()]));
+ }
+
+ $share->setSendPasswordByTalk(true);
+ }
+
//Expire date
if ($expireDate !== '') {
try {
@@ -873,6 +884,15 @@ class ShareAPIController extends OCSController {
$share->setLabel($label);
}
+ if ($sendPasswordByTalk === 'true') {
+ if (!$this->appManager->isEnabledForUser('spreed')) {
+ throw new OCSForbiddenException($this->l->t('Sharing sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled'));
+ }
+
+ $share->setSendPasswordByTalk(true);
+ } else if ($sendPasswordByTalk !== null) {
+ $share->setSendPasswordByTalk(false);
+ }
} else {
if ($permissions !== null) {
$permissions = (int)$permissions;
diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
index eb39dd7926f..efc252d49d7 100644
--- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
@@ -430,6 +430,7 @@ class ShareAPIControllerTest extends TestCase {
'share_type' => \OCP\Share::SHARE_TYPE_LINK,
'share_with' => 'password',
'share_with_displayname' => 'password',
+ 'send_password_by_talk' => false,
'uid_owner' => 'initiatorId',
'displayname_owner' => 'initiatorDisplay',
'item_type' => 'folder',
@@ -1135,6 +1136,71 @@ class ShareAPIControllerTest extends TestCase {
$this->assertEquals($expected->getData(), $result->getData());
}
+ public function testCreateShareLinkSendPasswordByTalk() {
+ $ocs = $this->mockFormatShare();
+
+ $path = $this->getMockBuilder(Folder::class)->getMock();
+ $storage = $this->getMockBuilder(Storage::class)->getMock();
+ $storage->method('instanceOfStorage')
+ ->with('OCA\Files_Sharing\External\Storage')
+ ->willReturn(false);
+ $path->method('getStorage')->willReturn($storage);
+ $this->rootFolder->method('getUserFolder')->with($this->currentUser)->will($this->returnSelf());
+ $this->rootFolder->method('get')->with('valid-path')->willReturn($path);
+
+ $this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
+ $this->shareManager->method('shareApiAllowLinks')->willReturn(true);
+ $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
+
+ $this->appManager->method('isEnabledForUser')->with('spreed')->willReturn(true);
+
+ $this->shareManager->expects($this->once())->method('createShare')->with(
+ $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->getPassword() === 'password' &&
+ $share->getSendPasswordByTalk() === true &&
+ $share->getExpirationDate() === null;
+ })
+ )->will($this->returnArgument(0));
+
+ $expected = new DataResponse([]);
+ $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', 'password', 'true', '');
+
+ $this->assertInstanceOf(get_class($expected), $result);
+ $this->assertEquals($expected->getData(), $result->getData());
+ }
+
+ /**
+ * @expectedException \OCP\AppFramework\OCS\OCSForbiddenException
+ * @expectedExceptionMessage Sharing valid-path sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled
+ */
+ public function testCreateShareLinkSendPasswordByTalkWithTalkDisabled() {
+ $ocs = $this->mockFormatShare();
+
+ $path = $this->getMockBuilder(Folder::class)->getMock();
+ $storage = $this->getMockBuilder(Storage::class)->getMock();
+ $storage->method('instanceOfStorage')
+ ->with('OCA\Files_Sharing\External\Storage')
+ ->willReturn(false);
+ $path->method('getStorage')->willReturn($storage);
+ $path->method('getPath')->willReturn('valid-path');
+ $this->rootFolder->method('getUserFolder')->with($this->currentUser)->will($this->returnSelf());
+ $this->rootFolder->method('get')->with('valid-path')->willReturn($path);
+
+ $this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
+ $this->shareManager->method('shareApiAllowLinks')->willReturn(true);
+ $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
+
+ $this->appManager->method('isEnabledForUser')->with('spreed')->willReturn(false);
+
+ $this->shareManager->expects($this->never())->method('createShare');
+
+ $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', 'password', 'true', '');
+ }
+
public function testCreateShareValidExpireDate() {
$ocs = $this->mockFormatShare();
@@ -1512,6 +1578,9 @@ class ShareAPIControllerTest extends TestCase {
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setPassword('password')
->setExpirationDate(new \DateTime())
+ ->setNote('note')
+ ->setLabel('label')
+ ->setHideDownload(true)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setNode($node);
@@ -1525,7 +1594,12 @@ class ShareAPIControllerTest extends TestCase {
$this->callback(function (\OCP\Share\IShare $share) {
return $share->getPermissions() === \OCP\Constants::PERMISSION_READ &&
$share->getPassword() === null &&
- $share->getExpirationDate() === null;
+ $share->getExpirationDate() === null &&
+ // Once set a note or a label are never back to null, only to an
+ // empty string.
+ $share->getNote() === '' &&
+ $share->getLabel() === '' &&
+ $share->getHideDownload() === false;
})
)->will($this->returnArgument(0));
@@ -1533,7 +1607,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn([]);
$expected = new DataResponse([]);
- $result = $ocs->updateShare(42, null, '', null, 'false', '');
+ $result = $ocs->updateShare(42, null, '', null, 'false', '', '', '', 'false');
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
@@ -1560,7 +1634,10 @@ class ShareAPIControllerTest extends TestCase {
return $share->getPermissions() === (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE) &&
$share->getPassword() === 'password' &&
- $share->getExpirationDate() == $date;
+ $share->getExpirationDate() == $date &&
+ $share->getNote() === 'note' &&
+ $share->getLabel() === 'label' &&
+ $share->getHideDownload() === true;
})
)->will($this->returnArgument(0));
@@ -1568,7 +1645,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn([]);
$expected = new DataResponse([]);
- $result = $ocs->updateShare(42, null, 'password', null, 'true', '2000-01-01');
+ $result = $ocs->updateShare(42, null, 'password', null, 'true', '2000-01-01', 'note', 'label', 'true');
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
@@ -1700,7 +1777,11 @@ class ShareAPIControllerTest extends TestCase {
->setSharedBy($this->currentUser)
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setPassword('password')
+ ->setSendPasswordByTalk(true)
->setExpirationDate($date)
+ ->setNote('note')
+ ->setLabel('label')
+ ->setHideDownload(true)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setNode($node);
@@ -1714,12 +1795,194 @@ class ShareAPIControllerTest extends TestCase {
$this->callback(function (\OCP\Share\IShare $share) use ($date) {
return $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
$share->getPassword() === 'newpassword' &&
- $share->getExpirationDate() === $date;
+ $share->getSendPasswordByTalk() === true &&
+ $share->getExpirationDate() === $date &&
+ $share->getNote() === 'note' &&
+ $share->getLabel() === 'label' &&
+ $share->getHideDownload() === true;
+ })
+ )->will($this->returnArgument(0));
+
+ $expected = new DataResponse([]);
+ $result = $ocs->updateShare(42, null, 'newpassword', null, null, null, null, null, null);
+
+ $this->assertInstanceOf(get_class($expected), $result);
+ $this->assertEquals($expected->getData(), $result->getData());
+ }
+
+ public function testUpdateLinkShareSendPasswordByTalkDoesNotChangeOther() {
+ $ocs = $this->mockFormatShare();
+
+ $date = new \DateTime('2000-01-01');
+ $date->setTime(0,0,0);
+
+ $node = $this->getMockBuilder(File::class)->getMock();
+ $share = $this->newShare();
+ $share->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ ->setSharedBy($this->currentUser)
+ ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setPassword('password')
+ ->setSendPasswordByTalk(false)
+ ->setExpirationDate($date)
+ ->setNote('note')
+ ->setLabel('label')
+ ->setHideDownload(true)
+ ->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ ->setNode($node);
+
+ $node->expects($this->once())
+ ->method('lock')
+ ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+
+ $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
+
+ $this->appManager->method('isEnabledForUser')->with('spreed')->willReturn(true);
+
+ $this->shareManager->expects($this->once())->method('updateShare')->with(
+ $this->callback(function (\OCP\Share\IShare $share) use ($date) {
+ return $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
+ $share->getPassword() === 'password' &&
+ $share->getSendPasswordByTalk() === true &&
+ $share->getExpirationDate() === $date &&
+ $share->getNote() === 'note' &&
+ $share->getLabel() === 'label' &&
+ $share->getHideDownload() === true;
+ })
+ )->will($this->returnArgument(0));
+
+ $expected = new DataResponse([]);
+ $result = $ocs->updateShare(42, null, null, 'true', null, null, null, null, null);
+
+ $this->assertInstanceOf(get_class($expected), $result);
+ $this->assertEquals($expected->getData(), $result->getData());
+ }
+
+ /**
+ * @expectedException \OCP\AppFramework\OCS\OCSForbiddenException
+ * @expectedExceptionMessage Sharing sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled
+ */
+ public function testUpdateLinkShareSendPasswordByTalkWithTalkDisabledDoesNotChangeOther() {
+ $ocs = $this->mockFormatShare();
+
+ $date = new \DateTime('2000-01-01');
+ $date->setTime(0,0,0);
+
+ $node = $this->getMockBuilder(File::class)->getMock();
+ $share = $this->newShare();
+ $share->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ ->setSharedBy($this->currentUser)
+ ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setPassword('password')
+ ->setSendPasswordByTalk(false)
+ ->setExpirationDate($date)
+ ->setNote('note')
+ ->setLabel('label')
+ ->setHideDownload(true)
+ ->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ ->setNode($node);
+
+ $node->expects($this->once())
+ ->method('lock')
+ ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+
+ $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
+
+ $this->appManager->method('isEnabledForUser')->with('spreed')->willReturn(false);
+
+ $this->shareManager->expects($this->never())->method('updateShare');
+
+ $ocs->updateShare(42, null, null, 'true', null, null, null, null, null);
+ }
+
+ public function testUpdateLinkShareDoNotSendPasswordByTalkDoesNotChangeOther() {
+ $ocs = $this->mockFormatShare();
+
+ $date = new \DateTime('2000-01-01');
+ $date->setTime(0,0,0);
+
+ $node = $this->getMockBuilder(File::class)->getMock();
+ $share = $this->newShare();
+ $share->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ ->setSharedBy($this->currentUser)
+ ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setPassword('password')
+ ->setSendPasswordByTalk(true)
+ ->setExpirationDate($date)
+ ->setNote('note')
+ ->setLabel('label')
+ ->setHideDownload(true)
+ ->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ ->setNode($node);
+
+ $node->expects($this->once())
+ ->method('lock')
+ ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+
+ $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
+
+ $this->appManager->method('isEnabledForUser')->with('spreed')->willReturn(true);
+
+ $this->shareManager->expects($this->once())->method('updateShare')->with(
+ $this->callback(function (\OCP\Share\IShare $share) use ($date) {
+ return $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
+ $share->getPassword() === 'password' &&
+ $share->getSendPasswordByTalk() === false &&
+ $share->getExpirationDate() === $date &&
+ $share->getNote() === 'note' &&
+ $share->getLabel() === 'label' &&
+ $share->getHideDownload() === true;
})
)->will($this->returnArgument(0));
$expected = new DataResponse([]);
- $result = $ocs->updateShare(42, null, 'newpassword', null, null, null);
+ $result = $ocs->updateShare(42, null, null, 'false', null, null, null, null, null);
+
+ $this->assertInstanceOf(get_class($expected), $result);
+ $this->assertEquals($expected->getData(), $result->getData());
+ }
+
+ public function testUpdateLinkShareDoNotSendPasswordByTalkWithTalkDisabledDoesNotChangeOther() {
+ $ocs = $this->mockFormatShare();
+
+ $date = new \DateTime('2000-01-01');
+ $date->setTime(0,0,0);
+
+ $node = $this->getMockBuilder(File::class)->getMock();
+ $share = $this->newShare();
+ $share->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ ->setSharedBy($this->currentUser)
+ ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setPassword('password')
+ ->setSendPasswordByTalk(true)
+ ->setExpirationDate($date)
+ ->setNote('note')
+ ->setLabel('label')
+ ->setHideDownload(true)
+ ->setPermissions(\OCP\Constants::PERMISSION_ALL)
+ ->setNode($node);
+
+ $node->expects($this->once())
+ ->method('lock')
+ ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+
+ $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
+
+ $this->appManager->method('isEnabledForUser')->with('spreed')->willReturn(false);
+
+ $this->shareManager->expects($this->once())->method('updateShare')->with(
+ $this->callback(function (\OCP\Share\IShare $share) use ($date) {
+ return $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
+ $share->getPassword() === 'password' &&
+ $share->getSendPasswordByTalk() === false &&
+ $share->getExpirationDate() === $date &&
+ $share->getNote() === 'note' &&
+ $share->getLabel() === 'label' &&
+ $share->getHideDownload() === true;
+ })
+ )->will($this->returnArgument(0));
+
+ $expected = new DataResponse([]);
+ $result = $ocs->updateShare(42, null, null, 'false', null, null, null, null, null);
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
@@ -1734,7 +1997,11 @@ class ShareAPIControllerTest extends TestCase {
->setSharedBy($this->currentUser)
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setPassword('password')
+ ->setSendPasswordByTalk(true)
->setExpirationDate(new \DateTime())
+ ->setNote('note')
+ ->setLabel('label')
+ ->setHideDownload(true)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setNode($node);
@@ -1751,12 +2018,16 @@ class ShareAPIControllerTest extends TestCase {
return $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
$share->getPassword() === 'password' &&
- $share->getExpirationDate() == $date;
+ $share->getSendPasswordByTalk() === true &&
+ $share->getExpirationDate() == $date &&
+ $share->getNote() === 'note' &&
+ $share->getLabel() === 'label' &&
+ $share->getHideDownload() === true;
})
)->will($this->returnArgument(0));
$expected = new DataResponse([]);
- $result = $ocs->updateShare(42, null, null, null, null, '2010-12-23');
+ $result = $ocs->updateShare(42, null, null, null, null, '2010-12-23', null, null, null);
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
@@ -1774,7 +2045,11 @@ class ShareAPIControllerTest extends TestCase {
->setSharedBy($this->currentUser)
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setPassword('password')
+ ->setSendPasswordByTalk(true)
->setExpirationDate($date)
+ ->setNote('note')
+ ->setLabel('label')
+ ->setHideDownload(true)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setNode($folder);
@@ -1785,7 +2060,11 @@ class ShareAPIControllerTest extends TestCase {
$this->callback(function (\OCP\Share\IShare $share) use ($date) {
return $share->getPermissions() === (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE) &&
$share->getPassword() === 'password' &&
- $share->getExpirationDate() === $date;
+ $share->getSendPasswordByTalk() === true &&
+ $share->getExpirationDate() === $date &&
+ $share->getNote() === 'note' &&
+ $share->getLabel() === 'label' &&
+ $share->getHideDownload() === true;
})
)->will($this->returnArgument(0));
@@ -1793,7 +2072,7 @@ class ShareAPIControllerTest extends TestCase {
->willReturn([]);
$expected = new DataResponse([]);
- $result = $ocs->updateShare(42, null, null, null, 'true', null);
+ $result = $ocs->updateShare(42, null, null, null, 'true', null, null, null, null);
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
@@ -1811,7 +2090,11 @@ class ShareAPIControllerTest extends TestCase {
->setSharedBy($this->currentUser)
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setPassword('password')
+ ->setSendPasswordByTalk(true)
->setExpirationDate($date)
+ ->setNote('note')
+ ->setLabel('label')
+ ->setHideDownload(true)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setNode($folder);
@@ -1822,14 +2105,18 @@ class ShareAPIControllerTest extends TestCase {
$this->callback(function (\OCP\Share\IShare $share) use ($date) {
return $share->getPermissions() === (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE) &&
$share->getPassword() === 'password' &&
- $share->getExpirationDate() === $date;
+ $share->getSendPasswordByTalk() === true &&
+ $share->getExpirationDate() === $date &&
+ $share->getNote() === 'note' &&
+ $share->getLabel() === 'label' &&
+ $share->getHideDownload() === true;
})
)->will($this->returnArgument(0));
$this->shareManager->method('getSharedWith')->willReturn([]);
$expected = new DataResponse([]);
- $result = $ocs->updateShare(42, 7, null, null, null, null);
+ $result = $ocs->updateShare(42, 7, null, null, null, null, null, null, null);
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
@@ -1847,7 +2134,11 @@ class ShareAPIControllerTest extends TestCase {
->setSharedBy($this->currentUser)
->setShareType(\OCP\Share::SHARE_TYPE_LINK)
->setPassword('password')
+ ->setSendPasswordByTalk(true)
->setExpirationDate($date)
+ ->setNote('note')
+ ->setLabel('label')
+ ->setHideDownload(true)
->setPermissions(\OCP\Constants::PERMISSION_READ)
->setNode($folder);
@@ -1858,14 +2149,18 @@ class ShareAPIControllerTest extends TestCase {
$this->callback(function (\OCP\Share\IShare $share) use ($date) {
return $share->getPermissions() === (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE) &&
$share->getPassword() === 'password' &&
- $share->getExpirationDate() === $date;
+ $share->getSendPasswordByTalk() === true &&
+ $share->getExpirationDate() === $date &&
+ $share->getNote() === 'note' &&
+ $share->getLabel() === 'label' &&
+ $share->getHideDownload() === true;
})
)->will($this->returnArgument(0));
$this->shareManager->method('getSharedWith')->willReturn([]);
$expected = new DataResponse([]);
- $result = $ocs->updateShare(42, 31, null, null, null, null);
+ $result = $ocs->updateShare(42, 31, null, null, null, null, null, null, null);
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
@@ -2394,6 +2689,56 @@ class ShareAPIControllerTest extends TestCase {
'file_target' => 'myTarget',
'share_with' => 'mypassword',
'share_with_displayname' => 'mypassword',
+ 'send_password_by_talk' => false,
+ 'mail_send' => 0,
+ 'url' => 'myLink',
+ 'mimetype' => 'myMimeType',
+ 'hide_download' => 0,
+ ], $share, [], false
+ ];
+
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setSharedBy('initiator')
+ ->setShareOwner('owner')
+ ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setNode($file)
+ ->setShareTime(new \DateTime('2000-01-01T00:01:02'))
+ ->setTarget('myTarget')
+ ->setPassword('mypassword')
+ ->setSendPasswordByTalk(true)
+ ->setExpirationDate(new \DateTime('2001-01-02T00:00:00'))
+ ->setToken('myToken')
+ ->setNote('personal note')
+ ->setLabel('new link share')
+ ->setId(42);
+
+ $result[] = [
+ [
+ 'id' => 42,
+ 'share_type' => \OCP\Share::SHARE_TYPE_LINK,
+ 'uid_owner' => 'initiator',
+ 'displayname_owner' => 'initiator',
+ 'permissions' => 1,
+ 'stime' => 946684862,
+ 'parent' => null,
+ 'expiration' => '2001-01-02 00:00:00',
+ 'token' => 'myToken',
+ 'uid_file_owner' => 'owner',
+ 'displayname_file_owner' => 'owner',
+ 'note' => 'personal note',
+ 'label' => 'new link share',
+ 'path' => 'file',
+ 'item_type' => 'file',
+ 'storage_id' => 'storageId',
+ 'storage' => 100,
+ 'item_source' => 3,
+ 'file_source' => 3,
+ 'file_parent' => 1,
+ 'file_target' => 'myTarget',
+ 'share_with' => 'mypassword',
+ 'share_with_displayname' => 'mypassword',
+ 'send_password_by_talk' => true,
'mail_send' => 0,
'url' => 'myLink',
'mimetype' => 'myMimeType',