Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-03-09 13:29:15 +0300
committerGitHub <noreply@github.com>2018-03-09 13:29:15 +0300
commit6176296c8034ad0d7e1d2a756b41c791f63d1c98 (patch)
treeeeddbca41ff37e84baead9dff7a4a24ed3847a79 /tests
parent0f1567d8faee6b762657ade5e745442704f56c7d (diff)
parenta2f3f0a681a49e08b89f27d94422b6b81d3ded21 (diff)
Merge pull request #8749 from nextcloud/backport/8596/sharee-email-matches-not-limited
[stable13] Sharee email matches not limited
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Collaboration/Collaborators/MailPluginTest.php129
1 files changed, 111 insertions, 18 deletions
diff --git a/tests/lib/Collaboration/Collaborators/MailPluginTest.php b/tests/lib/Collaboration/Collaborators/MailPluginTest.php
index 9c4836c2eb3..775941bd440 100644
--- a/tests/lib/Collaboration/Collaborators/MailPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/MailPluginTest.php
@@ -32,6 +32,7 @@ use OCP\Contacts\IManager;
use OCP\Federation\ICloudIdManager;
use OCP\IConfig;
use OCP\IGroupManager;
+use OCP\IUser;
use OCP\IUserSession;
use OCP\Share;
use Test\TestCase;
@@ -98,6 +99,12 @@ class MailPluginTest extends TestCase {
$this->instantiatePlugin();
+ $currentUser = $this->createMock(IUser::class);
+ $currentUser->method('getUID')
+ ->willReturn('current');
+ $this->userSession->method('getUser')
+ ->willReturn($currentUser);
+
$this->contactsManager->expects($this->any())
->method('search')
->with($searchTerm, ['EMAIL', 'FN'])
@@ -113,15 +120,15 @@ class MailPluginTest extends TestCase {
public function dataGetEmail() {
return [
- ['test', [], true, ['emails' => [], 'exact' => ['emails' => []]], false, true],
- ['test', [], false, ['emails' => [], 'exact' => ['emails' => []]], false, true],
+ ['test', [], true, ['emails' => [], 'exact' => ['emails' => []]], false, false],
+ ['test', [], false, ['emails' => [], 'exact' => ['emails' => []]], false, false],
[
'test@remote.com',
[],
true,
['emails' => [], 'exact' => ['emails' => [['label' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
false,
- true,
+ false,
],
[ // no valid email address
'test@remote',
@@ -129,7 +136,7 @@ class MailPluginTest extends TestCase {
true,
['emails' => [], 'exact' => ['emails' => []]],
false,
- true,
+ false,
],
[
'test@remote.com',
@@ -137,7 +144,7 @@ class MailPluginTest extends TestCase {
false,
['emails' => [], 'exact' => ['emails' => [['label' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
false,
- true,
+ false,
],
[
'test',
@@ -160,7 +167,7 @@ class MailPluginTest extends TestCase {
true,
['emails' => [['label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]], 'exact' => ['emails' => []]],
false,
- true,
+ false,
],
[
'test',
@@ -183,7 +190,7 @@ class MailPluginTest extends TestCase {
false,
['emails' => [], 'exact' => ['emails' => []]],
false,
- true,
+ false,
],
[
'test@remote.com',
@@ -206,7 +213,7 @@ class MailPluginTest extends TestCase {
true,
['emails' => [['label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]], 'exact' => ['emails' => [['label' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
false,
- true,
+ false,
],
[
'test@remote.com',
@@ -229,7 +236,7 @@ class MailPluginTest extends TestCase {
false,
['emails' => [], 'exact' => ['emails' => [['label' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
false,
- true,
+ false,
],
[
'username@localhost',
@@ -252,7 +259,7 @@ class MailPluginTest extends TestCase {
true,
['emails' => [], 'exact' => ['emails' => [['label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]]]],
true,
- true,
+ false,
],
[
'username@localhost',
@@ -275,7 +282,7 @@ class MailPluginTest extends TestCase {
false,
['emails' => [], 'exact' => ['emails' => [['label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]]]],
true,
- true,
+ false,
],
// contact with space
[
@@ -299,7 +306,7 @@ class MailPluginTest extends TestCase {
false,
['emails' => [], 'exact' => ['emails' => [['label' => 'User Name @ Localhost (user name@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'user name@localhost']]]]],
true,
- true,
+ false,
],
// remote with space, no contact
[
@@ -323,7 +330,7 @@ class MailPluginTest extends TestCase {
false,
['emails' => [], 'exact' => ['emails' => []]],
false,
- true,
+ false,
],
// Local user found by email
[
@@ -337,10 +344,96 @@ class MailPluginTest extends TestCase {
]
],
false,
- ['users' => [], 'exact' => ['users' => [['label' => 'User (test@example.com)','value' => ['shareType' => 0, 'shareWith' => 'test'],]]]],
+ ['users' => [], 'exact' => ['users' => [['label' => 'User (test@example.com)','value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test'],]]]],
true,
false,
- ]
+ ],
+ // Current local user found by email => no result
+ [
+ 'test@example.com',
+ [
+ [
+ 'FN' => 'User',
+ 'EMAIL' => ['test@example.com'],
+ 'CLOUD' => ['current@localhost'],
+ 'isLocalSystemBook' => true,
+ ]
+ ],
+ true,
+ ['exact' => []],
+ false,
+ false,
+ ],
+ // Pagination and "more results" for user matches byyyyyyy emails
+ [
+ 'test@example',
+ [
+ [
+ 'FN' => 'User1',
+ 'EMAIL' => ['test@example.com'],
+ 'CLOUD' => ['test1@localhost'],
+ 'isLocalSystemBook' => true,
+ ],
+ [
+ 'FN' => 'User2',
+ 'EMAIL' => ['test@example.de'],
+ 'CLOUD' => ['test2@localhost'],
+ 'isLocalSystemBook' => true,
+ ],
+ [
+ 'FN' => 'User3',
+ 'EMAIL' => ['test@example.org'],
+ 'CLOUD' => ['test3@localhost'],
+ 'isLocalSystemBook' => true,
+ ],
+ [
+ 'FN' => 'User4',
+ 'EMAIL' => ['test@example.net'],
+ 'CLOUD' => ['test4@localhost'],
+ 'isLocalSystemBook' => true,
+ ],
+ ],
+ true,
+ ['users' => [
+ ['label' => 'User1 (test@example.com)', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'User2 (test@example.de)', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
+ ], 'emails' => [], 'exact' => ['users' => [], 'emails' => []]],
+ false,
+ true,
+ ],
+ // Pagination and "more results" for normal emails
+ [
+ 'test@example',
+ [
+ [
+ 'FN' => 'User1',
+ 'EMAIL' => ['test@example.com'],
+ 'CLOUD' => ['test1@localhost'],
+ ],
+ [
+ 'FN' => 'User2',
+ 'EMAIL' => ['test@example.de'],
+ 'CLOUD' => ['test2@localhost'],
+ ],
+ [
+ 'FN' => 'User3',
+ 'EMAIL' => ['test@example.org'],
+ 'CLOUD' => ['test3@localhost'],
+ ],
+ [
+ 'FN' => 'User4',
+ 'EMAIL' => ['test@example.net'],
+ 'CLOUD' => ['test4@localhost'],
+ ],
+ ],
+ true,
+ ['emails' => [
+ ['label' => 'User1 (test@example.com)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@example.com']],
+ ['label' => 'User2 (test@example.de)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@example.de']],
+ ], 'exact' => ['emails' => []]],
+ false,
+ true,
+ ],
];
}
@@ -422,7 +515,7 @@ class MailPluginTest extends TestCase {
],
['users' => [['label' => 'User (test@example.com)','value' => ['shareType' => 0, 'shareWith' => 'test'],]], 'emails' => [], 'exact' => ['emails' => [], 'users' => []]],
false,
- true,
+ false,
[
"currentUser" => ["group1"],
"User" => ["group1"]
@@ -442,7 +535,7 @@ class MailPluginTest extends TestCase {
],
['emails'=> [], 'exact' => ['emails' => []]],
false,
- true,
+ false,
[
"currentUser" => ["group1"],
"User" => ["group2"]
@@ -462,7 +555,7 @@ class MailPluginTest extends TestCase {
],
['emails' => [], 'exact' => ['emails' => [['label' => 'test@example.com', 'value' => ['shareType' => 4,'shareWith' => 'test@example.com']]]]],
false,
- true,
+ false,
[
"currentUser" => ["group1"],
"User" => ["group2"]