aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLouis Chemineau <louis@chmn.me>2024-09-20 11:26:22 +0200
committerLouis Chemineau <louis@chmn.me>2024-09-23 18:06:38 +0200
commit9a34a6c4c4f556ccc6f1b6cb6d0cf8a651840fb0 (patch)
tree0ad6e95dbc751d682705e1c1c58d66073a965a23 /tests
parentc15e2411db080fcb57a4200953a7c08f5ecea8d7 (diff)
downloadnextcloud-server-9a34a6c4c4f556ccc6f1b6cb6d0cf8a651840fb0.tar.gz
nextcloud-server-9a34a6c4c4f556ccc6f1b6cb6d0cf8a651840fb0.zip
fix(users): Don't crash if disabled user is missing in the databasebackport/48207/stable30
Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Files/Config/UserMountCacheTest.php2
-rw-r--r--tests/lib/Files/Storage/Wrapper/EncryptionTest.php9
-rw-r--r--tests/lib/Files/Stream/EncryptionTest.php4
-rw-r--r--tests/lib/User/ManagerTest.php54
-rw-r--r--tests/lib/User/SessionTest.php9
5 files changed, 48 insertions, 30 deletions
diff --git a/tests/lib/Files/Config/UserMountCacheTest.php b/tests/lib/Files/Config/UserMountCacheTest.php
index d84f4469e8b..946203100d2 100644
--- a/tests/lib/Files/Config/UserMountCacheTest.php
+++ b/tests/lib/Files/Config/UserMountCacheTest.php
@@ -62,7 +62,7 @@ class UserMountCacheTest extends TestCase {
->expects($this->any())
->method('getAppValue')
->willReturnArgument(2);
- $this->userManager = new Manager($config, $this->createMock(ICacheFactory::class), $this->createMock(IEventDispatcher::class));
+ $this->userManager = new Manager($config, $this->createMock(ICacheFactory::class), $this->createMock(IEventDispatcher::class), $this->createMock(LoggerInterface::class));
$userBackend = new Dummy();
$userBackend->createUser('u1', '');
$userBackend->createUser('u2', '');
diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
index a6e0260fde6..088ff139b3c 100644
--- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
+++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
@@ -137,7 +137,8 @@ class EncryptionTest extends Storage {
->setConstructorArgs([new View(), new Manager(
$this->config,
$this->createMock(ICacheFactory::class),
- $this->createMock(IEventDispatcher::class)
+ $this->createMock(IEventDispatcher::class),
+ $this->createMock(LoggerInterface::class),
), $this->groupManager, $this->config, $this->arrayCache])
->getMock();
$this->util->expects($this->any())
@@ -577,7 +578,8 @@ class EncryptionTest extends Storage {
new Manager(
$this->config,
$this->createMock(ICacheFactory::class),
- $this->createMock(IEventDispatcher::class)
+ $this->createMock(IEventDispatcher::class),
+ $this->createMock(LoggerInterface::class),
),
$this->groupManager,
$this->config,
@@ -659,7 +661,8 @@ class EncryptionTest extends Storage {
->setConstructorArgs([new View(), new Manager(
$this->config,
$this->createMock(ICacheFactory::class),
- $this->createMock(IEventDispatcher::class)
+ $this->createMock(IEventDispatcher::class),
+ $this->createMock(LoggerInterface::class),
), $this->groupManager, $this->config, $this->arrayCache])
->getMock();
diff --git a/tests/lib/Files/Stream/EncryptionTest.php b/tests/lib/Files/Stream/EncryptionTest.php
index b6650b56a85..1326baf75fa 100644
--- a/tests/lib/Files/Stream/EncryptionTest.php
+++ b/tests/lib/Files/Stream/EncryptionTest.php
@@ -13,6 +13,7 @@ use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Cache\ICache;
use OCP\ICacheFactory;
use OCP\IConfig;
+use Psr\Log\LoggerInterface;
class EncryptionTest extends \Test\TestCase {
public const DEFAULT_WRAPPER = '\OC\Files\Stream\Encryption';
@@ -57,7 +58,8 @@ class EncryptionTest extends \Test\TestCase {
->setConstructorArgs([new View(), new \OC\User\Manager(
$config,
$this->createMock(ICacheFactory::class),
- $this->createMock(IEventDispatcher::class)
+ $this->createMock(IEventDispatcher::class),
+ $this->createMock(LoggerInterface::class),
), $groupManager, $config, $arrayCache])
->getMock();
$util->expects($this->any())
diff --git a/tests/lib/User/ManagerTest.php b/tests/lib/User/ManagerTest.php
index c516b1de945..01592851706 100644
--- a/tests/lib/User/ManagerTest.php
+++ b/tests/lib/User/ManagerTest.php
@@ -16,6 +16,7 @@ use OCP\ICache;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IUser;
+use Psr\Log\LoggerInterface;
use Test\TestCase;
/**
@@ -34,6 +35,8 @@ class ManagerTest extends TestCase {
private $cacheFactory;
/** @var ICache */
private $cache;
+ /** @var LoggerInterface */
+ private $logger;
protected function setUp(): void {
parent::setUp();
@@ -42,6 +45,7 @@ class ManagerTest extends TestCase {
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
$this->cacheFactory = $this->createMock(ICacheFactory::class);
$this->cache = $this->createMock(ICache::class);
+ $this->logger = $this->createMock(LoggerInterface::class);
$this->cacheFactory->method('createDistributed')
->willReturn($this->cache);
@@ -49,7 +53,7 @@ class ManagerTest extends TestCase {
public function testGetBackends() {
$userDummyBackend = $this->createMock(\Test\Util\User\Dummy::class);
- $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$manager->registerBackend($userDummyBackend);
$this->assertEquals([$userDummyBackend], $manager->getBackends());
$dummyDatabaseBackend = $this->createMock(Database::class);
@@ -68,7 +72,7 @@ class ManagerTest extends TestCase {
->with($this->equalTo('foo'))
->willReturn(true);
- $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$manager->registerBackend($backend);
$this->assertTrue($manager->userExists('foo'));
@@ -84,14 +88,14 @@ class ManagerTest extends TestCase {
->with($this->equalTo('foo'))
->willReturn(false);
- $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$manager->registerBackend($backend);
$this->assertFalse($manager->userExists('foo'));
}
public function testUserExistsNoBackends() {
- $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$this->assertFalse($manager->userExists('foo'));
}
@@ -115,7 +119,7 @@ class ManagerTest extends TestCase {
->with($this->equalTo('foo'))
->willReturn(true);
- $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$manager->registerBackend($backend1);
$manager->registerBackend($backend2);
@@ -139,7 +143,7 @@ class ManagerTest extends TestCase {
$backend2->expects($this->never())
->method('userExists');
- $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$manager->registerBackend($backend1);
$manager->registerBackend($backend2);
@@ -166,7 +170,7 @@ class ManagerTest extends TestCase {
}
});
- $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$manager->registerBackend($backend);
$user = $manager->checkPassword('foo', 'bar');
@@ -185,7 +189,7 @@ class ManagerTest extends TestCase {
->method('implementsActions')
->willReturn(false);
- $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$manager->registerBackend($backend);
$this->assertFalse($manager->checkPassword('foo', 'bar'));
@@ -203,7 +207,7 @@ class ManagerTest extends TestCase {
$backend->expects($this->never())
->method('loginName2UserName');
- $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$manager->registerBackend($backend);
$this->assertEquals('foo', $manager->get('foo')->getUID());
@@ -219,7 +223,7 @@ class ManagerTest extends TestCase {
->with($this->equalTo('foo'))
->willReturn(false);
- $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$manager->registerBackend($backend);
$this->assertEquals(null, $manager->get('foo'));
@@ -237,7 +241,7 @@ class ManagerTest extends TestCase {
$backend->expects($this->never())
->method('loginName2UserName');
- $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$manager->registerBackend($backend);
$this->assertEquals('bLeNdEr', $manager->get('bLeNdEr')->getUID());
@@ -255,7 +259,7 @@ class ManagerTest extends TestCase {
$backend->expects($this->never())
->method('loginName2UserName');
- $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$manager->registerBackend($backend);
$result = $manager->search('fo');
@@ -289,7 +293,7 @@ class ManagerTest extends TestCase {
$backend2->expects($this->never())
->method('loginName2UserName');
- $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$manager->registerBackend($backend1);
$manager->registerBackend($backend2);
@@ -343,7 +347,7 @@ class ManagerTest extends TestCase {
->willReturn(true);
- $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$manager->registerBackend($backend);
$this->expectException(\InvalidArgumentException::class, $exception);
@@ -370,7 +374,7 @@ class ManagerTest extends TestCase {
$backend->expects($this->never())
->method('loginName2UserName');
- $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$manager->registerBackend($backend);
$user = $manager->createUser('foo', 'bar');
@@ -397,7 +401,7 @@ class ManagerTest extends TestCase {
->with($this->equalTo('foo'))
->willReturn(true);
- $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$manager->registerBackend($backend);
$manager->createUser('foo', 'bar');
@@ -418,14 +422,14 @@ class ManagerTest extends TestCase {
$backend->expects($this->never())
->method('userExists');
- $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$manager->registerBackend($backend);
$this->assertFalse($manager->createUser('foo', 'bar'));
}
public function testCreateUserNoBackends() {
- $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$this->assertFalse($manager->createUser('foo', 'bar'));
}
@@ -445,7 +449,7 @@ class ManagerTest extends TestCase {
->with('MyUid', 'MyPassword')
->willReturn(false);
- $manager = new Manager($this->config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new Manager($this->config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$manager->createUserFromBackend('MyUid', 'MyPassword', $backend);
}
@@ -485,7 +489,7 @@ class ManagerTest extends TestCase {
->with($this->equalTo('foo'))
->willReturn(true);
- $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$manager->registerBackend($backend1);
$manager->registerBackend($backend2);
@@ -493,7 +497,7 @@ class ManagerTest extends TestCase {
}
public function testCountUsersNoBackend() {
- $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$result = $manager->countUsers();
$this->assertTrue(is_array($result));
@@ -518,7 +522,7 @@ class ManagerTest extends TestCase {
->method('getBackendName')
->willReturn('Mock_Test_Util_User_Dummy');
- $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$manager->registerBackend($backend);
$result = $manager->countUsers();
@@ -559,7 +563,7 @@ class ManagerTest extends TestCase {
->method('getBackendName')
->willReturn('Mock_Test_Util_User_Dummy');
- $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($this->config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$manager->registerBackend($backend1);
$manager->registerBackend($backend2);
@@ -672,7 +676,7 @@ class ManagerTest extends TestCase {
->method('getAppValue')
->willReturnArgument(2);
- $manager = new \OC\User\Manager($config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$backend = new \Test\Util\User\Dummy();
$manager->registerBackend($backend);
@@ -706,7 +710,7 @@ class ManagerTest extends TestCase {
true
);
- $manager = new \OC\User\Manager($config, $this->cacheFactory, $this->eventDispatcher);
+ $manager = new \OC\User\Manager($config, $this->cacheFactory, $this->eventDispatcher, $this->logger);
$manager->registerBackend($backend);
$users = $manager->getByEmail('test@example.com');
diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php
index 84af7f552a7..0ebc2965b3e 100644
--- a/tests/lib/User/SessionTest.php
+++ b/tests/lib/User/SessionTest.php
@@ -181,6 +181,7 @@ class SessionTest extends \Test\TestCase {
$this->config,
$this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class),
+ $this->createMock(LoggerInterface::class),
])
->getMock();
@@ -247,6 +248,7 @@ class SessionTest extends \Test\TestCase {
$this->config,
$this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class),
+ $this->createMock(LoggerInterface::class),
])
->getMock();
@@ -280,6 +282,7 @@ class SessionTest extends \Test\TestCase {
$this->config,
$this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class),
+ $this->createMock(LoggerInterface::class),
])
->getMock();
$backend = $this->createMock(\Test\Util\User\Dummy::class);
@@ -323,6 +326,7 @@ class SessionTest extends \Test\TestCase {
$this->config,
$this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class),
+ $this->createMock(LoggerInterface::class),
])
->getMock();
$userSession = new Session($manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher);
@@ -360,6 +364,7 @@ class SessionTest extends \Test\TestCase {
$this->config,
$this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class),
+ $this->createMock(LoggerInterface::class),
])
->getMock();
$userSession = new Session($manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher);
@@ -617,6 +622,7 @@ class SessionTest extends \Test\TestCase {
$this->config,
$this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class),
+ $this->createMock(LoggerInterface::class),
])
->getMock();
$userSession = $this->getMockBuilder(Session::class)
@@ -706,6 +712,7 @@ class SessionTest extends \Test\TestCase {
$this->config,
$this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class),
+ $this->createMock(LoggerInterface::class),
])
->getMock();
$userSession = $this->getMockBuilder(Session::class)
@@ -770,6 +777,7 @@ class SessionTest extends \Test\TestCase {
$this->config,
$this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class),
+ $this->createMock(LoggerInterface::class),
])
->getMock();
$userSession = $this->getMockBuilder(Session::class)
@@ -822,6 +830,7 @@ class SessionTest extends \Test\TestCase {
$this->config,
$this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class),
+ $this->createMock(LoggerInterface::class),
])
->getMock();
$userSession = $this->getMockBuilder(Session::class)