You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MailPluginTest.php 18KB

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