summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-08-17 12:13:49 +0200
committerJoas Schilling <nickvergessen@owncloud.com>2015-08-26 11:54:25 +0200
commit83b88c9a264a46f393df95e6c57793f0300495da (patch)
tree1fff923b3c43cc45346fdcfedc304cb452106983 /apps
parent0227cfff081a79627d038f7e30a1bdece9df4d3a (diff)
downloadnextcloud-server-83b88c9a264a46f393df95e6c57793f0300495da.tar.gz
nextcloud-server-83b88c9a264a46f393df95e6c57793f0300495da.zip
Do not return the current user himself
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/api/sharees.php5
-rw-r--r--apps/files_sharing/tests/api/sharees.php44
2 files changed, 44 insertions, 5 deletions
diff --git a/apps/files_sharing/api/sharees.php b/apps/files_sharing/api/sharees.php
index 3e802b3028a..f12677265bf 100644
--- a/apps/files_sharing/api/sharees.php
+++ b/apps/files_sharing/api/sharees.php
@@ -116,6 +116,11 @@ class Sharees {
foreach ($users as $uid => $displayName) {
+ if ($uid === $this->userSession->getUser()->getUID()) {
+ // Skip the current user
+ continue;
+ }
+
$sharees[] = [
'label' => $displayName,
'value' => [
diff --git a/apps/files_sharing/tests/api/sharees.php b/apps/files_sharing/tests/api/sharees.php
index 24a659eb063..9b7a21b0635 100644
--- a/apps/files_sharing/tests/api/sharees.php
+++ b/apps/files_sharing/tests/api/sharees.php
@@ -129,6 +129,20 @@ class ShareesTest extends TestCase {
],
[
'test',
+ false,
+ [],
+ [
+ $this->getUserMock('test1', 'Test One'),
+ $this->getUserMock('test2', 'Test Two'),
+ $this->getUserMock('admin', 'Should be removed'),
+ ],
+ [
+ ['label' => 'Test One', 'value' => ['shareType' => \OCP\Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'Test Two', 'value' => ['shareType' => \OCP\Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
+ ]
+ ],
+ [
+ 'test',
true,
['abc', 'xyz'],
[
@@ -175,6 +189,26 @@ class ShareesTest extends TestCase {
['label' => 'Test Two', 'value' => ['shareType' => \OCP\Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
]
],
+ [
+ 'test',
+ true,
+ ['abc', 'xyz'],
+ [
+ ['abc', 'test', -1, 0, [
+ 'test1' => 'Test One',
+ ]],
+ ['xyz', 'test', -1, 0, [
+ 'test2' => 'Test Two',
+ ]],
+ ['admin', 'Should be removed', -1, 0, [
+ 'test2' => 'Test Two',
+ ]],
+ ],
+ [
+ ['label' => 'Test One', 'value' => ['shareType' => \OCP\Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'Test Two', 'value' => ['shareType' => \OCP\Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
+ ]
+ ],
];
}
@@ -188,17 +222,17 @@ class ShareesTest extends TestCase {
* @param array $expected
*/
public function testGetUsers($searchTerm, $shareWithGroupOnly, $groupResponse, $userResponse, $expected) {
+ $user = $this->getUserMock('admin', 'Administrator');
+ $this->session->expects($this->any())
+ ->method('getUser')
+ ->willReturn($user);
+
if (!$shareWithGroupOnly) {
$this->userManager->expects($this->once())
->method('searchDisplayName')
->with($searchTerm)
->willReturn($userResponse);
} else {
- $user = $this->getUserMock('admin', 'Administrator');
- $this->session->expects($this->any())
- ->method('getUser')
- ->willReturn($user);
-
$this->groupManager->expects($this->once())
->method('getUserGroupIds')
->with($user)