User_LDAP plugins: smaller fixes

Signed-off-by: Vinicius Cubas Brand <viniciuscb@gmail.com>
This commit is contained in:
Vinicius Cubas Brand 2017-11-02 20:19:03 -02:00
parent 10ca793452
commit fa565750d1
14 changed files with 134 additions and 63 deletions

View file

@ -24,9 +24,13 @@ return array(
'OCA\\User_LDAP\\Exceptions\\ConstraintViolationException' => $baseDir . '/../lib/Exceptions/ConstraintViolationException.php',
'OCA\\User_LDAP\\Exceptions\\NotOnLDAP' => $baseDir . '/../lib/Exceptions/NotOnLDAP.php',
'OCA\\User_LDAP\\FilesystemHelper' => $baseDir . '/../lib/FilesystemHelper.php',
'OCA\\User_LDAP\\GroupPluginManager' => $baseDir . '/../lib/GroupPluginManager.php',
'OCA\\User_LDAP\\Group_LDAP' => $baseDir . '/../lib/Group_LDAP.php',
'OCA\\User_LDAP\\Group_Proxy' => $baseDir . '/../lib/Group_Proxy.php',
'OCA\\User_LDAP\\Helper' => $baseDir . '/../lib/Helper.php',
'OCA\\User_LDAP\\IGroupLDAP' => $baseDir . '/../lib/IGroupLDAP.php',
'OCA\\User_LDAP\\ILDAPGroupPlugin' => $baseDir . '/../lib/ILDAPGroupPlugin.php',
'OCA\\User_LDAP\\ILDAPUserPlugin' => $baseDir . '/../lib/ILDAPUserPlugin.php',
'OCA\\User_LDAP\\ILDAPWrapper' => $baseDir . '/../lib/ILDAPWrapper.php',
'OCA\\User_LDAP\\IUserLDAP' => $baseDir . '/../lib/IUserLDAP.php',
'OCA\\User_LDAP\\Jobs\\CleanUp' => $baseDir . '/../lib/Jobs/CleanUp.php',
@ -47,6 +51,7 @@ return array(
'OCA\\User_LDAP\\Proxy' => $baseDir . '/../lib/Proxy.php',
'OCA\\User_LDAP\\Settings\\Admin' => $baseDir . '/../lib/Settings/Admin.php',
'OCA\\User_LDAP\\Settings\\Section' => $baseDir . '/../lib/Settings/Section.php',
'OCA\\User_LDAP\\UserPluginManager' => $baseDir . '/../lib/UserPluginManager.php',
'OCA\\User_LDAP\\User\\DeletedUsersIndex' => $baseDir . '/../lib/User/DeletedUsersIndex.php',
'OCA\\User_LDAP\\User\\IUserTools' => $baseDir . '/../lib/User/IUserTools.php',
'OCA\\User_LDAP\\User\\Manager' => $baseDir . '/../lib/User/Manager.php',

View file

@ -39,9 +39,13 @@ class ComposerStaticInitUser_LDAP
'OCA\\User_LDAP\\Exceptions\\ConstraintViolationException' => __DIR__ . '/..' . '/../lib/Exceptions/ConstraintViolationException.php',
'OCA\\User_LDAP\\Exceptions\\NotOnLDAP' => __DIR__ . '/..' . '/../lib/Exceptions/NotOnLDAP.php',
'OCA\\User_LDAP\\FilesystemHelper' => __DIR__ . '/..' . '/../lib/FilesystemHelper.php',
'OCA\\User_LDAP\\GroupPluginManager' => __DIR__ . '/..' . '/../lib/GroupPluginManager.php',
'OCA\\User_LDAP\\Group_LDAP' => __DIR__ . '/..' . '/../lib/Group_LDAP.php',
'OCA\\User_LDAP\\Group_Proxy' => __DIR__ . '/..' . '/../lib/Group_Proxy.php',
'OCA\\User_LDAP\\Helper' => __DIR__ . '/..' . '/../lib/Helper.php',
'OCA\\User_LDAP\\IGroupLDAP' => __DIR__ . '/..' . '/../lib/IGroupLDAP.php',
'OCA\\User_LDAP\\ILDAPGroupPlugin' => __DIR__ . '/..' . '/../lib/ILDAPGroupPlugin.php',
'OCA\\User_LDAP\\ILDAPUserPlugin' => __DIR__ . '/..' . '/../lib/ILDAPUserPlugin.php',
'OCA\\User_LDAP\\ILDAPWrapper' => __DIR__ . '/..' . '/../lib/ILDAPWrapper.php',
'OCA\\User_LDAP\\IUserLDAP' => __DIR__ . '/..' . '/../lib/IUserLDAP.php',
'OCA\\User_LDAP\\Jobs\\CleanUp' => __DIR__ . '/..' . '/../lib/Jobs/CleanUp.php',
@ -62,6 +66,7 @@ class ComposerStaticInitUser_LDAP
'OCA\\User_LDAP\\Proxy' => __DIR__ . '/..' . '/../lib/Proxy.php',
'OCA\\User_LDAP\\Settings\\Admin' => __DIR__ . '/..' . '/../lib/Settings/Admin.php',
'OCA\\User_LDAP\\Settings\\Section' => __DIR__ . '/..' . '/../lib/Settings/Section.php',
'OCA\\User_LDAP\\UserPluginManager' => __DIR__ . '/..' . '/../lib/UserPluginManager.php',
'OCA\\User_LDAP\\User\\DeletedUsersIndex' => __DIR__ . '/..' . '/../lib/User/DeletedUsersIndex.php',
'OCA\\User_LDAP\\User\\IUserTools' => __DIR__ . '/..' . '/../lib/User/IUserTools.php',
'OCA\\User_LDAP\\User\\Manager' => __DIR__ . '/..' . '/../lib/User/Manager.php',

View file

@ -23,19 +23,19 @@
namespace OCA\User_LDAP;
use OC\Group\Backend;
use OCP\GroupInterface;
class GroupPluginManager {
private $respondToActions = 0;
private $which = array(
Backend::CREATE_GROUP => null,
Backend::DELETE_GROUP => null,
Backend::ADD_TO_GROUP => null,
Backend::REMOVE_FROM_GROUP => null,
Backend::COUNT_USERS => null,
Backend::GROUP_DETAILS => null
GroupInterface::CREATE_GROUP => null,
GroupInterface::DELETE_GROUP => null,
GroupInterface::ADD_TO_GROUP => null,
GroupInterface::REMOVE_FROM_GROUP => null,
GroupInterface::COUNT_USERS => null,
GroupInterface::GROUP_DETAILS => null
);
/**
@ -63,7 +63,7 @@ class GroupPluginManager {
/**
* Signal if there is a registered plugin that implements some given actions
* @param int $action Actions defined in \OC\Group\Backend, like Backend::REMOVE_FROM_GROUP
* @param int $actions Actions defined in \OCP\GroupInterface, like GroupInterface::REMOVE_FROM_GROUP
* @return bool
*/
public function implementsActions($actions) {
@ -77,7 +77,7 @@ class GroupPluginManager {
* @throws \Exception
*/
public function createGroup($gid) {
$plugin = $this->which[Backend::CREATE_GROUP];
$plugin = $this->which[GroupInterface::CREATE_GROUP];
if ($plugin) {
return $plugin->createGroup($gid);
@ -92,7 +92,7 @@ class GroupPluginManager {
* @throws \Exception
*/
public function deleteGroup($gid) {
$plugin = $this->which[Backend::DELETE_GROUP];
$plugin = $this->which[GroupInterface::DELETE_GROUP];
if ($plugin) {
return $plugin->deleteGroup($gid);
@ -110,7 +110,7 @@ class GroupPluginManager {
* Adds a user to a group.
*/
public function addToGroup($uid, $gid) {
$plugin = $this->which[Backend::ADD_TO_GROUP];
$plugin = $this->which[GroupInterface::ADD_TO_GROUP];
if ($plugin) {
return $plugin->addToGroup($uid, $gid);
@ -128,7 +128,7 @@ class GroupPluginManager {
* removes the user from a group.
*/
public function removeFromGroup($uid, $gid) {
$plugin = $this->which[Backend::REMOVE_FROM_GROUP];
$plugin = $this->which[GroupInterface::REMOVE_FROM_GROUP];
if ($plugin) {
return $plugin->removeFromGroup($uid, $gid);
@ -144,7 +144,7 @@ class GroupPluginManager {
* @throws \Exception
*/
public function countUsersInGroup($gid, $search = '') {
$plugin = $this->which[Backend::COUNT_USERS];
$plugin = $this->which[GroupInterface::COUNT_USERS];
if ($plugin) {
return $plugin->countUsersInGroup($gid,$search);
@ -159,7 +159,7 @@ class GroupPluginManager {
* @throws \Exception
*/
public function getGroupDetails($gid) {
$plugin = $this->which[Backend::GROUP_DETAILS];
$plugin = $this->which[GroupInterface::GROUP_DETAILS];
if ($plugin) {
return $plugin->getGroupDetails($gid);

View file

@ -39,7 +39,7 @@
namespace OCA\User_LDAP;
use OC\Cache\CappedMemoryCache;
use OC\Group\Backend;
use OCP\GroupInterface;
class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLDAP {
protected $enabled = false;
@ -865,7 +865,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD
* @return int|bool
*/
public function countUsersInGroup($gid, $search = '') {
if ($this->groupPluginManager->implementsActions(Backend::COUNT_USERS)) {
if ($this->groupPluginManager->implementsActions(GroupInterface::COUNT_USERS)) {
return $this->groupPluginManager->countUsersInGroup($gid, $search);
}
@ -1076,10 +1076,10 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD
* @return boolean
*
* Returns the supported actions as int to be
* compared with \OC\Group\Backend::CREATE_GROUP etc.
* compared with GroupInterface::CREATE_GROUP etc.
*/
public function implementsActions($actions) {
return (bool)((\OC\Group\Backend::COUNT_USERS |
return (bool)((GroupInterface::COUNT_USERS |
$this->groupPluginManager->getImplementedActions()) & $actions);
}
@ -1098,7 +1098,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD
* @throws \Exception
*/
public function createGroup($gid) {
if ($this->groupPluginManager->implementsActions(Backend::CREATE_GROUP)) {
if ($this->groupPluginManager->implementsActions(GroupInterface::CREATE_GROUP)) {
if ($dn = $this->groupPluginManager->createGroup($gid)) {
//updates group mapping
$this->access->dn2ocname($dn, $gid, false);
@ -1116,7 +1116,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD
* @throws \Exception
*/
public function deleteGroup($gid) {
if ($this->groupPluginManager->implementsActions(Backend::DELETE_GROUP)) {
if ($this->groupPluginManager->implementsActions(GroupInterface::DELETE_GROUP)) {
if ($ret = $this->groupPluginManager->deleteGroup($gid)) {
#delete group in nextcloud internal db
$this->access->getGroupMapper()->unmap($gid);
@ -1135,9 +1135,9 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD
* @throws \Exception
*/
public function addToGroup($uid, $gid) {
if ($this->groupPluginManager->implementsActions(Backend::ADD_TO_GROUP)) {
if ($this->groupPluginManager->implementsActions(GroupInterface::ADD_TO_GROUP)) {
if ($ret = $this->groupPluginManager->addToGroup($uid, $gid)) {
#$this->access->connection->clearCache();
$this->access->connection->clearCache();
}
return $ret;
}
@ -1152,9 +1152,9 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD
* @throws \Exception
*/
public function removeFromGroup($uid, $gid) {
if ($this->groupPluginManager->implementsActions(Backend::REMOVE_FROM_GROUP)) {
if ($this->groupPluginManager->implementsActions(GroupInterface::REMOVE_FROM_GROUP)) {
if ($ret = $this->groupPluginManager->removeFromGroup($uid, $gid)) {
#$this->access->connection->clearCache();
$this->access->connection->clearCache();
}
return $ret;
}
@ -1168,7 +1168,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD
* @throws \Exception
*/
public function getGroupDetails($gid) {
if ($this->groupPluginManager->implementsActions(Backend::GROUP_DETAILS)) {
if ($this->groupPluginManager->implementsActions(GroupInterface::GROUP_DETAILS)) {
return $this->groupPluginManager->getGroupDetails($gid);
}
throw new \Exception('Could not get group details in LDAP backend.');

View file

@ -245,7 +245,7 @@ class Group_Proxy extends Proxy implements \OCP\GroupInterface, IGroupLDAP {
* @return boolean
*
* Returns the supported actions as int to be
* compared with \OC\Group\Backend::CREATE_GROUP etc.
* compared with \OCP\GroupInterface::CREATE_GROUP etc.
*/
public function implementsActions($actions) {
//it's the same across all our user backends obviously

View file

@ -83,6 +83,4 @@ interface ILDAPGroupPlugin {
*/
public function getGroupDetails($gid);
}

View file

@ -46,6 +46,8 @@ class LDAPProvider implements ILDAPProvider, IDeletionFlagSupport {
/**
* Create new LDAPProvider
* @param \OCP\IServerContainer $serverContainer
* @param Helper $helper
* @param DeletedUsersIndex $deletedUsersIndex
* @throws \Exception if user_ldap app was not enabled
*/
public function __construct(IServerContainer $serverContainer, Helper $helper, DeletedUsersIndex $deletedUsersIndex) {

View file

@ -51,26 +51,28 @@ class UserPluginManager {
/**
* Registers a group plugin that may implement some actions, overriding User_LDAP's user actions.
* @param ILDAPGroupPlugin $plugin
*
* @param ILDAPUserPlugin $plugin
*/
public function register(ILDAPUserPlugin $plugin) {
$respondToActions = $plugin->respondToActions();
$this->respondToActions |= $respondToActions;
foreach($this->which as $action => $v) {
if ((bool)($respondToActions & $action)) {
if (is_int($action) && (bool)($respondToActions & $action)) {
$this->which[$action] = $plugin;
\OC::$server->getLogger()->debug("Registered action ".$action." to plugin ".get_class($plugin), ['app' => 'user_ldap']);
}
}
if (method_exists($plugin,'deleteUser')) {
$this->which['deleteUser'] = $plugin;
\OC::$server->getLogger()->debug("Registered action deleteUser to plugin ".get_class($plugin), ['app' => 'user_ldap']);
}
}
/**
* Signal if there is a registered plugin that implements some given actions
* @param int $action Actions defined in \OC\User\Backend, like Backend::CREATE_USER
* @param int $actions Actions defined in \OC\User\Backend, like Backend::CREATE_USER
* @return bool
*/
public function implementsActions($actions) {
@ -80,7 +82,7 @@ class UserPluginManager {
/**
* Create a new user in LDAP Backend
*
* @param string $uid The username of the user to create
* @param string $username The username of the user to create
* @param string $password The password of the new user
* @return bool
* @throws \Exception

View file

@ -23,7 +23,7 @@
namespace OCA\User_LDAP\Tests;
use OC\Group\Backend;
use OCP\GroupInterface;
use OCA\User_LDAP\GroupPluginManager;
class GroupLDAPPluginTest extends \Test\TestCase {
@ -44,7 +44,7 @@ class GroupLDAPPluginTest extends \Test\TestCase {
$plugin->expects($this->any())
->method('respondToActions')
->willReturn(Backend::CREATE_GROUP);
->willReturn(GroupInterface::CREATE_GROUP);
$plugin2 = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPGroupPluginDummy')
->setMethods(['respondToActions'])
@ -52,14 +52,14 @@ class GroupLDAPPluginTest extends \Test\TestCase {
$plugin2->expects($this->any())
->method('respondToActions')
->willReturn(Backend::ADD_TO_GROUP);
->willReturn(GroupInterface::ADD_TO_GROUP);
$pluginManager->register($plugin);
$pluginManager->register($plugin2);
$this->assertEquals($pluginManager->getImplementedActions(), Backend::CREATE_GROUP | Backend::ADD_TO_GROUP);
$this->assertTrue($pluginManager->implementsActions(Backend::CREATE_GROUP));
$this->assertTrue($pluginManager->implementsActions(Backend::ADD_TO_GROUP));
$this->assertEquals($pluginManager->getImplementedActions(), GroupInterface::CREATE_GROUP | GroupInterface::ADD_TO_GROUP);
$this->assertTrue($pluginManager->implementsActions(GroupInterface::CREATE_GROUP));
$this->assertTrue($pluginManager->implementsActions(GroupInterface::ADD_TO_GROUP));
}
public function testCreateGroup() {
@ -71,7 +71,7 @@ class GroupLDAPPluginTest extends \Test\TestCase {
$plugin->expects($this->any())
->method('respondToActions')
->willReturn(Backend::CREATE_GROUP);
->willReturn(GroupInterface::CREATE_GROUP);
$plugin->expects($this->once())
->method('createGroup')
@ -101,7 +101,7 @@ class GroupLDAPPluginTest extends \Test\TestCase {
$plugin->expects($this->any())
->method('respondToActions')
->willReturn(Backend::DELETE_GROUP);
->willReturn(GroupInterface::DELETE_GROUP);
$plugin->expects($this->once())
->method('deleteGroup')
@ -131,7 +131,7 @@ class GroupLDAPPluginTest extends \Test\TestCase {
$plugin->expects($this->any())
->method('respondToActions')
->willReturn(Backend::ADD_TO_GROUP);
->willReturn(GroupInterface::ADD_TO_GROUP);
$plugin->expects($this->once())
->method('addToGroup')
@ -162,7 +162,7 @@ class GroupLDAPPluginTest extends \Test\TestCase {
$plugin->expects($this->any())
->method('respondToActions')
->willReturn(Backend::REMOVE_FROM_GROUP);
->willReturn(GroupInterface::REMOVE_FROM_GROUP);
$plugin->expects($this->once())
->method('removeFromGroup')
@ -193,7 +193,7 @@ class GroupLDAPPluginTest extends \Test\TestCase {
$plugin->expects($this->any())
->method('respondToActions')
->willReturn(Backend::COUNT_USERS);
->willReturn(GroupInterface::COUNT_USERS);
$plugin->expects($this->once())
->method('countUsersInGroup')
@ -224,7 +224,7 @@ class GroupLDAPPluginTest extends \Test\TestCase {
$plugin->expects($this->any())
->method('respondToActions')
->willReturn(Backend::GROUP_DETAILS);
->willReturn(GroupInterface::GROUP_DETAILS);
$plugin->expects($this->once())
->method('getGroupDetails')

View file

@ -29,7 +29,7 @@
namespace OCA\User_LDAP\Tests;
use OC\Group\Backend;
use OCP\GroupInterface;
use OCA\User_LDAP\Group_LDAP as GroupLDAP;
use OCA\User_LDAP\ILDAPWrapper;
@ -157,7 +157,7 @@ class Group_LDAPTest extends \Test\TestCase {
$pluginManager->expects($this->once())
->method('implementsActions')
->with(Backend::COUNT_USERS)
->with(GroupInterface::COUNT_USERS)
->willReturn(true);
$pluginManager->expects($this->once())
@ -727,7 +727,7 @@ class Group_LDAPTest extends \Test\TestCase {
$pluginManager->expects($this->once())
->method('implementsActions')
->with(Backend::CREATE_GROUP)
->with(GroupInterface::CREATE_GROUP)
->willReturn(true);
$pluginManager->expects($this->once())
@ -753,7 +753,7 @@ class Group_LDAPTest extends \Test\TestCase {
$pluginManager->expects($this->once())
->method('implementsActions')
->with(Backend::CREATE_GROUP)
->with(GroupInterface::CREATE_GROUP)
->willReturn(false);
$ldap = new GroupLDAP(
@ -771,7 +771,7 @@ class Group_LDAPTest extends \Test\TestCase {
$pluginManager->expects($this->once())
->method('implementsActions')
->with(Backend::DELETE_GROUP)
->with(GroupInterface::DELETE_GROUP)
->willReturn(true);
$pluginManager->expects($this->once())
@ -808,7 +808,7 @@ class Group_LDAPTest extends \Test\TestCase {
$pluginManager->expects($this->once())
->method('implementsActions')
->with(Backend::DELETE_GROUP)
->with(GroupInterface::DELETE_GROUP)
->willReturn(false);
$ldap = new GroupLDAP(
@ -826,7 +826,7 @@ class Group_LDAPTest extends \Test\TestCase {
$pluginManager->expects($this->once())
->method('implementsActions')
->with(Backend::ADD_TO_GROUP)
->with(GroupInterface::ADD_TO_GROUP)
->willReturn(true);
$pluginManager->expects($this->once())
@ -852,7 +852,7 @@ class Group_LDAPTest extends \Test\TestCase {
$pluginManager->expects($this->once())
->method('implementsActions')
->with(Backend::ADD_TO_GROUP)
->with(GroupInterface::ADD_TO_GROUP)
->willReturn(false);
$ldap = new GroupLDAP(
@ -870,7 +870,7 @@ class Group_LDAPTest extends \Test\TestCase {
$pluginManager->expects($this->once())
->method('implementsActions')
->with(Backend::REMOVE_FROM_GROUP)
->with(GroupInterface::REMOVE_FROM_GROUP)
->willReturn(true);
$pluginManager->expects($this->once())
@ -896,7 +896,7 @@ class Group_LDAPTest extends \Test\TestCase {
$pluginManager->expects($this->once())
->method('implementsActions')
->with(Backend::REMOVE_FROM_GROUP)
->with(GroupInterface::REMOVE_FROM_GROUP)
->willReturn(false);
$ldap = new GroupLDAP(
@ -914,7 +914,7 @@ class Group_LDAPTest extends \Test\TestCase {
$pluginManager->expects($this->once())
->method('implementsActions')
->with(Backend::GROUP_DETAILS)
->with(GroupInterface::GROUP_DETAILS)
->willReturn(true);
$pluginManager->expects($this->once())
@ -940,7 +940,7 @@ class Group_LDAPTest extends \Test\TestCase {
$pluginManager->expects($this->once())
->method('implementsActions')
->with(Backend::GROUP_DETAILS)
->with(GroupInterface::GROUP_DETAILS)
->willReturn(false);
$ldap = new GroupLDAP(

View file

@ -68,6 +68,13 @@ abstract class AbstractIntegrationTest {
* the LDAP backend.
*/
public function init() {
\OC::$server->registerService('LDAPUserPluginManager', function() {
return new \OCA\User_LDAP\UserPluginManager();
});
\OC::$server->registerService('LDAPGroupPluginManager', function() {
return new \OCA\User_LDAP\GroupPluginManager();
});
$this->initLDAPWrapper();
$this->initConnection();
$this->initUserManager();

View file

@ -46,7 +46,7 @@ class IntegrationTestUserCleanUp extends AbstractIntegrationTest {
$this->mapping->clear();
$this->access->setUserMapper($this->mapping);
$userBackend = new User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager(), \OC::$server->getUserSession());
$userBackend = new User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager(), \OC::$server->getUserSession(), \OC::$server->query('LDAPUserPluginManager'));
\OC_User::useBackend($userBackend);
}

View file

@ -432,6 +432,51 @@ class LDAPProviderTest extends \Test\TestCase {
$this->assertTrue(TRUE);
}
/**
* @expectedException \Exception
* @expectedExceptionMessage Group id not found in LDAP
*/
public function testClearGroupCacheGroupIDNotFound() {
$userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP')
->disableOriginalConstructor()
->getMock();
$groupBackend = $this->getMockBuilder('OCA\User_LDAP\Group_LDAP')
->setMethods(['groupExists'])
->disableOriginalConstructor()
->getMock();
$groupBackend->expects($this->any())->method('groupExists')->willReturn(false);
$server = $this->getServerMock($userBackend, $groupBackend);
$ldapProvider = $this->getLDAPProvider($server);
$ldapProvider->clearGroupCache('nonexisting_group');
}
public function testClearGroupCache() {
$userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP')
->disableOriginalConstructor()
->getMock();
$groupBackend = $this->getMockBuilder('OCA\User_LDAP\Group_LDAP')
->setMethods(['groupExists', 'getLDAPAccess', 'getConnection', 'clearCache'])
->disableOriginalConstructor()
->getMock();
$groupBackend->expects($this->at(0))
->method('groupExists')
->willReturn(true);
$groupBackend->expects($this->at(3))
->method('clearCache')
->willReturn(true);
$groupBackend->expects($this->any())
->method($this->anything())
->willReturnSelf();
$server = $this->getServerMock($userBackend, $groupBackend);
$ldapProvider = $this->getLDAPProvider($server);
$ldapProvider->clearGroupCache('existing_group');
$this->assertTrue(TRUE);
}
public function testDnExists() {
$userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP')
->setMethods(['dn2UserName'])

View file

@ -123,6 +123,13 @@ interface ILDAPProvider {
*/
public function clearCache($uid);
/**
* Clear the cache if a cache is used, otherwise do nothing.
* @param string $gid group id
* @since 13.0.0
*/
public function clearGroupCache($gid);
/**
* Get the LDAP attribute name for the user's display name
* @param string $uid user id