IntegrationTestPaging.php 2.8 KB

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