aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-03-16 11:19:09 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-03-16 11:19:09 +0100
commit225eebd8f91c19666e453527ebfa457ee10a811a (patch)
treebffba8f9396c28317cf7219f5c2ea48f2184c828
parent631ae2f0f4eda0da1c03bfc1a9a32e8cf7a926a7 (diff)
parent7d42bdfde0f53798f05b8db053737904e853d4ed (diff)
downloadnextcloud-server-225eebd8f91c19666e453527ebfa457ee10a811a.tar.gz
nextcloud-server-225eebd8f91c19666e453527ebfa457ee10a811a.zip
Merge pull request #23155 from owncloud/fed-unshare-with
Specify the target user when unsharing a federated share
-rw-r--r--apps/files_sharing/api/server2server.php2
-rw-r--r--apps/files_sharing/tests/server2server.php32
2 files changed, 33 insertions, 1 deletions
diff --git a/apps/files_sharing/api/server2server.php b/apps/files_sharing/api/server2server.php
index 6da95ed6549..a3d58880f70 100644
--- a/apps/files_sharing/api/server2server.php
+++ b/apps/files_sharing/api/server2server.php
@@ -178,7 +178,7 @@ class Server2Server {
if ($share) {
// userId must be set to the user who unshares
- \OCP\Share::unshare($share['item_type'], $share['item_source'], $share['share_type'], null, $share['uid_owner']);
+ \OCP\Share::unshare($share['item_type'], $share['item_source'], $share['share_type'], $share['share_with'], $share['uid_owner']);
list($file, $link) = $this->getFile($share['uid_owner'], $share['file_source']);
diff --git a/apps/files_sharing/tests/server2server.php b/apps/files_sharing/tests/server2server.php
index 298f1008f71..7714f274c6d 100644
--- a/apps/files_sharing/tests/server2server.php
+++ b/apps/files_sharing/tests/server2server.php
@@ -147,6 +147,38 @@ class Test_Files_Sharing_S2S_OCS_API extends TestCase {
$this->assertEmpty($data);
}
+ function testDeclineShareMultiple() {
+ $dummy = \OCP\DB::prepare('
+ INSERT INTO `*PREFIX*share`
+ (`share_type`, `uid_owner`, `item_type`, `item_source`, `item_target`, `file_source`, `file_target`, `permissions`, `stime`, `token`, `share_with`)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
+ ');
+ $dummy->execute(array(\OCP\Share::SHARE_TYPE_REMOTE, self::TEST_FILES_SHARING_API_USER1, 'test', '1', '/1', '1', '/test.txt', '1', time(), 'token1', 'foo@bar'));
+ $dummy->execute(array(\OCP\Share::SHARE_TYPE_REMOTE, self::TEST_FILES_SHARING_API_USER1, 'test', '1', '/1', '1', '/test.txt', '1', time(), 'token2', 'bar@bar'));
+
+ $verify = \OCP\DB::prepare('SELECT * FROM `*PREFIX*share`');
+ $result = $verify->execute();
+ $data = $result->fetchAll();
+ $this->assertCount(2, $data);
+
+ $_POST['token'] = 'token1';
+ $this->s2s->declineShare(array('id' => $data[0]['id']));
+
+ $verify = \OCP\DB::prepare('SELECT * FROM `*PREFIX*share`');
+ $result = $verify->execute();
+ $data = $result->fetchAll();
+ $this->assertCount(1, $data);
+ $this->assertEquals('bar@bar', $data[0]['share_with']);
+
+ $_POST['token'] = 'token2';
+ $this->s2s->declineShare(array('id' => $data[0]['id']));
+
+ $verify = \OCP\DB::prepare('SELECT * FROM `*PREFIX*share`');
+ $result = $verify->execute();
+ $data = $result->fetchAll();
+ $this->assertEmpty($data);
+ }
+
/**
* @dataProvider dataTestDeleteUser
*/