Blame view

sources/apps/user_ldap/tests/user_ldap.php 15.8 KB
31b7f2792   Kload   Upgrade to ownclo...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  <?php
  /**
  * ownCloud
  *
  * @author Arthur Schiwon
  * @copyright 2013 Arthur Schiwon blizzz@owncloud.com
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  * License as published by the Free Software Foundation; either
  * version 3 of the License, or any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  *
  * You should have received a copy of the GNU Affero General Public
  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
  *
  */
  
  namespace OCA\user_ldap\tests;
  
  use \OCA\user_ldap\USER_LDAP as UserLDAP;
  use \OCA\user_ldap\lib\Access;
  use \OCA\user_ldap\lib\Connection;
  use \OCA\user_ldap\lib\ILDAPWrapper;
  
  class Test_User_Ldap_Direct extends \PHPUnit_Framework_TestCase {
  	protected $backend;
6d9380f96   Cédric Dupont   Update sources OC...
32
  	protected $access;
31b7f2792   Kload   Upgrade to ownclo...
33
34
35
36
37
38
39
40
41
  
  	public function setUp() {
  		\OC_User::clearBackends();
  		\OC_Group::clearBackends();
  	}
  
  	private function getAccessMock() {
  		static $conMethods;
  		static $accMethods;
6d9380f96   Cédric Dupont   Update sources OC...
42
  		static $uMethods;
31b7f2792   Kload   Upgrade to ownclo...
43
44
45
46
  
  		if(is_null($conMethods) || is_null($accMethods)) {
  			$conMethods = get_class_methods('\OCA\user_ldap\lib\Connection');
  			$accMethods = get_class_methods('\OCA\user_ldap\lib\Access');
6d9380f96   Cédric Dupont   Update sources OC...
47
48
49
50
51
  			unset($accMethods[array_search('getConnection', $accMethods)]);
  			$uMethods   = get_class_methods('\OCA\user_ldap\lib\user\User');
  			unset($uMethods[array_search('getUsername', $uMethods)]);
  			unset($uMethods[array_search('getDN', $uMethods)]);
  			unset($uMethods[array_search('__construct', $uMethods)]);
31b7f2792   Kload   Upgrade to ownclo...
52
53
54
55
56
  		}
  		$lw  = $this->getMock('\OCA\user_ldap\lib\ILDAPWrapper');
  		$connector = $this->getMock('\OCA\user_ldap\lib\Connection',
  									$conMethods,
  									array($lw, null, null));
6d9380f96   Cédric Dupont   Update sources OC...
57
58
59
60
61
62
63
64
  
  		$um = new \OCA\user_ldap\lib\user\Manager(
  				$this->getMock('\OCP\IConfig'),
  				$this->getMock('\OCA\user_ldap\lib\FilesystemHelper'),
  				$this->getMock('\OCA\user_ldap\lib\LogWrapper'),
  				$this->getMock('\OCP\IAvatarManager'),
  				$this->getMock('\OCP\Image')
  			);
31b7f2792   Kload   Upgrade to ownclo...
65
66
  		$access = $this->getMock('\OCA\user_ldap\lib\Access',
  								 $accMethods,
6d9380f96   Cédric Dupont   Update sources OC...
67
68
69
  								 array($connector, $lw, $um));
  
  		$um->setLdapAccess($access);
31b7f2792   Kload   Upgrade to ownclo...
70
71
72
73
74
75
76
77
78
79
  
  		return $access;
  	}
  
  	private function prepareMockForUserExists(&$access) {
  		$access->expects($this->any())
  			   ->method('username2dn')
  			   ->will($this->returnCallback(function($uid) {
  					switch ($uid) {
  						case 'gunslinger':
6d9380f96   Cédric Dupont   Update sources OC...
80
  							return 'dnOfRoland,dc=test';
31b7f2792   Kload   Upgrade to ownclo...
81
82
  							break;
  						case 'formerUser':
6d9380f96   Cédric Dupont   Update sources OC...
83
  							return 'dnOfFormerUser,dc=test';
31b7f2792   Kload   Upgrade to ownclo...
84
85
  							break;
  						case 'newyorker':
6d9380f96   Cédric Dupont   Update sources OC...
86
  							return 'dnOfNewYorker,dc=test';
31b7f2792   Kload   Upgrade to ownclo...
87
88
  							break;
  						case 'ladyofshadows':
6d9380f96   Cédric Dupont   Update sources OC...
89
  							return 'dnOfLadyOfShadows,dc=test';
31b7f2792   Kload   Upgrade to ownclo...
90
  							break;
6d9380f96   Cédric Dupont   Update sources OC...
91
  						default:
31b7f2792   Kload   Upgrade to ownclo...
92
93
94
95
96
97
  							return false;
  					}
  			   }));
  	}
  
  	/**
6d9380f96   Cédric Dupont   Update sources OC...
98
99
  	 * Prepares the Access mock for checkPassword tests
  	 * @param \OCA\user_ldap\lib\Access $access mock
31b7f2792   Kload   Upgrade to ownclo...
100
101
102
  	 * @return void
  	 */
  	private function prepareAccessForCheckPassword(&$access) {
a293d369c   Kload   Update sources to...
103
104
105
106
107
  		$access->expects($this->once())
  			   ->method('escapeFilterPart')
  			   ->will($this->returnCallback(function($uid) {
  				   return $uid;
  			   }));
31b7f2792   Kload   Upgrade to ownclo...
108
109
110
111
112
113
114
115
116
117
118
119
120
  		$access->connection->expects($this->any())
  			   ->method('__get')
  			   ->will($this->returnCallback(function($name) {
  					if($name === 'ldapLoginFilter') {
  						return '%uid';
  					}
  					return null;
  			   }));
  
  		$access->expects($this->any())
  			   ->method('fetchListOfUsers')
  			   ->will($this->returnCallback(function($filter) {
  					if($filter === 'roland') {
6d9380f96   Cédric Dupont   Update sources OC...
121
  						return array('dnOfRoland,dc=test');
31b7f2792   Kload   Upgrade to ownclo...
122
123
124
125
126
127
  					}
  					return array();
  			   }));
  
  		$access->expects($this->any())
  			   ->method('dn2username')
6d9380f96   Cédric Dupont   Update sources OC...
128
  			   ->with($this->equalTo('dnOfRoland,dc=test'))
31b7f2792   Kload   Upgrade to ownclo...
129
130
131
  			   ->will($this->returnValue('gunslinger'));
  
  		$access->expects($this->any())
f7d878ff1   kload   [enh] Update to 7...
132
133
134
135
136
  			   ->method('stringResemblesDN')
  			   ->with($this->equalTo('dnOfRoland,dc=test'))
  			   ->will($this->returnValue(true));
  
  		$access->expects($this->any())
31b7f2792   Kload   Upgrade to ownclo...
137
138
139
140
141
142
143
144
  			   ->method('areCredentialsValid')
  			   ->will($this->returnCallback(function($dn, $pwd) {
  					if($pwd === 'dt19') {
  						return true;
  					}
  					return false;
  			   }));
  	}
a293d369c   Kload   Update sources to...
145
  	public function testCheckPasswordUidReturn() {
31b7f2792   Kload   Upgrade to ownclo...
146
  		$access = $this->getAccessMock();
a293d369c   Kload   Update sources to...
147

31b7f2792   Kload   Upgrade to ownclo...
148
149
150
151
152
153
  		$this->prepareAccessForCheckPassword($access);
  		$backend = new UserLDAP($access);
  		\OC_User::useBackend($backend);
  
  		$result = $backend->checkPassword('roland', 'dt19');
  		$this->assertEquals('gunslinger', $result);
a293d369c   Kload   Update sources to...
154
155
156
157
158
159
160
161
  	}
  
  	public function testCheckPasswordWrongPassword() {
  		$access = $this->getAccessMock();
  
  		$this->prepareAccessForCheckPassword($access);
  		$backend = new UserLDAP($access);
  		\OC_User::useBackend($backend);
31b7f2792   Kload   Upgrade to ownclo...
162
163
164
  
  		$result = $backend->checkPassword('roland', 'wrong');
  		$this->assertFalse($result);
a293d369c   Kload   Update sources to...
165
166
167
168
169
170
171
172
  	}
  
  	public function testCheckPasswordWrongUser() {
  		$access = $this->getAccessMock();
  
  		$this->prepareAccessForCheckPassword($access);
  		$backend = new UserLDAP($access);
  		\OC_User::useBackend($backend);
31b7f2792   Kload   Upgrade to ownclo...
173
174
175
176
177
178
179
180
181
182
183
184
185
  
  		$result = $backend->checkPassword('mallory', 'evil');
  		$this->assertFalse($result);
  	}
  
  	public function testCheckPasswordPublicAPI() {
  		$access = $this->getAccessMock();
  		$this->prepareAccessForCheckPassword($access);
  		$backend = new UserLDAP($access);
  		\OC_User::useBackend($backend);
  
  		$result = \OCP\User::checkPassword('roland', 'dt19');
  		$this->assertEquals('gunslinger', $result);
a293d369c   Kload   Update sources to...
186
187
188
189
190
191
192
  	}
  
  	public function testCheckPasswordPublicAPIWrongPassword() {
  		$access = $this->getAccessMock();
  		$this->prepareAccessForCheckPassword($access);
  		$backend = new UserLDAP($access);
  		\OC_User::useBackend($backend);
31b7f2792   Kload   Upgrade to ownclo...
193
194
195
  
  		$result = \OCP\User::checkPassword('roland', 'wrong');
  		$this->assertFalse($result);
a293d369c   Kload   Update sources to...
196
197
198
199
200
201
202
  	}
  
  	public function testCheckPasswordPublicAPIWrongUser() {
  		$access = $this->getAccessMock();
  		$this->prepareAccessForCheckPassword($access);
  		$backend = new UserLDAP($access);
  		\OC_User::useBackend($backend);
31b7f2792   Kload   Upgrade to ownclo...
203
204
205
206
207
208
  
  		$result = \OCP\User::checkPassword('mallory', 'evil');
  		$this->assertFalse($result);
  	}
  
  	/**
6d9380f96   Cédric Dupont   Update sources OC...
209
210
  	 * Prepares the Access mock for getUsers tests
  	 * @param \OCA\user_ldap\lib\Access $access mock
31b7f2792   Kload   Upgrade to ownclo...
211
212
213
  	 * @return void
  	 */
  	private function prepareAccessForGetUsers(&$access) {
a293d369c   Kload   Update sources to...
214
215
216
217
218
  		$access->expects($this->once())
  			   ->method('escapeFilterPart')
  			   ->will($this->returnCallback(function($search) {
  				   return $search;
  			   }));
31b7f2792   Kload   Upgrade to ownclo...
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
  		$access->expects($this->any())
  			   ->method('getFilterPartForUserSearch')
  			   ->will($this->returnCallback(function($search) {
  					return $search;
  			   }));
  
  		$access->expects($this->any())
  			   ->method('combineFilterWithAnd')
  			   ->will($this->returnCallback(function($param) {
  					return $param[1];
  			   }));
  
  		$access->expects($this->any())
  			   ->method('fetchListOfUsers')
  			   ->will($this->returnCallback(function($search, $a, $l, $o) {
  					$users = array('gunslinger', 'newyorker', 'ladyofshadows');
  					if(empty($search)) {
  						$result = $users;
  					} else {
  						$result = array();
  						foreach($users as $user) {
  							if(stripos($user,  $search) !== false) {
  								$result[] = $user;
  							}
  						}
  					}
  					if(!is_null($l) || !is_null($o)) {
  						$result = array_slice($result, $o, $l);
  					}
  					return $result;
  			   }));
  
  		$access->expects($this->any())
  			   ->method('ownCloudUserNames')
  			   ->will($this->returnArgument(0));
  	}
a293d369c   Kload   Update sources to...
255
  	public function testGetUsersNoParam() {
31b7f2792   Kload   Upgrade to ownclo...
256
257
258
259
260
261
  		$access = $this->getAccessMock();
  		$this->prepareAccessForGetUsers($access);
  		$backend = new UserLDAP($access);
  
  		$result = $backend->getUsers();
  		$this->assertEquals(3, count($result));
a293d369c   Kload   Update sources to...
262
263
264
265
266
267
  	}
  
  	public function testGetUsersLimitOffset() {
  		$access = $this->getAccessMock();
  		$this->prepareAccessForGetUsers($access);
  		$backend = new UserLDAP($access);
31b7f2792   Kload   Upgrade to ownclo...
268
269
270
  
  		$result = $backend->getUsers('', 1, 2);
  		$this->assertEquals(1, count($result));
a293d369c   Kload   Update sources to...
271
272
273
274
275
276
  	}
  
  	public function testGetUsersLimitOffset2() {
  		$access = $this->getAccessMock();
  		$this->prepareAccessForGetUsers($access);
  		$backend = new UserLDAP($access);
31b7f2792   Kload   Upgrade to ownclo...
277
278
279
  
  		$result = $backend->getUsers('', 2, 1);
  		$this->assertEquals(2, count($result));
a293d369c   Kload   Update sources to...
280
281
282
283
284
285
  	}
  
  	public function testGetUsersSearchWithResult() {
  		$access = $this->getAccessMock();
  		$this->prepareAccessForGetUsers($access);
  		$backend = new UserLDAP($access);
31b7f2792   Kload   Upgrade to ownclo...
286
287
288
  
  		$result = $backend->getUsers('yo');
  		$this->assertEquals(2, count($result));
a293d369c   Kload   Update sources to...
289
290
291
292
293
294
  	}
  
  	public function testGetUsersSearchEmptyResult() {
  		$access = $this->getAccessMock();
  		$this->prepareAccessForGetUsers($access);
  		$backend = new UserLDAP($access);
31b7f2792   Kload   Upgrade to ownclo...
295
296
297
298
  
  		$result = $backend->getUsers('nix');
  		$this->assertEquals(0, count($result));
  	}
a293d369c   Kload   Update sources to...
299
  	public function testGetUsersViaAPINoParam() {
31b7f2792   Kload   Upgrade to ownclo...
300
301
302
303
304
305
306
  		$access = $this->getAccessMock();
  		$this->prepareAccessForGetUsers($access);
  		$backend = new UserLDAP($access);
  		\OC_User::useBackend($backend);
  
  		$result = \OCP\User::getUsers();
  		$this->assertEquals(3, count($result));
a293d369c   Kload   Update sources to...
307
308
309
310
311
312
313
  	}
  
  	public function testGetUsersViaAPILimitOffset() {
  		$access = $this->getAccessMock();
  		$this->prepareAccessForGetUsers($access);
  		$backend = new UserLDAP($access);
  		\OC_User::useBackend($backend);
31b7f2792   Kload   Upgrade to ownclo...
314
315
316
  
  		$result = \OCP\User::getUsers('', 1, 2);
  		$this->assertEquals(1, count($result));
a293d369c   Kload   Update sources to...
317
318
319
320
321
322
323
  	}
  
  	public function testGetUsersViaAPILimitOffset2() {
  		$access = $this->getAccessMock();
  		$this->prepareAccessForGetUsers($access);
  		$backend = new UserLDAP($access);
  		\OC_User::useBackend($backend);
31b7f2792   Kload   Upgrade to ownclo...
324
325
326
  
  		$result = \OCP\User::getUsers('', 2, 1);
  		$this->assertEquals(2, count($result));
a293d369c   Kload   Update sources to...
327
328
329
330
331
332
333
  	}
  
  	public function testGetUsersViaAPISearchWithResult() {
  		$access = $this->getAccessMock();
  		$this->prepareAccessForGetUsers($access);
  		$backend = new UserLDAP($access);
  		\OC_User::useBackend($backend);
31b7f2792   Kload   Upgrade to ownclo...
334
335
336
  
  		$result = \OCP\User::getUsers('yo');
  		$this->assertEquals(2, count($result));
a293d369c   Kload   Update sources to...
337
338
339
340
341
342
343
  	}
  
  	public function testGetUsersViaAPISearchEmptyResult() {
  		$access = $this->getAccessMock();
  		$this->prepareAccessForGetUsers($access);
  		$backend = new UserLDAP($access);
  		\OC_User::useBackend($backend);
31b7f2792   Kload   Upgrade to ownclo...
344
345
346
347
348
349
350
351
352
353
354
355
356
  
  		$result = \OCP\User::getUsers('nix');
  		$this->assertEquals(0, count($result));
  	}
  
  	public function testUserExists() {
  		$access = $this->getAccessMock();
  		$backend = new UserLDAP($access);
  		$this->prepareMockForUserExists($access);
  
  		$access->expects($this->any())
  			   ->method('readAttribute')
  			   ->will($this->returnCallback(function($dn) {
6d9380f96   Cédric Dupont   Update sources OC...
357
  					if($dn === 'dnOfRoland,dc=test') {
31b7f2792   Kload   Upgrade to ownclo...
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
  						return array();
  					}
  					return false;
  			   }));
  
  		//test for existing user
  		$result = $backend->userExists('gunslinger');
  		$this->assertTrue($result);
  
  		//test for deleted user
  		$result = $backend->userExists('formerUser');
  		$this->assertFalse($result);
  
  		//test for never-existing user
  		$result = $backend->userExists('mallory');
  		$this->assertFalse($result);
  	}
  
  	public function testUserExistsPublicAPI() {
  		$access = $this->getAccessMock();
  		$backend = new UserLDAP($access);
  		$this->prepareMockForUserExists($access);
  		\OC_User::useBackend($backend);
  
  		$access->expects($this->any())
  			   ->method('readAttribute')
  			   ->will($this->returnCallback(function($dn) {
6d9380f96   Cédric Dupont   Update sources OC...
385
  					if($dn === 'dnOfRoland,dc=test') {
31b7f2792   Kload   Upgrade to ownclo...
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
  						return array();
  					}
  					return false;
  			   }));
  
  		//test for existing user
  		$result = \OCP\User::userExists('gunslinger');
  		$this->assertTrue($result);
  
  		//test for deleted user
  		$result = \OCP\User::userExists('formerUser');
  		$this->assertFalse($result);
  
  		//test for never-existing user
  		$result = \OCP\User::userExists('mallory');
  		$this->assertFalse($result);
  	}
  
  	public function testDeleteUser() {
  		$access = $this->getAccessMock();
  		$backend = new UserLDAP($access);
  
  		//we do not support deleting users at all
  		$result = $backend->deleteUser('gunslinger');
  		$this->assertFalse($result);
  	}
  
  	public function testGetHome() {
  		$access = $this->getAccessMock();
  		$backend = new UserLDAP($access);
  		$this->prepareMockForUserExists($access);
  
  		$access->connection->expects($this->any())
  			   ->method('__get')
  			   ->will($this->returnCallback(function($name) {
  					if($name === 'homeFolderNamingRule') {
  						return 'attr:testAttribute';
  					}
  					return null;
  			   }));
  
  		$access->expects($this->any())
  			   ->method('readAttribute')
  			   ->will($this->returnCallback(function($dn, $attr) {
  					switch ($dn) {
6d9380f96   Cédric Dupont   Update sources OC...
431
  						case 'dnOfRoland,dc=test':
31b7f2792   Kload   Upgrade to ownclo...
432
433
434
435
436
  							if($attr === 'testAttribute') {
  								return array('/tmp/rolandshome/');
  							}
  							return array();
  							break;
6d9380f96   Cédric Dupont   Update sources OC...
437
  						case 'dnOfLadyOfShadows,dc=test':
31b7f2792   Kload   Upgrade to ownclo...
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
  							if($attr === 'testAttribute') {
  								return array('susannah/');
  							}
  							return array();
  							break;
  						default:
  							return false;
  				   }
  			   }));
  
  		//absolut path
  		$result = $backend->getHome('gunslinger');
  		$this->assertEquals('/tmp/rolandshome/', $result);
  
  		//datadir-relativ path
  		$result = $backend->getHome('ladyofshadows');
  		$datadir = \OCP\Config::getSystemValue('datadirectory',
  											   \OC::$SERVERROOT.'/data');
  		$this->assertEquals($datadir.'/susannah/', $result);
  
  		//no path at all – triggers OC default behaviour
  		$result = $backend->getHome('newyorker');
  		$this->assertFalse($result);
  	}
  
  	private function prepareAccessForGetDisplayName(&$access) {
  		$access->connection->expects($this->any())
  			   ->method('__get')
  			   ->will($this->returnCallback(function($name) {
  					if($name === 'ldapUserDisplayName') {
  						return 'displayname';
  					}
  					return null;
  			   }));
  
  		$access->expects($this->any())
  			   ->method('readAttribute')
  			   ->will($this->returnCallback(function($dn, $attr) {
  					switch ($dn) {
6d9380f96   Cédric Dupont   Update sources OC...
477
  						case 'dnOfRoland,dc=test':
31b7f2792   Kload   Upgrade to ownclo...
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
  							if($attr === 'displayname') {
  								return array('Roland Deschain');
  							}
  							return array();
  							break;
  
  						default:
  							return false;
  				   }
  			   }));
  	}
  
  	public function testGetDisplayName() {
  		$access = $this->getAccessMock();
  		$this->prepareAccessForGetDisplayName($access);
  		$backend = new UserLDAP($access);
  		$this->prepareMockForUserExists($access);
  
  		//with displayName
  		$result = $backend->getDisplayName('gunslinger');
  		$this->assertEquals('Roland Deschain', $result);
  
  		//empty displayname retrieved
  		$result = $backend->getDisplayName('newyorker');
  		$this->assertEquals(null, $result);
  	}
  
  	public function testGetDisplayNamePublicAPI() {
  		$access = $this->getAccessMock();
  		$this->prepareAccessForGetDisplayName($access);
  		$backend = new UserLDAP($access);
  		$this->prepareMockForUserExists($access);
  		\OC_User::useBackend($backend);
  
  		//with displayName
  		$result = \OCP\User::getDisplayName('gunslinger');
  		$this->assertEquals('Roland Deschain', $result);
  
  		//empty displayname retrieved
  		$result = \OCP\User::getDisplayName('newyorker');
  		$this->assertEquals('newyorker', $result);
  	}
  
  	//no test for getDisplayNames, because it just invokes getUsers and
  	//getDisplayName
a293d369c   Kload   Update sources to...
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
  
  	public function testCountUsers() {
  		$access = $this->getAccessMock();
  
  		$access->connection->expects($this->once())
  			   ->method('__get')
  			   ->will($this->returnCallback(function($name) {
  					if($name === 'ldapLoginFilter') {
  						return 'uid=%uid';
  					}
  					return null;
  			   }));
  
  		$access->expects($this->once())
  			   ->method('countUsers')
  			   ->will($this->returnCallback(function($filter, $a, $b, $c) {
  				   if($filter !== 'uid=*') {
  					   return false;
  				   }
  				   return 5;
  			   }));
  
  		$backend = new UserLDAP($access);
  
  		$result = $backend->countUsers();
  		$this->assertEquals(5, $result);
  	}
  
  	public function testCountUsersFailing() {
  		$access = $this->getAccessMock();
  
  		$access->connection->expects($this->once())
  			   ->method('__get')
  			   ->will($this->returnCallback(function($name) {
  					if($name === 'ldapLoginFilter') {
  						return 'invalidFilter';
  					}
  					return null;
  			   }));
  
  		$access->expects($this->once())
  			   ->method('countUsers')
  			   ->will($this->returnCallback(function($filter, $a, $b, $c) {
  				   if($filter !== 'uid=*') {
  					   return false;
  				   }
  				   return 5;
  			   }));
  
  		$backend = new UserLDAP($access);
  
  		$result = $backend->countUsers();
  		$this->assertFalse($result);
  	}
6d9380f96   Cédric Dupont   Update sources OC...
577
  }