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