diff options
author | Robin Appelman <icewind@owncloud.com> | 2016-03-11 16:49:04 +0300 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2016-03-16 15:29:04 +0300 |
commit | 8c035ae6f68cdcb95f788b210602c68197a09de2 (patch) | |
tree | 5eaeda270f63bc6537b585ec5372b695cbdd0a48 | |
parent | d54106dadaeb84ad54c716111315db45ec202d0b (diff) |
Specify the target user when unsharing a federated share
-rw-r--r-- | apps/files_sharing/api/server2server.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/tests/server2server.php | 32 |
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 */ |