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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
<?php
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\user_ldap\tests\Integration\Lib;
use OCA\User_LDAP\Group_LDAP;
use OCA\User_LDAP\GroupPluginManager;
use OCA\User_LDAP\Mapping\GroupMapping;
use OCA\User_LDAP\Mapping\UserMapping;
use OCA\User_LDAP\Tests\Integration\AbstractIntegrationTest;
use OCA\User_LDAP\User\DeletedUsersIndex;
use OCA\User_LDAP\User_LDAP;
use OCA\User_LDAP\UserPluginManager;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IGroupManager;
use OCP\IUserManager;
use OCP\Server;
use Psr\Log\LoggerInterface;
require_once __DIR__ . '/../Bootstrap.php';
class IntegrationTestAttributeDetection extends AbstractIntegrationTest {
public function init() {
require(__DIR__ . '/../setup-scripts/createExplicitUsers.php');
require(__DIR__ . '/../setup-scripts/createExplicitGroups.php');
parent::init();
$this->connection->setConfiguration(['ldapGroupFilter' => 'objectClass=groupOfNames']);
$this->connection->setConfiguration(['ldapGroupMemberAssocAttr' => 'member']);
$userMapper = new UserMapping(Server::get(IDBConnection::class));
$userMapper->clear();
$this->access->setUserMapper($userMapper);
$groupMapper = new GroupMapping(Server::get(IDBConnection::class));
$groupMapper->clear();
$this->access->setGroupMapper($groupMapper);
$userBackend = new User_LDAP($this->access, Server::get(\OCP\Notification\IManager::class), Server::get(UserPluginManager::class), Server::get(LoggerInterface::class), Server::get(DeletedUsersIndex::class));
$userManager = Server::get(IUserManager::class);
$userManager->clearBackends();
$userManager->registerBackend($userBackend);
$groupBackend = new Group_LDAP($this->access, Server::get(GroupPluginManager::class), Server::get(IConfig::class));
$groupManger = Server::get(IGroupManager::class);
$groupManger->clearBackends();
$groupManger->addBackend($groupBackend);
}
protected function caseNativeUUIDAttributeUsers() {
// trigger importing of users which also triggers UUID attribute detection
Server::get(IUserManager::class)->search('', 5, 0);
return $this->connection->ldapUuidUserAttribute === 'entryuuid';
}
protected function caseNativeUUIDAttributeGroups() {
// essentially the same as 'caseNativeUUIDAttributeUsers', code paths
// are similar, but we take no chances.
// trigger importing of users which also triggers UUID attribute detection
Server::get(IGroupManager::class)->search('', 5, 0);
return $this->connection->ldapUuidGroupAttribute === 'entryuuid';
}
}
/** @var string $host */
/** @var int $port */
/** @var string $adn */
/** @var string $apwd */
/** @var string $bdn */
$test = new IntegrationTestAttributeDetection($host, $port, $adn, $apwd, $bdn);
$test->init();
$test->run();
|