|
|
|
|
@ -60,7 +60,7 @@ class User_LDAPTest extends TestCase { |
|
|
|
|
protected function setUp(): void { |
|
|
|
|
parent::setUp(); |
|
|
|
|
|
|
|
|
|
\OC_User::clearBackends(); |
|
|
|
|
Server::get(IUserManager::class)->clearBackends(); |
|
|
|
|
Server::get(IGroupManager::class)->clearBackends(); |
|
|
|
|
|
|
|
|
|
$this->connection = $this->createMock(Connection::class); |
|
|
|
|
@ -187,7 +187,7 @@ class User_LDAPTest extends TestCase { |
|
|
|
|
|
|
|
|
|
$backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); |
|
|
|
|
|
|
|
|
|
\OC_User::useBackend($backend); |
|
|
|
|
Server::get(IUserManager::class)->registerBackend($backend); |
|
|
|
|
|
|
|
|
|
$result = $backend->checkPassword('roland', 'dt19'); |
|
|
|
|
$this->assertEquals('gunslinger', $result); |
|
|
|
|
@ -196,7 +196,7 @@ class User_LDAPTest extends TestCase { |
|
|
|
|
public function testCheckPasswordWrongPassword(): void { |
|
|
|
|
$this->prepareAccessForCheckPassword(); |
|
|
|
|
$backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); |
|
|
|
|
\OC_User::useBackend($backend); |
|
|
|
|
Server::get(IUserManager::class)->registerBackend($backend); |
|
|
|
|
|
|
|
|
|
$result = $backend->checkPassword('roland', 'wrong'); |
|
|
|
|
$this->assertFalse($result); |
|
|
|
|
@ -205,7 +205,7 @@ class User_LDAPTest extends TestCase { |
|
|
|
|
public function testCheckPasswordWrongUser(): void { |
|
|
|
|
$this->prepareAccessForCheckPassword(); |
|
|
|
|
$backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); |
|
|
|
|
\OC_User::useBackend($backend); |
|
|
|
|
Server::get(IUserManager::class)->registerBackend($backend); |
|
|
|
|
|
|
|
|
|
$result = $backend->checkPassword('mallory', 'evil'); |
|
|
|
|
$this->assertFalse($result); |
|
|
|
|
@ -220,7 +220,7 @@ class User_LDAPTest extends TestCase { |
|
|
|
|
->willReturn(null); |
|
|
|
|
|
|
|
|
|
$backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); |
|
|
|
|
\OC_User::useBackend($backend); |
|
|
|
|
Server::get(IUserManager::class)->registerBackend($backend); |
|
|
|
|
|
|
|
|
|
$result = $backend->checkPassword('roland', 'dt19'); |
|
|
|
|
$this->assertFalse($result); |
|
|
|
|
@ -238,7 +238,7 @@ class User_LDAPTest extends TestCase { |
|
|
|
|
->willReturn($user); |
|
|
|
|
|
|
|
|
|
$backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); |
|
|
|
|
\OC_User::useBackend($backend); |
|
|
|
|
Server::get(IUserManager::class)->registerBackend($backend); |
|
|
|
|
|
|
|
|
|
$user = Server::get(IUserManager::class)->checkPassword('roland', 'dt19'); |
|
|
|
|
$result = false; |
|
|
|
|
@ -251,7 +251,7 @@ class User_LDAPTest extends TestCase { |
|
|
|
|
public function testCheckPasswordPublicAPIWrongPassword(): void { |
|
|
|
|
$this->prepareAccessForCheckPassword(); |
|
|
|
|
$backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); |
|
|
|
|
\OC_User::useBackend($backend); |
|
|
|
|
Server::get(IUserManager::class)->registerBackend($backend); |
|
|
|
|
|
|
|
|
|
$user = Server::get(IUserManager::class)->checkPassword('roland', 'wrong'); |
|
|
|
|
$result = false; |
|
|
|
|
@ -264,7 +264,7 @@ class User_LDAPTest extends TestCase { |
|
|
|
|
public function testCheckPasswordPublicAPIWrongUser(): void { |
|
|
|
|
$this->prepareAccessForCheckPassword(); |
|
|
|
|
$backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); |
|
|
|
|
\OC_User::useBackend($backend); |
|
|
|
|
Server::get(IUserManager::class)->registerBackend($backend); |
|
|
|
|
|
|
|
|
|
$user = Server::get(IUserManager::class)->checkPassword('mallory', 'evil'); |
|
|
|
|
$result = false; |
|
|
|
|
@ -450,7 +450,7 @@ class User_LDAPTest extends TestCase { |
|
|
|
|
public function testGetUsersViaAPINoParam(): void { |
|
|
|
|
$this->prepareAccessForGetUsers(); |
|
|
|
|
$backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); |
|
|
|
|
\OC_User::useBackend($backend); |
|
|
|
|
Server::get(IUserManager::class)->registerBackend($backend); |
|
|
|
|
|
|
|
|
|
$result = $this->getUsers(); |
|
|
|
|
$this->assertEquals(3, count($result)); |
|
|
|
|
@ -459,7 +459,7 @@ class User_LDAPTest extends TestCase { |
|
|
|
|
public function testGetUsersViaAPILimitOffset(): void { |
|
|
|
|
$this->prepareAccessForGetUsers(); |
|
|
|
|
$backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); |
|
|
|
|
\OC_User::useBackend($backend); |
|
|
|
|
Server::get(IUserManager::class)->registerBackend($backend); |
|
|
|
|
|
|
|
|
|
$result = $this->getUsers('', 1, 2); |
|
|
|
|
$this->assertEquals(1, count($result)); |
|
|
|
|
@ -468,7 +468,7 @@ class User_LDAPTest extends TestCase { |
|
|
|
|
public function testGetUsersViaAPILimitOffset2(): void { |
|
|
|
|
$this->prepareAccessForGetUsers(); |
|
|
|
|
$backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); |
|
|
|
|
\OC_User::useBackend($backend); |
|
|
|
|
Server::get(IUserManager::class)->registerBackend($backend); |
|
|
|
|
|
|
|
|
|
$result = $this->getUsers('', 2, 1); |
|
|
|
|
$this->assertEquals(2, count($result)); |
|
|
|
|
@ -477,7 +477,7 @@ class User_LDAPTest extends TestCase { |
|
|
|
|
public function testGetUsersViaAPISearchWithResult(): void { |
|
|
|
|
$this->prepareAccessForGetUsers(); |
|
|
|
|
$backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); |
|
|
|
|
\OC_User::useBackend($backend); |
|
|
|
|
Server::get(IUserManager::class)->registerBackend($backend); |
|
|
|
|
|
|
|
|
|
$result = $this->getUsers('yo'); |
|
|
|
|
$this->assertEquals(2, count($result)); |
|
|
|
|
@ -486,7 +486,7 @@ class User_LDAPTest extends TestCase { |
|
|
|
|
public function testGetUsersViaAPISearchEmptyResult(): void { |
|
|
|
|
$this->prepareAccessForGetUsers(); |
|
|
|
|
$backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); |
|
|
|
|
\OC_User::useBackend($backend); |
|
|
|
|
Server::get(IUserManager::class)->registerBackend($backend); |
|
|
|
|
|
|
|
|
|
$result = $this->getUsers('nix'); |
|
|
|
|
$this->assertEquals(0, count($result)); |
|
|
|
|
@ -561,7 +561,7 @@ class User_LDAPTest extends TestCase { |
|
|
|
|
public function testUserExistsPublicAPI(): void { |
|
|
|
|
$backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); |
|
|
|
|
$this->prepareMockForUserExists(); |
|
|
|
|
\OC_User::useBackend($backend); |
|
|
|
|
Server::get(IUserManager::class)->registerBackend($backend); |
|
|
|
|
|
|
|
|
|
$user = $this->createMock(User::class); |
|
|
|
|
$user->expects($this->any()) |
|
|
|
|
@ -950,7 +950,7 @@ class User_LDAPTest extends TestCase { |
|
|
|
|
return true; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
\OC_User::useBackend($backend); |
|
|
|
|
Server::get(IUserManager::class)->registerBackend($backend); |
|
|
|
|
|
|
|
|
|
$user1 = $this->createMock(User::class); |
|
|
|
|
$user1->expects($this->once()) |
|
|
|
|
@ -1250,7 +1250,7 @@ class User_LDAPTest extends TestCase { |
|
|
|
|
->method('get') |
|
|
|
|
->willReturn($this->createMock(User::class)); |
|
|
|
|
$backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); |
|
|
|
|
\OC_User::useBackend($backend); |
|
|
|
|
Server::get(IUserManager::class)->registerBackend($backend); |
|
|
|
|
|
|
|
|
|
$this->assertTrue(\OC_User::setPassword('roland', 'dt')); |
|
|
|
|
} |
|
|
|
|
@ -1267,7 +1267,7 @@ class User_LDAPTest extends TestCase { |
|
|
|
|
->method('get') |
|
|
|
|
->willReturn($this->createMock(User::class)); |
|
|
|
|
|
|
|
|
|
\OC_User::useBackend($backend); |
|
|
|
|
Server::get(IUserManager::class)->registerBackend($backend); |
|
|
|
|
|
|
|
|
|
$this->assertTrue(\OC_User::setPassword('roland', 'dt12234$')); |
|
|
|
|
} |
|
|
|
|
@ -1279,7 +1279,7 @@ class User_LDAPTest extends TestCase { |
|
|
|
|
|
|
|
|
|
$this->prepareAccessForSetPassword(false); |
|
|
|
|
$backend = new UserLDAP($this->access, $this->notificationManager, $this->pluginManager, $this->logger, $this->deletedUsersIndex); |
|
|
|
|
\OC_User::useBackend($backend); |
|
|
|
|
Server::get(IUserManager::class)->registerBackend($backend); |
|
|
|
|
|
|
|
|
|
$this->assertFalse(\OC_User::setPassword('roland', 'dt12234$')); |
|
|
|
|
} |
|
|
|
|
|