IntegrationTestPaging.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. namespace OCA\User_LDAP\Tests\Integration\Lib;
  27. use OCA\User_LDAP\Mapping\UserMapping;
  28. use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest;
  29. use OCA\User_LDAP\User_LDAP;
  30. use OCA\User_LDAP\UserPluginManager;
  31. require_once __DIR__ . '/../Bootstrap.php';
  32. class IntegrationTestPaging extends AbstractIntegrationTest {
  33. /** @var UserMapping */
  34. protected $mapping;
  35. /** @var User_LDAP */
  36. protected $backend;
  37. /** @var int */
  38. protected $pagingSize = 2;
  39. /**
  40. * prepares the LDAP environment and sets up a test configuration for
  41. * the LDAP backend.
  42. */
  43. public function init() {
  44. require(__DIR__ . '/../setup-scripts/createExplicitUsers.php');
  45. parent::init();
  46. $this->backend = new User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager(), \OC::$server->getUserSession(), \OC::$server->query(UserPluginManager::class));
  47. }
  48. public function initConnection() {
  49. parent::initConnection();
  50. $this->connection->setConfiguration([
  51. 'ldapPagingSize' => $this->pagingSize
  52. ]);
  53. }
  54. /**
  55. * fetch first three, afterwards all users
  56. *
  57. * @return bool
  58. */
  59. protected function case1() {
  60. $filter = 'objectclass=inetorgperson';
  61. $attributes = ['cn', 'dn'];
  62. $result = $this->access->searchUsers($filter, $attributes, 4);
  63. // beware, under circumstances, the result set can be larger then
  64. // the specified limit! In this case, if we specify a limit of 3,
  65. // the result will be 4, because the highest possible paging size
  66. // is 2 (as configured).
  67. // But also with more than one search base, the limit can be outpaced.
  68. if (count($result) !== 4) {
  69. return false;
  70. }
  71. $result = $this->access->searchUsers($filter, $attributes);
  72. if (count($result) !== 7) {
  73. return false;
  74. }
  75. return true;
  76. }
  77. }
  78. /** @var string $host */
  79. /** @var int $port */
  80. /** @var string $adn */
  81. /** @var string $apwd */
  82. /** @var string $bdn */
  83. $test = new IntegrationTestPaging($host, $port, $adn, $apwd, $bdn);
  84. $test->init();
  85. $test->run();