MailPluginTest.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace Test\Collaboration\Collaborators;
  7. use OC\Collaboration\Collaborators\MailPlugin;
  8. use OC\Collaboration\Collaborators\SearchResult;
  9. use OC\Federation\CloudIdManager;
  10. use OC\KnownUser\KnownUserService;
  11. use OCP\Collaboration\Collaborators\SearchResultType;
  12. use OCP\Contacts\IManager;
  13. use OCP\EventDispatcher\IEventDispatcher;
  14. use OCP\Federation\ICloudIdManager;
  15. use OCP\ICacheFactory;
  16. use OCP\IConfig;
  17. use OCP\IGroupManager;
  18. use OCP\IURLGenerator;
  19. use OCP\IUser;
  20. use OCP\IUserManager;
  21. use OCP\IUserSession;
  22. use OCP\Mail\IMailer;
  23. use OCP\Share\IShare;
  24. use Test\TestCase;
  25. class MailPluginTest extends TestCase {
  26. /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
  27. protected $config;
  28. /** @var IManager|\PHPUnit\Framework\MockObject\MockObject */
  29. protected $contactsManager;
  30. /** @var ICloudIdManager|\PHPUnit\Framework\MockObject\MockObject */
  31. protected $cloudIdManager;
  32. /** @var MailPlugin */
  33. protected $plugin;
  34. /** @var SearchResult */
  35. protected $searchResult;
  36. /** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
  37. protected $groupManager;
  38. /** @var KnownUserService|\PHPUnit\Framework\MockObject\MockObject */
  39. protected $knownUserService;
  40. /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */
  41. protected $userSession;
  42. /** @var IMailer|\PHPUnit\Framework\MockObject\MockObject */
  43. protected $mailer;
  44. protected function setUp(): void {
  45. parent::setUp();
  46. $this->config = $this->createMock(IConfig::class);
  47. $this->contactsManager = $this->createMock(IManager::class);
  48. $this->groupManager = $this->createMock(IGroupManager::class);
  49. $this->knownUserService = $this->createMock(KnownUserService::class);
  50. $this->userSession = $this->createMock(IUserSession::class);
  51. $this->mailer = $this->createMock(IMailer::class);
  52. $this->cloudIdManager = new CloudIdManager(
  53. $this->contactsManager,
  54. $this->createMock(IURLGenerator::class),
  55. $this->createMock(IUserManager::class),
  56. $this->createMock(ICacheFactory::class),
  57. $this->createMock(IEventDispatcher::class)
  58. );
  59. $this->searchResult = new SearchResult();
  60. }
  61. public function instantiatePlugin() {
  62. $this->plugin = new MailPlugin(
  63. $this->contactsManager,
  64. $this->cloudIdManager,
  65. $this->config,
  66. $this->groupManager,
  67. $this->knownUserService,
  68. $this->userSession,
  69. $this->mailer
  70. );
  71. }
  72. /**
  73. * @dataProvider dataGetEmail
  74. *
  75. * @param string $searchTerm
  76. * @param array $contacts
  77. * @param bool $shareeEnumeration
  78. * @param array $expected
  79. * @param bool $reachedEnd
  80. */
  81. public function testSearch($searchTerm, $contacts, $shareeEnumeration, $expected, $exactIdMatch, $reachedEnd, $validEmail) {
  82. $this->config->expects($this->any())
  83. ->method('getAppValue')
  84. ->willReturnCallback(
  85. function ($appName, $key, $default) use ($shareeEnumeration) {
  86. if ($appName === 'core' && $key === 'shareapi_allow_share_dialog_user_enumeration') {
  87. return $shareeEnumeration ? 'yes' : 'no';
  88. }
  89. return $default;
  90. }
  91. );
  92. $this->instantiatePlugin();
  93. $currentUser = $this->createMock(IUser::class);
  94. $currentUser->method('getUID')
  95. ->willReturn('current');
  96. $this->userSession->method('getUser')
  97. ->willReturn($currentUser);
  98. $this->mailer->method('validateMailAddress')
  99. ->willReturn($validEmail);
  100. $this->contactsManager->expects($this->any())
  101. ->method('search')
  102. ->willReturnCallback(function ($search, $searchAttributes) use ($searchTerm, $contacts) {
  103. if ($search === $searchTerm) {
  104. return $contacts;
  105. }
  106. return [];
  107. });
  108. $moreResults = $this->plugin->search($searchTerm, 2, 0, $this->searchResult);
  109. $result = $this->searchResult->asArray();
  110. $this->assertSame($exactIdMatch, $this->searchResult->hasExactIdMatch(new SearchResultType('emails')));
  111. $this->assertEquals($expected, $result);
  112. $this->assertSame($reachedEnd, $moreResults);
  113. }
  114. public function dataGetEmail() {
  115. return [
  116. // data set 0
  117. ['test', [], true, ['emails' => [], 'exact' => ['emails' => []]], false, false, false],
  118. // data set 1
  119. ['test', [], false, ['emails' => [], 'exact' => ['emails' => []]], false, false, false],
  120. // data set 2
  121. [
  122. 'test@remote.com',
  123. [],
  124. true,
  125. ['emails' => [], 'exact' => ['emails' => [['uuid' => 'test@remote.com', 'label' => 'test@remote.com', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
  126. false,
  127. false,
  128. true,
  129. ],
  130. // data set 3
  131. [ // no valid email address
  132. 'test@remote',
  133. [],
  134. true,
  135. ['emails' => [], 'exact' => ['emails' => []]],
  136. false,
  137. false,
  138. false,
  139. ],
  140. // data set 4
  141. [
  142. 'test@remote.com',
  143. [],
  144. false,
  145. ['emails' => [], 'exact' => ['emails' => [['uuid' => 'test@remote.com', 'label' => 'test@remote.com', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
  146. false,
  147. false,
  148. true,
  149. ],
  150. // data set 5
  151. [
  152. 'test',
  153. [
  154. [
  155. 'UID' => 'uid3',
  156. 'FN' => 'User3 @ Localhost',
  157. ],
  158. [
  159. 'UID' => 'uid2',
  160. 'FN' => 'User2 @ Localhost',
  161. 'EMAIL' => [
  162. ],
  163. ],
  164. [
  165. 'UID' => 'uid1',
  166. 'FN' => 'User @ Localhost',
  167. 'EMAIL' => [
  168. 'username@localhost',
  169. ],
  170. ],
  171. ],
  172. true,
  173. ['emails' => [['uuid' => 'uid1', 'name' => 'User @ Localhost', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@localhost']]], 'exact' => ['emails' => []]],
  174. false,
  175. false,
  176. false,
  177. ],
  178. // data set 6
  179. [
  180. 'test',
  181. [
  182. [
  183. 'UID' => 'uid3',
  184. 'FN' => 'User3 @ Localhost',
  185. ],
  186. [
  187. 'UID' => 'uid2',
  188. 'FN' => 'User2 @ Localhost',
  189. 'EMAIL' => [
  190. ],
  191. ],
  192. [
  193. 'isLocalSystemBook' => true,
  194. 'UID' => 'uid1',
  195. 'FN' => 'User @ Localhost',
  196. 'EMAIL' => [
  197. 'username@localhost',
  198. ],
  199. ],
  200. ],
  201. false,
  202. ['emails' => [], 'exact' => ['emails' => []]],
  203. false,
  204. false,
  205. false,
  206. ],
  207. // data set 7
  208. [
  209. 'test@remote.com',
  210. [
  211. [
  212. 'UID' => 'uid3',
  213. 'FN' => 'User3 @ Localhost',
  214. ],
  215. [
  216. 'UID' => 'uid2',
  217. 'FN' => 'User2 @ Localhost',
  218. 'EMAIL' => [
  219. ],
  220. ],
  221. [
  222. 'UID' => 'uid1',
  223. 'FN' => 'User @ Localhost',
  224. 'EMAIL' => [
  225. 'username@localhost',
  226. ],
  227. ],
  228. ],
  229. true,
  230. ['emails' => [['uuid' => 'uid1', 'name' => 'User @ Localhost', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@localhost']]], 'exact' => ['emails' => [['label' => 'test@remote.com', 'uuid' => 'test@remote.com', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
  231. false,
  232. false,
  233. true,
  234. ],
  235. // data set 8
  236. [
  237. 'test@remote.com',
  238. [
  239. [
  240. 'UID' => 'uid3',
  241. 'FN' => 'User3 @ Localhost',
  242. ],
  243. [
  244. 'UID' => 'uid2',
  245. 'FN' => 'User2 @ Localhost',
  246. 'EMAIL' => [
  247. ],
  248. ],
  249. [
  250. 'isLocalSystemBook' => true,
  251. 'UID' => 'uid1',
  252. 'FN' => 'User @ Localhost',
  253. 'EMAIL' => [
  254. 'username@localhost',
  255. ],
  256. ],
  257. ],
  258. false,
  259. ['emails' => [], 'exact' => ['emails' => [['label' => 'test@remote.com', 'uuid' => 'test@remote.com', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
  260. false,
  261. false,
  262. true,
  263. ],
  264. // data set 9
  265. [
  266. 'username@localhost',
  267. [
  268. [
  269. 'UID' => 'uid3',
  270. 'FN' => 'User3 @ Localhost',
  271. ],
  272. [
  273. 'UID' => 'uid2',
  274. 'FN' => 'User2 @ Localhost',
  275. 'EMAIL' => [
  276. ],
  277. ],
  278. [
  279. 'UID' => 'uid1',
  280. 'FN' => 'User @ Localhost',
  281. 'EMAIL' => [
  282. 'username@localhost',
  283. ],
  284. ],
  285. ],
  286. true,
  287. ['emails' => [], 'exact' => ['emails' => [['name' => 'User @ Localhost', 'uuid' => 'uid1', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@localhost']]]]],
  288. true,
  289. false,
  290. false,
  291. ],
  292. // data set 10
  293. [
  294. 'username@localhost',
  295. [
  296. [
  297. 'UID' => 'uid1',
  298. 'FN' => 'User3 @ Localhost',
  299. ],
  300. [
  301. 'UID' => 'uid2',
  302. 'FN' => 'User2 @ Localhost',
  303. 'EMAIL' => [
  304. ],
  305. ],
  306. [
  307. 'UID' => 'uid1',
  308. 'FN' => 'User @ Localhost',
  309. 'EMAIL' => [
  310. 'username@localhost',
  311. ],
  312. ],
  313. ],
  314. false,
  315. ['emails' => [], 'exact' => ['emails' => [['name' => 'User @ Localhost', 'uuid' => 'uid1', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@localhost']]]]],
  316. true,
  317. false,
  318. false,
  319. ],
  320. // data set 11
  321. // contact with space
  322. [
  323. 'user name@localhost',
  324. [
  325. [
  326. 'UID' => 'uid3',
  327. 'FN' => 'User3 @ Localhost',
  328. ],
  329. [
  330. 'UID' => 'uid2',
  331. 'FN' => 'User2 @ Localhost',
  332. 'EMAIL' => [
  333. ],
  334. ],
  335. [
  336. 'UID' => 'uid1',
  337. 'FN' => 'User Name @ Localhost',
  338. 'EMAIL' => [
  339. 'user name@localhost',
  340. ],
  341. ],
  342. ],
  343. false,
  344. ['emails' => [], 'exact' => ['emails' => [['name' => 'User Name @ Localhost', 'uuid' => 'uid1', 'type' => '', 'label' => 'User Name @ Localhost (user name@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'user name@localhost']]]]],
  345. true,
  346. false,
  347. false,
  348. ],
  349. // data set 12
  350. // remote with space, no contact
  351. [
  352. 'user space@remote.com',
  353. [
  354. [
  355. 'UID' => 'uid3',
  356. 'FN' => 'User3 @ Localhost',
  357. ],
  358. [
  359. 'UID' => 'uid2',
  360. 'FN' => 'User2 @ Localhost',
  361. 'EMAIL' => [
  362. ],
  363. ],
  364. [
  365. 'isLocalSystemBook' => true,
  366. 'UID' => 'uid1',
  367. 'FN' => 'User @ Localhost',
  368. 'EMAIL' => [
  369. 'username@localhost',
  370. ],
  371. ],
  372. ],
  373. false,
  374. ['emails' => [], 'exact' => ['emails' => []]],
  375. false,
  376. false,
  377. false,
  378. ],
  379. // data set 13
  380. // Local user found by email
  381. [
  382. 'test@example.com',
  383. [
  384. [
  385. 'UID' => 'uid1',
  386. 'FN' => 'User',
  387. 'EMAIL' => ['test@example.com'],
  388. 'CLOUD' => ['test@localhost'],
  389. 'isLocalSystemBook' => true,
  390. ]
  391. ],
  392. false,
  393. ['users' => [], 'exact' => ['users' => [['uuid' => 'uid1', 'name' => 'User', 'label' => 'User (test@example.com)','value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test'], 'shareWithDisplayNameUnique' => 'test@example.com']]]],
  394. true,
  395. false,
  396. true,
  397. ],
  398. // data set 14
  399. // Current local user found by email => no result
  400. [
  401. 'test@example.com',
  402. [
  403. [
  404. 'UID' => 'uid1',
  405. 'FN' => 'User',
  406. 'EMAIL' => ['test@example.com'],
  407. 'CLOUD' => ['current@localhost'],
  408. 'isLocalSystemBook' => true,
  409. ]
  410. ],
  411. true,
  412. ['exact' => []],
  413. false,
  414. false,
  415. true,
  416. ],
  417. // data set 15
  418. // Pagination and "more results" for user matches byyyyyyy emails
  419. [
  420. 'test@example',
  421. [
  422. [
  423. 'UID' => 'uid1',
  424. 'FN' => 'User1',
  425. 'EMAIL' => ['test@example.com'],
  426. 'CLOUD' => ['test1@localhost'],
  427. 'isLocalSystemBook' => true,
  428. ],
  429. [
  430. 'UID' => 'uid2',
  431. 'FN' => 'User2',
  432. 'EMAIL' => ['test@example.de'],
  433. 'CLOUD' => ['test2@localhost'],
  434. 'isLocalSystemBook' => true,
  435. ],
  436. [
  437. 'UID' => 'uid3',
  438. 'FN' => 'User3',
  439. 'EMAIL' => ['test@example.org'],
  440. 'CLOUD' => ['test3@localhost'],
  441. 'isLocalSystemBook' => true,
  442. ],
  443. [
  444. 'UID' => 'uid4',
  445. 'FN' => 'User4',
  446. 'EMAIL' => ['test@example.net'],
  447. 'CLOUD' => ['test4@localhost'],
  448. 'isLocalSystemBook' => true,
  449. ],
  450. ],
  451. true,
  452. ['users' => [
  453. ['uuid' => 'uid1', 'name' => 'User1', 'label' => 'User1 (test@example.com)', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1'], 'shareWithDisplayNameUnique' => 'test@example.com'],
  454. ['uuid' => 'uid2', 'name' => 'User2', 'label' => 'User2 (test@example.de)', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test2'], 'shareWithDisplayNameUnique' => 'test@example.de'],
  455. ], 'emails' => [], 'exact' => ['users' => [], 'emails' => []]],
  456. false,
  457. true,
  458. false,
  459. ],
  460. // data set 16
  461. // Pagination and "more results" for normal emails
  462. [
  463. 'test@example',
  464. [
  465. [
  466. 'UID' => 'uid1',
  467. 'FN' => 'User1',
  468. 'EMAIL' => ['test@example.com'],
  469. 'CLOUD' => ['test1@localhost'],
  470. ],
  471. [
  472. 'UID' => 'uid2',
  473. 'FN' => 'User2',
  474. 'EMAIL' => ['test@example.de'],
  475. 'CLOUD' => ['test2@localhost'],
  476. ],
  477. [
  478. 'UID' => 'uid3',
  479. 'FN' => 'User3',
  480. 'EMAIL' => ['test@example.org'],
  481. 'CLOUD' => ['test3@localhost'],
  482. ],
  483. [
  484. 'UID' => 'uid4',
  485. 'FN' => 'User4',
  486. 'EMAIL' => ['test@example.net'],
  487. 'CLOUD' => ['test4@localhost'],
  488. ],
  489. ],
  490. true,
  491. ['emails' => [
  492. ['uuid' => 'uid1', 'name' => 'User1', 'type' => '', 'label' => 'User1 (test@example.com)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@example.com']],
  493. ['uuid' => 'uid2', 'name' => 'User2', 'type' => '', 'label' => 'User2 (test@example.de)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@example.de']],
  494. ], 'exact' => ['emails' => []]],
  495. false,
  496. true,
  497. false,
  498. ],
  499. // data set 17
  500. // multiple email addresses with type
  501. [
  502. 'User Name',
  503. [
  504. [
  505. 'UID' => 'uid3',
  506. 'FN' => 'User3',
  507. ],
  508. [
  509. 'UID' => 'uid2',
  510. 'FN' => 'User2',
  511. 'EMAIL' => [
  512. ],
  513. ],
  514. [
  515. 'UID' => 'uid1',
  516. 'FN' => 'User Name',
  517. 'EMAIL' => [
  518. ['type' => 'HOME', 'value' => 'username@localhost'],
  519. ['type' => 'WORK', 'value' => 'username@other'],
  520. ],
  521. ],
  522. ],
  523. false,
  524. ['emails' => [
  525. ], 'exact' => ['emails' => [
  526. ['name' => 'User Name', 'uuid' => 'uid1', 'type' => 'HOME', 'label' => 'User Name (username@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@localhost']],
  527. ['name' => 'User Name', 'uuid' => 'uid1', 'type' => 'WORK', 'label' => 'User Name (username@other)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@other']]
  528. ]]],
  529. false,
  530. false,
  531. false,
  532. ],
  533. // data set 18
  534. // idn email
  535. [
  536. 'test@lölölölölölölöl.com',
  537. [],
  538. true,
  539. ['emails' => [], 'exact' => ['emails' => [['uuid' => 'test@lölölölölölölöl.com', 'label' => 'test@lölölölölölölöl.com', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@lölölölölölölöl.com']]]]],
  540. false,
  541. false,
  542. true,
  543. ],
  544. ];
  545. }
  546. /**
  547. * @dataProvider dataGetEmailGroupsOnly
  548. *
  549. * @param string $searchTerm
  550. * @param array $contacts
  551. * @param array $expected
  552. * @param bool $exactIdMatch
  553. * @param bool $reachedEnd
  554. * @param array groups
  555. */
  556. public function testSearchGroupsOnly($searchTerm, $contacts, $expected, $exactIdMatch, $reachedEnd, $userToGroupMapping, $validEmail) {
  557. $this->config->expects($this->any())
  558. ->method('getAppValue')
  559. ->willReturnCallback(
  560. function ($appName, $key, $default) {
  561. if ($appName === 'core' && $key === 'shareapi_allow_share_dialog_user_enumeration') {
  562. return 'yes';
  563. } elseif ($appName === 'core' && $key === 'shareapi_only_share_with_group_members') {
  564. return 'yes';
  565. }
  566. return $default;
  567. }
  568. );
  569. $this->instantiatePlugin();
  570. /** @var \OCP\IUser | \PHPUnit\Framework\MockObject\MockObject */
  571. $currentUser = $this->createMock('\OCP\IUser');
  572. $currentUser->expects($this->any())
  573. ->method('getUID')
  574. ->willReturn('currentUser');
  575. $this->mailer->method('validateMailAddress')
  576. ->willReturn($validEmail);
  577. $this->contactsManager->expects($this->any())
  578. ->method('search')
  579. ->willReturnCallback(function ($search, $searchAttributes) use ($searchTerm, $contacts) {
  580. if ($search === $searchTerm) {
  581. return $contacts;
  582. }
  583. return [];
  584. });
  585. $this->userSession->expects($this->any())
  586. ->method('getUser')
  587. ->willReturn($currentUser);
  588. $this->groupManager->expects($this->any())
  589. ->method('getUserGroupIds')
  590. ->willReturnCallback(function (\OCP\IUser $user) use ($userToGroupMapping) {
  591. return $userToGroupMapping[$user->getUID()];
  592. });
  593. $this->groupManager->expects($this->any())
  594. ->method('isInGroup')
  595. ->willReturnCallback(function ($userId, $group) use ($userToGroupMapping) {
  596. return in_array($group, $userToGroupMapping[$userId]);
  597. });
  598. $moreResults = $this->plugin->search($searchTerm, 2, 0, $this->searchResult);
  599. $result = $this->searchResult->asArray();
  600. $this->assertSame($exactIdMatch, $this->searchResult->hasExactIdMatch(new SearchResultType('emails')));
  601. $this->assertEquals($expected, $result);
  602. $this->assertSame($reachedEnd, $moreResults);
  603. }
  604. public function dataGetEmailGroupsOnly() {
  605. return [
  606. // The user `User` can share with the current user
  607. [
  608. 'test',
  609. [
  610. [
  611. 'FN' => 'User',
  612. 'EMAIL' => ['test@example.com'],
  613. 'CLOUD' => ['test@localhost'],
  614. 'isLocalSystemBook' => true,
  615. 'UID' => 'User'
  616. ]
  617. ],
  618. ['users' => [['label' => 'User (test@example.com)', 'uuid' => 'User', 'name' => 'User', 'value' => ['shareType' => 0, 'shareWith' => 'test'],'shareWithDisplayNameUnique' => 'test@example.com',]], 'emails' => [], 'exact' => ['emails' => [], 'users' => []]],
  619. false,
  620. false,
  621. [
  622. "currentUser" => ["group1"],
  623. "User" => ["group1"]
  624. ],
  625. false,
  626. ],
  627. // The user `User` cannot share with the current user
  628. [
  629. 'test',
  630. [
  631. [
  632. 'FN' => 'User',
  633. 'EMAIL' => ['test@example.com'],
  634. 'CLOUD' => ['test@localhost'],
  635. 'isLocalSystemBook' => true,
  636. 'UID' => 'User'
  637. ]
  638. ],
  639. ['emails' => [], 'exact' => ['emails' => []]],
  640. false,
  641. false,
  642. [
  643. "currentUser" => ["group1"],
  644. "User" => ["group2"]
  645. ],
  646. false,
  647. ],
  648. // The user `User` cannot share with the current user, but there is an exact match on the e-mail address -> share by e-mail
  649. [
  650. 'test@example.com',
  651. [
  652. [
  653. 'FN' => 'User',
  654. 'EMAIL' => ['test@example.com'],
  655. 'CLOUD' => ['test@localhost'],
  656. 'isLocalSystemBook' => true,
  657. 'UID' => 'User'
  658. ]
  659. ],
  660. ['emails' => [], 'exact' => ['emails' => [['label' => 'test@example.com', 'uuid' => 'test@example.com', 'value' => ['shareType' => 4,'shareWith' => 'test@example.com']]]]],
  661. false,
  662. false,
  663. [
  664. "currentUser" => ["group1"],
  665. "User" => ["group2"]
  666. ],
  667. true,
  668. ]
  669. ];
  670. }
  671. }