Cache the user backend info for 300s

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2021-02-02 15:45:34 +01:00 committed by backportbot[bot]
parent 1db95da5d1
commit a745d58133
7 changed files with 107 additions and 39 deletions

View File

@ -35,6 +35,7 @@ use OCA\User_LDAP\Connection;
use OCA\User_LDAP\IGroupLDAP; use OCA\User_LDAP\IGroupLDAP;
use OCA\User_LDAP\IUserLDAP; use OCA\User_LDAP\IUserLDAP;
use OCP\EventDispatcher\IEventDispatcher; use OCP\EventDispatcher\IEventDispatcher;
use OCP\ICacheFactory;
use OCP\IConfig; use OCP\IConfig;
use OCP\IServerContainer; use OCP\IServerContainer;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@ -78,7 +79,8 @@ class LDAPProviderTest extends \Test\TestCase {
->setConstructorArgs([ ->setConstructorArgs([
$this->createMock(IConfig::class), $this->createMock(IConfig::class),
$this->createMock(EventDispatcherInterface::class), $this->createMock(EventDispatcherInterface::class),
$this->createMock(IEventDispatcher::class) $this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class),
]) ])
->getMock(); ->getMock();
$userManager->expects($this->any()) $userManager->expects($this->any())

View File

@ -38,6 +38,8 @@ use OC\HintException;
use OC\Hooks\PublicEmitter; use OC\Hooks\PublicEmitter;
use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\EventDispatcher\IEventDispatcher; use OCP\EventDispatcher\IEventDispatcher;
use OCP\ICache;
use OCP\ICacheFactory;
use OCP\IConfig; use OCP\IConfig;
use OCP\IGroup; use OCP\IGroup;
use OCP\IUser; use OCP\IUser;
@ -84,14 +86,19 @@ class Manager extends PublicEmitter implements IUserManager {
/** @var EventDispatcherInterface */ /** @var EventDispatcherInterface */
private $dispatcher; private $dispatcher;
/** @var ICache */
private $cache;
/** @var IEventDispatcher */ /** @var IEventDispatcher */
private $eventDispatcher; private $eventDispatcher;
public function __construct(IConfig $config, public function __construct(IConfig $config,
EventDispatcherInterface $oldDispatcher, EventDispatcherInterface $oldDispatcher,
ICacheFactory $cacheFactory,
IEventDispatcher $eventDispatcher) { IEventDispatcher $eventDispatcher) {
$this->config = $config; $this->config = $config;
$this->dispatcher = $oldDispatcher; $this->dispatcher = $oldDispatcher;
$this->cache = $cacheFactory->createDistributed('user_backend_map');
$cachedUsers = &$this->cachedUsers; $cachedUsers = &$this->cachedUsers;
$this->listen('\OC\User', 'postDelete', function ($user) use (&$cachedUsers) { $this->listen('\OC\User', 'postDelete', function ($user) use (&$cachedUsers) {
/** @var \OC\User\User $user */ /** @var \OC\User\User $user */
@ -150,11 +157,27 @@ class Manager extends PublicEmitter implements IUserManager {
if (isset($this->cachedUsers[$uid])) { //check the cache first to prevent having to loop over the backends if (isset($this->cachedUsers[$uid])) { //check the cache first to prevent having to loop over the backends
return $this->cachedUsers[$uid]; return $this->cachedUsers[$uid];
} }
foreach ($this->backends as $backend) {
$cachedBackend = $this->cache->get($uid);
if ($cachedBackend !== null && isset($this->backends[$cachedBackend])) {
// Cache has the info of the user backend already, so ask that one directly
$backend = $this->backends[$cachedBackend];
if ($backend->userExists($uid)) { if ($backend->userExists($uid)) {
return $this->getUserObject($uid, $backend); return $this->getUserObject($uid, $backend);
} }
} }
foreach ($this->backends as $i => $backend) {
if ($i === $cachedBackend) {
// Tried that one already
continue;
}
if ($backend->userExists($uid)) {
$this->cache->set($uid, $i, 300);
return $this->getUserObject($uid, $backend);
}
}
return null; return null;
} }

View File

@ -15,6 +15,7 @@ use OC\Log;
use OC\User\Manager; use OC\User\Manager;
use OCP\EventDispatcher\IEventDispatcher; use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Config\ICachedMountInfo; use OCP\Files\Config\ICachedMountInfo;
use OCP\ICacheFactory;
use OCP\IConfig; use OCP\IConfig;
use OCP\IDBConnection; use OCP\IDBConnection;
use OCP\IUserManager; use OCP\IUserManager;
@ -46,7 +47,7 @@ class UserMountCacheTest extends TestCase {
protected function setUp(): void { protected function setUp(): void {
$this->fileIds = []; $this->fileIds = [];
$this->connection = \OC::$server->getDatabaseConnection(); $this->connection = \OC::$server->getDatabaseConnection();
$this->userManager = new Manager($this->createMock(IConfig::class), $this->createMock(EventDispatcherInterface::class), $this->createMock(IEventDispatcher::class)); $this->userManager = new Manager($this->createMock(IConfig::class), $this->createMock(EventDispatcherInterface::class), $this->createMock(ICacheFactory::class), $this->createMock(IEventDispatcher::class));
$userBackend = new Dummy(); $userBackend = new Dummy();
$userBackend->createUser('u1', ''); $userBackend->createUser('u1', '');
$userBackend->createUser('u2', ''); $userBackend->createUser('u2', '');

View File

@ -17,6 +17,7 @@ use OCP\Encryption\Keys\IStorage;
use OCP\EventDispatcher\IEventDispatcher; use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Cache\ICache; use OCP\Files\Cache\ICache;
use OCP\Files\Mount\IMountPoint; use OCP\Files\Mount\IMountPoint;
use OCP\ICacheFactory;
use OCP\IConfig; use OCP\IConfig;
use OCP\ILogger; use OCP\ILogger;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@ -131,7 +132,12 @@ class EncryptionTest extends Storage {
$this->util = $this->getMockBuilder('\OC\Encryption\Util') $this->util = $this->getMockBuilder('\OC\Encryption\Util')
->setMethods(['getUidAndFilename', 'isFile', 'isExcluded']) ->setMethods(['getUidAndFilename', 'isFile', 'isExcluded'])
->setConstructorArgs([new View(), new Manager($this->config, $this->createMock(EventDispatcherInterface::class), $this->createMock(IEventDispatcher::class)), $this->groupManager, $this->config, $this->arrayCache]) ->setConstructorArgs([new View(), new Manager(
$this->config,
$this->createMock(EventDispatcherInterface::class),
$this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class)
), $this->groupManager, $this->config, $this->arrayCache])
->getMock(); ->getMock();
$this->util->expects($this->any()) $this->util->expects($this->any())
->method('getUidAndFilename') ->method('getUidAndFilename')
@ -567,7 +573,12 @@ class EncryptionTest extends Storage {
->setConstructorArgs( ->setConstructorArgs(
[ [
new View(), new View(),
new Manager($this->config, $this->createMock(EventDispatcherInterface::class), $this->createMock(IEventDispatcher::class)), new Manager(
$this->config,
$this->createMock(EventDispatcherInterface::class),
$this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class)
),
$this->groupManager, $this->groupManager,
$this->config, $this->config,
$this->arrayCache $this->arrayCache
@ -635,7 +646,12 @@ class EncryptionTest extends Storage {
->willReturn($exists); ->willReturn($exists);
$util = $this->getMockBuilder('\OC\Encryption\Util') $util = $this->getMockBuilder('\OC\Encryption\Util')
->setConstructorArgs([new View(), new Manager($this->config, $this->createMock(EventDispatcherInterface::class), $this->createMock(IEventDispatcher::class)), $this->groupManager, $this->config, $this->arrayCache]) ->setConstructorArgs([new View(), new Manager(
$this->config,
$this->createMock(EventDispatcherInterface::class),
$this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class)
), $this->groupManager, $this->config, $this->arrayCache])
->getMock(); ->getMock();
$cache = $this->getMockBuilder('\OC\Files\Cache\Cache') $cache = $this->getMockBuilder('\OC\Files\Cache\Cache')

View File

@ -7,6 +7,7 @@ use OC\Files\View;
use OC\Memcache\ArrayCache; use OC\Memcache\ArrayCache;
use OCP\EventDispatcher\IEventDispatcher; use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Cache\ICache; use OCP\Files\Cache\ICache;
use OCP\ICacheFactory;
use OCP\IConfig; use OCP\IConfig;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@ -49,7 +50,12 @@ class EncryptionTest extends \Test\TestCase {
$file->expects($this->any())->method('getAccessList')->willReturn([]); $file->expects($this->any())->method('getAccessList')->willReturn([]);
$util = $this->getMockBuilder('\OC\Encryption\Util') $util = $this->getMockBuilder('\OC\Encryption\Util')
->setMethods(['getUidAndFilename']) ->setMethods(['getUidAndFilename'])
->setConstructorArgs([new View(), new \OC\User\Manager($config, $this->createMock(EventDispatcherInterface::class), $this->createMock(IEventDispatcher::class)), $groupManager, $config, $arrayCache]) ->setConstructorArgs([new View(), new \OC\User\Manager(
$config,
$this->createMock(EventDispatcherInterface::class),
$this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class)
), $groupManager, $config, $arrayCache])
->getMock(); ->getMock();
$util->expects($this->any()) $util->expects($this->any())
->method('getUidAndFilename') ->method('getUidAndFilename')

View File

@ -13,6 +13,8 @@ use OC\AllConfig;
use OC\User\Database; use OC\User\Database;
use OC\User\Manager; use OC\User\Manager;
use OCP\EventDispatcher\IEventDispatcher; use OCP\EventDispatcher\IEventDispatcher;
use OCP\ICache;
use OCP\ICacheFactory;
use OCP\IConfig; use OCP\IConfig;
use OCP\IUser; use OCP\IUser;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@ -33,6 +35,10 @@ class ManagerTest extends TestCase {
private $oldDispatcher; private $oldDispatcher;
/** @var IEventDispatcher */ /** @var IEventDispatcher */
private $eventDispatcher; private $eventDispatcher;
/** @var ICacheFactory */
private $cacheFactory;
/** @var ICache */
private $cache;
protected function setUp(): void { protected function setUp(): void {
parent::setUp(); parent::setUp();
@ -40,11 +46,17 @@ class ManagerTest extends TestCase {
$this->config = $this->createMock(IConfig::class); $this->config = $this->createMock(IConfig::class);
$this->oldDispatcher = $this->createMock(EventDispatcherInterface::class); $this->oldDispatcher = $this->createMock(EventDispatcherInterface::class);
$this->eventDispatcher = $this->createMock(IEventDispatcher::class); $this->eventDispatcher = $this->createMock(IEventDispatcher::class);
$this->cacheFactory = $this->createMock(ICacheFactory::class);
$this->cache = $this->createMock(ICache::class);
$this->cacheFactory->method('createDistributed')
->with('user_backend_map')
->willReturn($this->cache);
} }
public function testGetBackends() { public function testGetBackends() {
$userDummyBackend = $this->createMock(\Test\Util\User\Dummy::class); $userDummyBackend = $this->createMock(\Test\Util\User\Dummy::class);
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$manager->registerBackend($userDummyBackend); $manager->registerBackend($userDummyBackend);
$this->assertEquals([$userDummyBackend], $manager->getBackends()); $this->assertEquals([$userDummyBackend], $manager->getBackends());
$dummyDatabaseBackend = $this->createMock(Database::class); $dummyDatabaseBackend = $this->createMock(Database::class);
@ -63,7 +75,7 @@ class ManagerTest extends TestCase {
->with($this->equalTo('foo')) ->with($this->equalTo('foo'))
->willReturn(true); ->willReturn(true);
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$manager->registerBackend($backend); $manager->registerBackend($backend);
$this->assertTrue($manager->userExists('foo')); $this->assertTrue($manager->userExists('foo'));
@ -79,14 +91,14 @@ class ManagerTest extends TestCase {
->with($this->equalTo('foo')) ->with($this->equalTo('foo'))
->willReturn(false); ->willReturn(false);
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$manager->registerBackend($backend); $manager->registerBackend($backend);
$this->assertFalse($manager->userExists('foo')); $this->assertFalse($manager->userExists('foo'));
} }
public function testUserExistsNoBackends() { public function testUserExistsNoBackends() {
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$this->assertFalse($manager->userExists('foo')); $this->assertFalse($manager->userExists('foo'));
} }
@ -110,7 +122,7 @@ class ManagerTest extends TestCase {
->with($this->equalTo('foo')) ->with($this->equalTo('foo'))
->willReturn(true); ->willReturn(true);
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$manager->registerBackend($backend1); $manager->registerBackend($backend1);
$manager->registerBackend($backend2); $manager->registerBackend($backend2);
@ -134,7 +146,7 @@ class ManagerTest extends TestCase {
$backend2->expects($this->never()) $backend2->expects($this->never())
->method('userExists'); ->method('userExists');
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$manager->registerBackend($backend1); $manager->registerBackend($backend1);
$manager->registerBackend($backend2); $manager->registerBackend($backend2);
@ -161,7 +173,7 @@ class ManagerTest extends TestCase {
} }
}); });
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$manager->registerBackend($backend); $manager->registerBackend($backend);
$user = $manager->checkPassword('foo', 'bar'); $user = $manager->checkPassword('foo', 'bar');
@ -180,7 +192,7 @@ class ManagerTest extends TestCase {
->method('implementsActions') ->method('implementsActions')
->willReturn(false); ->willReturn(false);
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$manager->registerBackend($backend); $manager->registerBackend($backend);
$this->assertFalse($manager->checkPassword('foo', 'bar')); $this->assertFalse($manager->checkPassword('foo', 'bar'));
@ -198,7 +210,7 @@ class ManagerTest extends TestCase {
$backend->expects($this->never()) $backend->expects($this->never())
->method('loginName2UserName'); ->method('loginName2UserName');
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$manager->registerBackend($backend); $manager->registerBackend($backend);
$this->assertEquals('foo', $manager->get('foo')->getUID()); $this->assertEquals('foo', $manager->get('foo')->getUID());
@ -214,7 +226,7 @@ class ManagerTest extends TestCase {
->with($this->equalTo('foo')) ->with($this->equalTo('foo'))
->willReturn(false); ->willReturn(false);
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$manager->registerBackend($backend); $manager->registerBackend($backend);
$this->assertEquals(null, $manager->get('foo')); $this->assertEquals(null, $manager->get('foo'));
@ -232,7 +244,7 @@ class ManagerTest extends TestCase {
$backend->expects($this->never()) $backend->expects($this->never())
->method('loginName2UserName'); ->method('loginName2UserName');
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$manager->registerBackend($backend); $manager->registerBackend($backend);
$this->assertEquals('bLeNdEr', $manager->get('bLeNdEr')->getUID()); $this->assertEquals('bLeNdEr', $manager->get('bLeNdEr')->getUID());
@ -250,7 +262,7 @@ class ManagerTest extends TestCase {
$backend->expects($this->never()) $backend->expects($this->never())
->method('loginName2UserName'); ->method('loginName2UserName');
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$manager->registerBackend($backend); $manager->registerBackend($backend);
$result = $manager->search('fo'); $result = $manager->search('fo');
@ -284,7 +296,7 @@ class ManagerTest extends TestCase {
$backend2->expects($this->never()) $backend2->expects($this->never())
->method('loginName2UserName'); ->method('loginName2UserName');
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$manager->registerBackend($backend1); $manager->registerBackend($backend1);
$manager->registerBackend($backend2); $manager->registerBackend($backend2);
@ -338,7 +350,7 @@ class ManagerTest extends TestCase {
->willReturn(true); ->willReturn(true);
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$manager->registerBackend($backend); $manager->registerBackend($backend);
$this->expectException(\InvalidArgumentException::class, $exception); $this->expectException(\InvalidArgumentException::class, $exception);
@ -365,7 +377,7 @@ class ManagerTest extends TestCase {
$backend->expects($this->never()) $backend->expects($this->never())
->method('loginName2UserName'); ->method('loginName2UserName');
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$manager->registerBackend($backend); $manager->registerBackend($backend);
$user = $manager->createUser('foo', 'bar'); $user = $manager->createUser('foo', 'bar');
@ -392,7 +404,7 @@ class ManagerTest extends TestCase {
->with($this->equalTo('foo')) ->with($this->equalTo('foo'))
->willReturn(true); ->willReturn(true);
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$manager->registerBackend($backend); $manager->registerBackend($backend);
$manager->createUser('foo', 'bar'); $manager->createUser('foo', 'bar');
@ -413,14 +425,14 @@ class ManagerTest extends TestCase {
$backend->expects($this->never()) $backend->expects($this->never())
->method('userExists'); ->method('userExists');
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$manager->registerBackend($backend); $manager->registerBackend($backend);
$this->assertFalse($manager->createUser('foo', 'bar')); $this->assertFalse($manager->createUser('foo', 'bar'));
} }
public function testCreateUserNoBackends() { public function testCreateUserNoBackends() {
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$this->assertFalse($manager->createUser('foo', 'bar')); $this->assertFalse($manager->createUser('foo', 'bar'));
} }
@ -440,7 +452,7 @@ class ManagerTest extends TestCase {
->with('MyUid', 'MyPassword') ->with('MyUid', 'MyPassword')
->willReturn(false); ->willReturn(false);
$manager = new Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$manager->createUserFromBackend('MyUid', 'MyPassword', $backend); $manager->createUserFromBackend('MyUid', 'MyPassword', $backend);
} }
@ -480,7 +492,7 @@ class ManagerTest extends TestCase {
->with($this->equalTo('foo')) ->with($this->equalTo('foo'))
->willReturn(true); ->willReturn(true);
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$manager->registerBackend($backend1); $manager->registerBackend($backend1);
$manager->registerBackend($backend2); $manager->registerBackend($backend2);
@ -488,7 +500,7 @@ class ManagerTest extends TestCase {
} }
public function testCountUsersNoBackend() { public function testCountUsersNoBackend() {
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$result = $manager->countUsers(); $result = $manager->countUsers();
$this->assertTrue(is_array($result)); $this->assertTrue(is_array($result));
@ -513,7 +525,7 @@ class ManagerTest extends TestCase {
->method('getBackendName') ->method('getBackendName')
->willReturn('Mock_Test_Util_User_Dummy'); ->willReturn('Mock_Test_Util_User_Dummy');
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$manager->registerBackend($backend); $manager->registerBackend($backend);
$result = $manager->countUsers(); $result = $manager->countUsers();
@ -554,7 +566,7 @@ class ManagerTest extends TestCase {
->method('getBackendName') ->method('getBackendName')
->willReturn('Mock_Test_Util_User_Dummy'); ->willReturn('Mock_Test_Util_User_Dummy');
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$manager->registerBackend($backend1); $manager->registerBackend($backend1);
$manager->registerBackend($backend2); $manager->registerBackend($backend2);
@ -655,7 +667,7 @@ class ManagerTest extends TestCase {
} }
public function testDeleteUser() { public function testDeleteUser() {
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$backend = new \Test\Util\User\Dummy(); $backend = new \Test\Util\User\Dummy();
$manager->registerBackend($backend); $manager->registerBackend($backend);
@ -689,7 +701,7 @@ class ManagerTest extends TestCase {
->with($this->equalTo('uid2')) ->with($this->equalTo('uid2'))
->willReturn(true); ->willReturn(true);
$manager = new \OC\User\Manager($config, $this->oldDispatcher, $this->eventDispatcher); $manager = new \OC\User\Manager($config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$manager->registerBackend($backend); $manager->registerBackend($backend);
$users = $manager->getByEmail('test@example.com'); $users = $manager->getByEmail('test@example.com');

View File

@ -21,6 +21,7 @@ use OC\User\User;
use OCA\DAV\Connector\Sabre\Auth; use OCA\DAV\Connector\Sabre\Auth;
use OCP\AppFramework\Utility\ITimeFactory; use OCP\AppFramework\Utility\ITimeFactory;
use OCP\EventDispatcher\IEventDispatcher; use OCP\EventDispatcher\IEventDispatcher;
use OCP\ICacheFactory;
use OCP\IConfig; use OCP\IConfig;
use OCP\ILogger; use OCP\ILogger;
use OCP\IRequest; use OCP\IRequest;
@ -232,7 +233,8 @@ class SessionTest extends \Test\TestCase {
->setConstructorArgs([ ->setConstructorArgs([
$this->config, $this->config,
$this->createMock(EventDispatcherInterface::class), $this->createMock(EventDispatcherInterface::class),
$this->createMock(IEventDispatcher::class) $this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class),
]) ])
->getMock(); ->getMock();
@ -298,7 +300,8 @@ class SessionTest extends \Test\TestCase {
->setConstructorArgs([ ->setConstructorArgs([
$this->config, $this->config,
$this->createMock(EventDispatcherInterface::class), $this->createMock(EventDispatcherInterface::class),
$this->createMock(IEventDispatcher::class) $this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class),
]) ])
->getMock(); ->getMock();
@ -331,7 +334,8 @@ class SessionTest extends \Test\TestCase {
->setConstructorArgs([ ->setConstructorArgs([
$this->config, $this->config,
$this->createMock(EventDispatcherInterface::class), $this->createMock(EventDispatcherInterface::class),
$this->createMock(IEventDispatcher::class) $this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class),
]) ])
->getMock(); ->getMock();
$backend = $this->createMock(\Test\Util\User\Dummy::class); $backend = $this->createMock(\Test\Util\User\Dummy::class);
@ -574,7 +578,8 @@ class SessionTest extends \Test\TestCase {
->setConstructorArgs([ ->setConstructorArgs([
$this->config, $this->config,
$this->createMock(EventDispatcherInterface::class), $this->createMock(EventDispatcherInterface::class),
$this->createMock(IEventDispatcher::class) $this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class),
]) ])
->getMock(); ->getMock();
$userSession = $this->getMockBuilder(Session::class) $userSession = $this->getMockBuilder(Session::class)
@ -663,7 +668,8 @@ class SessionTest extends \Test\TestCase {
->setConstructorArgs([ ->setConstructorArgs([
$this->config, $this->config,
$this->createMock(EventDispatcherInterface::class), $this->createMock(EventDispatcherInterface::class),
$this->createMock(IEventDispatcher::class) $this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class),
]) ])
->getMock(); ->getMock();
$userSession = $this->getMockBuilder(Session::class) $userSession = $this->getMockBuilder(Session::class)
@ -727,7 +733,8 @@ class SessionTest extends \Test\TestCase {
->setConstructorArgs([ ->setConstructorArgs([
$this->config, $this->config,
$this->createMock(EventDispatcherInterface::class), $this->createMock(EventDispatcherInterface::class),
$this->createMock(IEventDispatcher::class) $this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class),
]) ])
->getMock(); ->getMock();
$userSession = $this->getMockBuilder(Session::class) $userSession = $this->getMockBuilder(Session::class)
@ -779,7 +786,8 @@ class SessionTest extends \Test\TestCase {
->setConstructorArgs([ ->setConstructorArgs([
$this->config, $this->config,
$this->createMock(EventDispatcherInterface::class), $this->createMock(EventDispatcherInterface::class),
$this->createMock(IEventDispatcher::class) $this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class),
]) ])
->getMock(); ->getMock();
$userSession = $this->getMockBuilder(Session::class) $userSession = $this->getMockBuilder(Session::class)