@@ -182,6 +182,46 @@ function ($appName, $key, $default) {
182182 $ this ->assertTrue ($ result ['exact ' ]['remotes ' ][0 ]['value ' ]['isTrustedServer ' ]);
183183 }
184184
185+ public function testEmailSearchInContacts (): void {
186+ $ this ->config ->expects ($ this ->any ())
187+ ->method ('getAppValue ' )
188+ ->willReturnCallback (
189+ function ($ appName , $ key , $ default ) {
190+ if ($ appName === 'core ' && $ key === 'shareapi_allow_share_dialog_user_enumeration ' ) {
191+ return 'yes ' ;
192+ }
193+ return $ default ;
194+ }
195+ );
196+
197+ $ this ->trustedServers ->expects ($ this ->any ())
198+ ->method ('isTrustedServer ' )
199+ ->willReturnCallback (function ($ serverUrl ) {
200+ return $ serverUrl === 'trustedserver.com ' ;
201+ });
202+
203+ $ this ->instantiatePlugin ();
204+
205+ $ this ->contactsManager ->expects ($ this ->once ())
206+ ->method ('search ' )
207+ ->with ('john@gmail.com ' , ['CLOUD ' , 'FN ' , 'EMAIL ' ])
208+ ->willReturn ([
209+ [
210+ 'FN ' => 'John Doe ' ,
211+ 'EMAIL ' => 'john@gmail.com ' ,
212+ 'CLOUD ' => 'john@trustedserver.com ' ,
213+ 'UID ' => 'john-contact-id '
214+ ]
215+ ]);
216+
217+ $ this ->plugin ->search ('john@gmail.com ' , 2 , 0 , $ this ->searchResult );
218+ $ result = $ this ->searchResult ->asArray ();
219+
220+ $ this ->assertNotEmpty ($ result ['exact ' ]['remotes ' ]);
221+ $ this ->assertEquals ('john@trustedserver.com ' , $ result ['exact ' ]['remotes ' ][0 ]['value ' ]['shareWith ' ]);
222+ $ this ->assertTrue ($ result ['exact ' ]['remotes ' ][0 ]['value ' ]['isTrustedServer ' ]);
223+ }
224+
185225 public static function dataGetRemote () {
186226 return [
187227 ['test ' , [], true , ['remotes ' => [], 'exact ' => ['remotes ' => []]], false , true ],
0 commit comments