summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/tests
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2017-04-24 12:17:04 +0200
committerGitHub <noreply@github.com>2017-04-24 12:17:04 +0200
commit42e805f0578b95206fdddabfe6234b0880c27b1e (patch)
treed9dc2870f2727ac0b35e95681ebc320222c5cc17 /apps/user_ldap/tests
parent3d671cc536b1b472c746fd4ea8f60135f4935a44 (diff)
parent5fa218051bb7cafe9acfdc223fe6a6d4605dacdc (diff)
downloadnextcloud-server-42e805f0578b95206fdddabfe6234b0880c27b1e.tar.gz
nextcloud-server-42e805f0578b95206fdddabfe6234b0880c27b1e.zip
Merge pull request #1023 from GitHubUser4234/ldap_password_renew_pr
Handle password expiry in user_ldap
Diffstat (limited to 'apps/user_ldap/tests')
-rw-r--r--apps/user_ldap/tests/AccessTest.php4
-rw-r--r--apps/user_ldap/tests/Integration/Lib/IntegrationTestFetchUsersByLoginName.php2
-rw-r--r--apps/user_ldap/tests/Integration/Lib/IntegrationTestPaging.php2
-rw-r--r--apps/user_ldap/tests/Integration/Lib/IntegrationTestUserHome.php2
-rw-r--r--apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserAvatar.php5
-rw-r--r--apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php2
-rw-r--r--apps/user_ldap/tests/User/ManagerTest.php36
-rw-r--r--apps/user_ldap/tests/User/UserTest.php278
-rw-r--r--apps/user_ldap/tests/User_LDAPTest.php96
-rw-r--r--apps/user_ldap/tests/User_ProxyTest.php5
10 files changed, 300 insertions, 132 deletions
diff --git a/apps/user_ldap/tests/AccessTest.php b/apps/user_ldap/tests/AccessTest.php
index 271e8eb605b..85f0516dec2 100644
--- a/apps/user_ldap/tests/AccessTest.php
+++ b/apps/user_ldap/tests/AccessTest.php
@@ -42,6 +42,7 @@ use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Image;
use OCP\IUserManager;
+use OCP\Notification\IManager as INotificationManager;
/**
* Class AccessTest
@@ -89,7 +90,8 @@ class AccessTest extends \Test\TestCase {
$this->createMock(IAvatarManager::class),
$this->createMock(Image::class),
$this->createMock(IDBConnection::class),
- $this->createMock(IUserManager::class)])
+ $this->createMock(IUserManager::class),
+ $this->createMock(INotificationManager::class)])
->getMock();
$helper = new Helper(\OC::$server->getConfig());
diff --git a/apps/user_ldap/tests/Integration/Lib/IntegrationTestFetchUsersByLoginName.php b/apps/user_ldap/tests/Integration/Lib/IntegrationTestFetchUsersByLoginName.php
index 32fc2151a7c..25b7cf83f99 100644
--- a/apps/user_ldap/tests/Integration/Lib/IntegrationTestFetchUsersByLoginName.php
+++ b/apps/user_ldap/tests/Integration/Lib/IntegrationTestFetchUsersByLoginName.php
@@ -47,7 +47,7 @@ class IntegrationTestFetchUsersByLoginName extends AbstractIntegrationTest {
$this->mapping = new UserMapping(\OC::$server->getDatabaseConnection());
$this->mapping->clear();
$this->access->setUserMapper($this->mapping);
- $this->backend = new \OCA\User_LDAP\User_LDAP($this->access, \OC::$server->getConfig());
+ $this->backend = new \OCA\User_LDAP\User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager());
}
/**
diff --git a/apps/user_ldap/tests/Integration/Lib/IntegrationTestPaging.php b/apps/user_ldap/tests/Integration/Lib/IntegrationTestPaging.php
index 3826cbdae51..2f14b0d1c1b 100644
--- a/apps/user_ldap/tests/Integration/Lib/IntegrationTestPaging.php
+++ b/apps/user_ldap/tests/Integration/Lib/IntegrationTestPaging.php
@@ -44,7 +44,7 @@ class IntegrationTestPaging extends AbstractIntegrationTest {
require(__DIR__ . '/../setup-scripts/createExplicitUsers.php');
parent::init();
- $this->backend = new \OCA\User_LDAP\User_LDAP($this->access, \OC::$server->getConfig());
+ $this->backend = new \OCA\User_LDAP\User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager());
}
/**
diff --git a/apps/user_ldap/tests/Integration/Lib/IntegrationTestUserHome.php b/apps/user_ldap/tests/Integration/Lib/IntegrationTestUserHome.php
index 9db4cafea41..57c48fa18e0 100644
--- a/apps/user_ldap/tests/Integration/Lib/IntegrationTestUserHome.php
+++ b/apps/user_ldap/tests/Integration/Lib/IntegrationTestUserHome.php
@@ -48,7 +48,7 @@ class IntegrationTestUserHome extends AbstractIntegrationTest {
$this->mapping = new UserMapping(\OC::$server->getDatabaseConnection());
$this->mapping->clear();
$this->access->setUserMapper($this->mapping);
- $this->backend = new \OCA\User_LDAP\User_LDAP($this->access, \OC::$server->getConfig());
+ $this->backend = new \OCA\User_LDAP\User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager());
}
/**
diff --git a/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserAvatar.php b/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserAvatar.php
index 7c8f9475b41..3fb5a67591b 100644
--- a/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserAvatar.php
+++ b/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserAvatar.php
@@ -45,7 +45,7 @@ class IntegrationTestUserAvatar extends AbstractIntegrationTest {
$this->mapping = new UserMapping(\OC::$server->getDatabaseConnection());
$this->mapping->clear();
$this->access->setUserMapper($this->mapping);
- $userBackend = new \OCA\User_LDAP\User_LDAP($this->access, \OC::$server->getConfig());
+ $userBackend = new \OCA\User_LDAP\User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager());
\OC_User::useBackend($userBackend);
}
@@ -130,7 +130,8 @@ class IntegrationTestUserAvatar extends AbstractIntegrationTest {
\OC::$server->getAvatarManager(),
new \OCP\Image(),
\OC::$server->getDatabaseConnection(),
- \OC::$server->getUserManager()
+ \OC::$server->getUserManager(),
+ \OC::$server->getNotificationManager()
);
}
diff --git a/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php b/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php
index d0444daca5f..616bf410e04 100644
--- a/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php
+++ b/apps/user_ldap/tests/Integration/Lib/User/IntegrationTestUserDisplayName.php
@@ -43,7 +43,7 @@ class IntegrationTestUserDisplayName extends AbstractIntegrationTest {
$this->mapping = new UserMapping(\OC::$server->getDatabaseConnection());
$this->mapping->clear();
$this->access->setUserMapper($this->mapping);
- $userBackend = new User_LDAP($this->access, \OC::$server->getConfig());
+ $userBackend = new User_LDAP($this->access, \OC::$server->getConfig(), \OC::$server->getNotificationManager());
\OC_User::useBackend($userBackend);
}
diff --git a/apps/user_ldap/tests/User/ManagerTest.php b/apps/user_ldap/tests/User/ManagerTest.php
index 16d6a3d9d6e..823081f1da2 100644
--- a/apps/user_ldap/tests/User/ManagerTest.php
+++ b/apps/user_ldap/tests/User/ManagerTest.php
@@ -36,6 +36,7 @@ use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Image;
use OCP\IUserManager;
+use OCP\Notification\IManager as INotificationManager;
/**
* Class Test_User_Manager
@@ -55,6 +56,7 @@ class ManagerTest extends \Test\TestCase {
$image = $this->createMock(Image::class);
$dbc = $this->createMock(IDBConnection::class);
$userMgr = $this->createMock(IUserManager::class);
+ $notiMgr = $this->createMock(INotificationManager::class);
$connection = new \OCA\User_LDAP\Connection(
$lw = $this->createMock(ILDAPWrapper::class),
@@ -66,11 +68,11 @@ class ManagerTest extends \Test\TestCase {
->method('getConnection')
->will($this->returnValue($connection));
- return array($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr);
+ return array($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr);
}
public function testGetByDNExisting() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
$inputDN = 'cn=foo,dc=foobar,dc=bar';
@@ -89,7 +91,7 @@ class ManagerTest extends \Test\TestCase {
$access->expects($this->never())
->method('username2dn');
- $manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr);
+ $manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr, $notiMgr);
$manager->setLdapAccess($access);
$user = $manager->get($inputDN);
@@ -101,7 +103,7 @@ class ManagerTest extends \Test\TestCase {
}
public function testGetByEDirectoryDN() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
$inputDN = 'uid=foo,o=foobar,c=bar';
@@ -120,7 +122,7 @@ class ManagerTest extends \Test\TestCase {
$access->expects($this->never())
->method('username2dn');
- $manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr);
+ $manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr, $notiMgr);
$manager->setLdapAccess($access);
$user = $manager->get($inputDN);
@@ -128,7 +130,7 @@ class ManagerTest extends \Test\TestCase {
}
public function testGetByExoticDN() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
$inputDN = 'ab=cde,f=ghei,mno=pq';
@@ -147,7 +149,7 @@ class ManagerTest extends \Test\TestCase {
$access->expects($this->never())
->method('username2dn');
- $manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr);
+ $manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr, $notiMgr);
$manager->setLdapAccess($access);
$user = $manager->get($inputDN);
@@ -155,7 +157,7 @@ class ManagerTest extends \Test\TestCase {
}
public function testGetByDNNotExisting() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
$inputDN = 'cn=gone,dc=foobar,dc=bar';
@@ -175,7 +177,7 @@ class ManagerTest extends \Test\TestCase {
->with($this->equalTo($inputDN))
->will($this->returnValue(false));
- $manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr);
+ $manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr, $notiMgr);
$manager->setLdapAccess($access);
$user = $manager->get($inputDN);
@@ -183,7 +185,7 @@ class ManagerTest extends \Test\TestCase {
}
public function testGetByUidExisting() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
$dn = 'cn=foo,dc=foobar,dc=bar';
@@ -202,7 +204,7 @@ class ManagerTest extends \Test\TestCase {
->with($this->equalTo($uid))
->will($this->returnValue(false));
- $manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr);
+ $manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr, $notiMgr);
$manager->setLdapAccess($access);
$user = $manager->get($uid);
@@ -214,7 +216,7 @@ class ManagerTest extends \Test\TestCase {
}
public function testGetByUidNotExisting() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
$uid = 'gone';
@@ -227,7 +229,7 @@ class ManagerTest extends \Test\TestCase {
->with($this->equalTo($uid))
->will($this->returnValue(false));
- $manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr);
+ $manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr, $notiMgr);
$manager->setLdapAccess($access);
$user = $manager->get($uid);
@@ -235,10 +237,10 @@ class ManagerTest extends \Test\TestCase {
}
public function testGetAttributesAll() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
- $manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr);
+ $manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr, $notiMgr);
$manager->setLdapAccess($access);
$connection = $access->getConnection();
@@ -253,10 +255,10 @@ class ManagerTest extends \Test\TestCase {
}
public function testGetAttributesMinimal() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
- $manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr);
+ $manager = new Manager($config, $filesys, $log, $avaMgr, $image, $dbc, $userMgr, $notiMgr);
$manager->setLdapAccess($access);
$attributes = $manager->getAttributes(true);
diff --git a/apps/user_ldap/tests/User/UserTest.php b/apps/user_ldap/tests/User/UserTest.php
index 6961e39d9f0..0437051b134 100644
--- a/apps/user_ldap/tests/User/UserTest.php
+++ b/apps/user_ldap/tests/User/UserTest.php
@@ -37,6 +37,7 @@ use OCP\IDBConnection;
use OCP\Image;
use OCP\IUser;
use OCP\IUserManager;
+use OCP\Notification\IManager as INotificationManager;
/**
* Class UserTest
@@ -56,11 +57,12 @@ class UserTest extends \Test\TestCase {
$image = $this->createMock(Image::class);
$dbc = $this->createMock(IDBConnection::class);
$userMgr = $this->createMock(IUserManager::class);
+ $notiMgr = $this->createMock(INotificationManager::class);
- return array($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr);
+ return array($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr);
}
- private function getAdvancedMocks($cfMock, $fsMock, $logMock, $avaMgr, $dbc, $userMgr = null) {
+ private function getAdvancedMocks($cfMock, $fsMock, $logMock, $avaMgr, $dbc, $userMgr = null, $notiMgr = null) {
static $conMethods;
static $accMethods;
static $umMethods;
@@ -77,9 +79,12 @@ class UserTest extends \Test\TestCase {
if (is_null($userMgr)) {
$userMgr = $this->createMock(IUserManager::class);
}
+ if (is_null($notiMgr)) {
+ $notiMgr = $this->createMock(INotificationManager::class);
+ }
$um = $this->getMockBuilder('\OCA\User_LDAP\User\Manager')
->setMethods($umMethods)
- ->setConstructorArgs([$cfMock, $fsMock, $logMock, $avaMgr, $im, $dbc, $userMgr])
+ ->setConstructorArgs([$cfMock, $fsMock, $logMock, $avaMgr, $im, $dbc, $userMgr, $notiMgr])
->getMock();
$helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig());
$connector = $this->getMockBuilder('\OCA\User_LDAP\Connection')
@@ -95,25 +100,25 @@ class UserTest extends \Test\TestCase {
}
public function testGetDNandUsername() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $db, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $db, $userMgr, $notiMgr) =
$this->getTestInstances();
$uid = 'alice';
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$this->assertSame($dn, $user->getDN());
$this->assertSame($uid, $user->getUsername());
}
public function testUpdateEmailProvided() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
- $this->getAdvancedMocks($config, $filesys, $log, $avaMgr, $dbc, $userMgr);
+ $this->getAdvancedMocks($config, $filesys, $log, $avaMgr, $dbc, $userMgr, $notiMgr);
$connection->expects($this->once())
->method('__get')
@@ -140,13 +145,13 @@ class UserTest extends \Test\TestCase {
->method('get')
->willReturn($uuser);
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$user->updateEmail();
}
public function testUpdateEmailNotProvided() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
@@ -170,13 +175,13 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$user->updateEmail();
}
public function testUpdateEmailNotConfigured() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
@@ -197,13 +202,13 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$user->updateEmail();
}
public function testUpdateQuotaAllProvided() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
@@ -244,13 +249,13 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$user->updateQuota();
}
public function testUpdateQuotaToDefaultAllProvided() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
@@ -284,13 +289,13 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$user->updateQuota();
}
public function testUpdateQuotaToNoneAllProvided() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
@@ -324,13 +329,13 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$user->updateQuota();
}
public function testUpdateQuotaDefaultProvided() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
@@ -369,13 +374,13 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$user->updateQuota();
}
public function testUpdateQuotaIndividualProvided() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
@@ -416,13 +421,13 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$user->updateQuota();
}
public function testUpdateQuotaNoneProvided() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
@@ -464,13 +469,13 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$user->updateQuota();
}
public function testUpdateQuotaNoneConfigured() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
@@ -510,13 +515,13 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$user->updateQuota();
}
public function testUpdateQuotaFromValue() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
@@ -545,7 +550,7 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$user->updateQuota($readQuota);
}
@@ -554,7 +559,7 @@ class UserTest extends \Test\TestCase {
* Unparseable quota will fallback to use the LDAP default
*/
public function testUpdateWrongQuotaAllProvided() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
@@ -593,7 +598,7 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$user->updateQuota();
}
@@ -602,7 +607,7 @@ class UserTest extends \Test\TestCase {
* No user quota and wrong default will set 'default' as quota
*/
public function testUpdateWrongDefaultQuotaProvided() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
@@ -641,7 +646,7 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$user->updateQuota();
}
@@ -650,7 +655,7 @@ class UserTest extends \Test\TestCase {
* Wrong user quota and wrong default will set 'default' as quota
*/
public function testUpdateWrongQuotaAndDefaultAllProvided() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
@@ -689,7 +694,7 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$user->updateQuota();
}
@@ -698,7 +703,7 @@ class UserTest extends \Test\TestCase {
* No quota attribute set and wrong default will set 'default' as quota
*/
public function testUpdateWrongDefaultQuotaNotProvided() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
@@ -734,14 +739,14 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$user->updateQuota();
}
//the testUpdateAvatar series also implicitely tests getAvatarImage
public function testUpdateAvatarJpegPhotoProvided() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
@@ -784,13 +789,13 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$user->updateAvatar();
}
public function testUpdateAvatarThumbnailPhotoProvided() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
@@ -842,13 +847,13 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$user->updateAvatar();
}
public function testUpdateAvatarNotProvided() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
@@ -888,13 +893,13 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$user->updateAvatar();
}
public function testUpdateBeforeFirstLogin() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
@@ -924,13 +929,13 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$user->update();
}
public function testUpdateAfterFirstLogin() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
@@ -964,13 +969,13 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$user->update();
}
public function testUpdateNoRefresh() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
@@ -1000,13 +1005,13 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$user->update();
}
public function testMarkLogin() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $db, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $db, $userMgr, $notiMgr) =
$this->getTestInstances();
$config->expects($this->once())
@@ -1021,13 +1026,13 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$user->markLogin();
}
public function testGetAvatarImageProvided() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $db, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $db, $userMgr, $notiMgr) =
$this->getTestInstances();
$access->expects($this->once())
@@ -1040,7 +1045,7 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$photo = $user->getAvatarImage();
$this->assertSame('this is a photo', $photo);
@@ -1050,7 +1055,7 @@ class UserTest extends \Test\TestCase {
}
public function testProcessAttributes() {
- list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
@@ -1070,7 +1075,7 @@ class UserTest extends \Test\TestCase {
);
$userMock = $this->getMockBuilder('OCA\User_LDAP\User\User')
- ->setConstructorArgs(array($uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr))
+ ->setConstructorArgs(array($uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr))
->setMethods($requiredMethods)
->getMock();
@@ -1102,7 +1107,7 @@ class UserTest extends \Test\TestCase {
$userMock->expects($this->once())
->method($method);
}
-
+ \OC_Hook::clear();//disconnect irrelevant hooks
$userMock->processAttributes($record);
\OC_Hook::emit('OC_User', 'post_login', array('uid' => $uid));
}
@@ -1118,7 +1123,7 @@ class UserTest extends \Test\TestCase {
* @dataProvider emptyHomeFolderAttributeValueProvider
*/
public function testGetHomePathNotConfigured($attributeValue) {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
@@ -1139,14 +1144,14 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$path = $user->getHomePath();
$this->assertSame($path, false);
}
public function testGetHomePathConfiguredNotAvailableAllowed() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
@@ -1170,7 +1175,7 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$path = $user->getHomePath();
@@ -1181,11 +1186,11 @@ class UserTest extends \Test\TestCase {
* @expectedException \Exception
*/
public function testGetHomePathConfiguredNotAvailableNotAllowed() {
- list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
$this->getTestInstances();
list($access, $connection) =
- $this->getAdvancedMocks($config, $filesys, $log, $avaMgr, $dbc, $userMgr);
+ $this->getAdvancedMocks($config, $filesys, $log, $avaMgr, $dbc, $userMgr, $notiMgr);
$connection->expects($this->any())
->method('__get')
@@ -1205,7 +1210,7 @@ class UserTest extends \Test\TestCase {
$dn = 'uid=alice,dc=foo,dc=bar';
$user = new User(
- $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$user->getHomePath();
}
@@ -1222,16 +1227,161 @@ class UserTest extends \Test\TestCase {
* @dataProvider displayNameProvider
*/
public function testComposeAndStoreDisplayName($part1, $part2, $expected) {
- list($access, $config, $filesys, $image, $log, $avaMgr, , $userMgr) =
+ list($access, $config, $filesys, $image, $log, $avaMgr, , $userMgr, $notiMgr) =
$this->getTestInstances();
$config->expects($this->once())
->method('setUserValue');
$user = new User(
- 'user', 'cn=user', $access, $config, $filesys, $image, $log, $avaMgr, $userMgr);
+ 'user', 'cn=user', $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
$displayName = $user->composeAndStoreDisplayName($part1, $part2);
$this->assertSame($expected, $displayName);
}
+
+ public function testHandlePasswordExpiryWarningDefaultPolicy() {
+ list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
+ $this->getTestInstances();
+
+ list($access, $connection) =
+ $this->getAdvancedMocks($config, $filesys, $log, $avaMgr, $dbc);
+
+ $uid = 'alice';
+ $dn = 'uid=alice';
+
+ $connection->expects($this->any())
+ ->method('__get')
+ ->will($this->returnCallback(function($name) {
+ if($name === 'ldapDefaultPPolicyDN') {
+ return 'cn=default,ou=policies,dc=foo,dc=bar';
+ }
+ if($name === 'turnOnPasswordChange') {
+ return '1';
+ }
+ return $name;
+ }));
+
+ $access->expects($this->any())
+ ->method('search')
+ ->will($this->returnCallback(function($filter, $base) {
+ if($base === 'uid=alice') {
+ return array(
+ array(
+ 'pwdchangedtime' => array((new \DateTime())->sub(new \DateInterval('P28D'))->format('Ymdhis').'Z'),
+ ),
+ );
+ }
+ if($base === 'cn=default,ou=policies,dc=foo,dc=bar') {
+ return array(
+ array(
+ 'pwdmaxage' => array('2592000'),
+ 'pwdexpirewarning' => array('2591999'),
+ ),
+ );
+ }
+ return array();
+ }));
+
+ $notification = $this->getMockBuilder('OCP\Notification\INotification')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $notification->expects($this->any())
+ ->method('setApp')
+ ->will($this->returnValue($notification));
+ $notification->expects($this->any())
+ ->method('setUser')
+ ->will($this->returnValue($notification));
+ $notification->expects($this->any())
+ ->method('setObject')
+ ->will($this->returnValue($notification));
+ $notification->expects($this->any())
+ ->method('setDateTime')
+ ->will($this->returnValue($notification));
+ $notiMgr->expects($this->exactly(2))
+ ->method('createNotification')
+ ->will($this->returnValue($notification));
+ $notiMgr->expects($this->exactly(1))
+ ->method('notify');
+
+ $user = new User(
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
+
+ \OC_Hook::clear();//disconnect irrelevant hooks
+ \OCP\Util::connectHook('OC_User', 'post_login', $user, 'handlePasswordExpiry');
+ \OC_Hook::emit('OC_User', 'post_login', array('uid' => $uid));
+ }
+
+ public function testHandlePasswordExpiryWarningCustomPolicy() {
+ list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) =
+ $this->getTestInstances();
+
+ list($access, $connection) =
+ $this->getAdvancedMocks($config, $filesys, $log, $avaMgr, $dbc);
+
+ $uid = 'alice';
+ $dn = 'uid=alice';
+
+ $connection->expects($this->any())
+ ->method('__get')
+ ->will($this->returnCallback(function($name) {
+ if($name === 'ldapDefaultPPolicyDN') {
+ return 'cn=default,ou=policies,dc=foo,dc=bar';
+ }
+ if($name === 'turnOnPasswordChange') {
+ return '1';
+ }
+ return $name;
+ }));
+
+ $access->expects($this->any())
+ ->method('search')
+ ->will($this->returnCallback(function($filter, $base) {
+ if($base === 'uid=alice') {
+ return array(
+ array(
+ 'pwdpolicysubentry' => array('cn=custom,ou=policies,dc=foo,dc=bar'),
+ 'pwdchangedtime' => array((new \DateTime())->sub(new \DateInterval('P28D'))->format('Ymdhis').'Z'),
+ )
+ );
+ }
+ if($base === 'cn=custom,ou=policies,dc=foo,dc=bar') {
+ return array(
+ array(
+ 'pwdmaxage' => array('2592000'),
+ 'pwdexpirewarning' => array('2591999'),
+ )
+ );
+ }
+ return array();
+ }));
+
+ $notification = $this->getMockBuilder('OCP\Notification\INotification')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $notification->expects($this->any())
+ ->method('setApp')
+ ->will($this->returnValue($notification));
+ $notification->expects($this->any())
+ ->method('setUser')
+ ->will($this->returnValue($notification));
+ $notification->expects($this->any())
+ ->method('setObject')
+ ->will($this->returnValue($notification));
+ $notification->expects($this->any())
+ ->method('setDateTime')
+ ->will($this->returnValue($notification));
+ $notiMgr->expects($this->exactly(2))
+ ->method('createNotification')
+ ->will($this->returnValue($notification));
+ $notiMgr->expects($this->exactly(1))
+ ->method('notify');
+
+ $user = new User(
+ $uid, $dn, $access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
+
+ \OC_Hook::clear();//disconnect irrelevant hooks
+ \OCP\Util::connectHook('OC_User', 'post_login', $user, 'handlePasswordExpiry');
+ \OC_Hook::emit('OC_User', 'post_login', array('uid' => $uid));
+ }
}
diff --git a/apps/user_ldap/tests/User_LDAPTest.php b/apps/user_ldap/tests/User_LDAPTest.php
index 1b1f9fdec78..aaf67ebcab6 100644
--- a/apps/user_ldap/tests/User_LDAPTest.php
+++ b/apps/user_ldap/tests/User_LDAPTest.php
@@ -47,6 +47,7 @@ use OCP\IDBConnection;
use OCP\Image;
use OCP\IUserManager;
use Test\TestCase;
+use OCP\Notification\IManager as INotificationManager;
/**
* Class Test_User_Ldap_Direct
@@ -92,7 +93,8 @@ class User_LDAPTest extends TestCase {
$this->createMock(IAvatarManager::class),
$this->createMock(Image::class),
$this->createMock(IDBConnection::class),
- $this->createMock(IUserManager::class)
+ $this->createMock(IUserManager::class),
+ $this->createMock(INotificationManager::class)
])
->getMock();
@@ -197,7 +199,7 @@ class User_LDAPTest extends TestCase {
$access = $this->getAccessMock();
$this->prepareAccessForCheckPassword($access);
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
\OC_User::useBackend($backend);
$result = $backend->checkPassword('roland', 'dt19');
@@ -208,7 +210,7 @@ class User_LDAPTest extends TestCase {
$access = $this->getAccessMock();
$this->prepareAccessForCheckPassword($access);
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
\OC_User::useBackend($backend);
$result = $backend->checkPassword('roland', 'wrong');
@@ -219,7 +221,7 @@ class User_LDAPTest extends TestCase {
$access = $this->getAccessMock();
$this->prepareAccessForCheckPassword($access);
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
\OC_User::useBackend($backend);
$result = $backend->checkPassword('mallory', 'evil');
@@ -234,7 +236,7 @@ class User_LDAPTest extends TestCase {
->method('username2dn')
->will($this->returnValue(false));
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
\OC_User::useBackend($backend);
$result = $backend->checkPassword('roland', 'dt19');
@@ -244,7 +246,7 @@ class User_LDAPTest extends TestCase {
public function testCheckPasswordPublicAPI() {
$access = $this->getAccessMock();
$this->prepareAccessForCheckPassword($access);
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
\OC_User::useBackend($backend);
$result = \OCP\User::checkPassword('roland', 'dt19');
@@ -254,7 +256,7 @@ class User_LDAPTest extends TestCase {
public function testCheckPasswordPublicAPIWrongPassword() {
$access = $this->getAccessMock();
$this->prepareAccessForCheckPassword($access);
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
\OC_User::useBackend($backend);
$result = \OCP\User::checkPassword('roland', 'wrong');
@@ -264,7 +266,7 @@ class User_LDAPTest extends TestCase {
public function testCheckPasswordPublicAPIWrongUser() {
$access = $this->getAccessMock();
$this->prepareAccessForCheckPassword($access);
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
\OC_User::useBackend($backend);
$result = \OCP\User::checkPassword('mallory', 'evil');
@@ -273,7 +275,7 @@ class User_LDAPTest extends TestCase {
public function testDeleteUserCancel() {
$access = $this->getAccessMock();
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
$result = $backend->deleteUser('notme');
$this->assertFalse($result);
}
@@ -295,7 +297,7 @@ class User_LDAPTest extends TestCase {
->method('getUserValue')
->will($this->onConsecutiveCalls('1', '/var/vhome/jdings/'));
- $backend = new UserLDAP($access, $config);
+ $backend = new UserLDAP($access, $config, $this->createMock(INotificationManager::class));
$result = $backend->deleteUser('jeremy');
$this->assertTrue($result);
@@ -356,7 +358,7 @@ class User_LDAPTest extends TestCase {
public function testGetUsersNoParam() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
$result = $backend->getUsers();
$this->assertEquals(3, count($result));
@@ -365,7 +367,7 @@ class User_LDAPTest extends TestCase {
public function testGetUsersLimitOffset() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
$result = $backend->getUsers('', 1, 2);
$this->assertEquals(1, count($result));
@@ -374,7 +376,7 @@ class User_LDAPTest extends TestCase {
public function testGetUsersLimitOffset2() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
$result = $backend->getUsers('', 2, 1);
$this->assertEquals(2, count($result));
@@ -383,7 +385,7 @@ class User_LDAPTest extends TestCase {
public function testGetUsersSearchWithResult() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
$result = $backend->getUsers('yo');
$this->assertEquals(2, count($result));
@@ -392,7 +394,7 @@ class User_LDAPTest extends TestCase {
public function testGetUsersSearchEmptyResult() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
$result = $backend->getUsers('nix');
$this->assertEquals(0, count($result));
@@ -401,7 +403,7 @@ class User_LDAPTest extends TestCase {
public function testGetUsersViaAPINoParam() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
\OC_User::useBackend($backend);
$result = \OCP\User::getUsers();
@@ -411,7 +413,7 @@ class User_LDAPTest extends TestCase {
public function testGetUsersViaAPILimitOffset() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
\OC_User::useBackend($backend);
$result = \OCP\User::getUsers('', 1, 2);
@@ -421,7 +423,7 @@ class User_LDAPTest extends TestCase {
public function testGetUsersViaAPILimitOffset2() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
\OC_User::useBackend($backend);
$result = \OCP\User::getUsers('', 2, 1);
@@ -431,7 +433,7 @@ class User_LDAPTest extends TestCase {
public function testGetUsersViaAPISearchWithResult() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
\OC_User::useBackend($backend);
$result = \OCP\User::getUsers('yo');
@@ -441,7 +443,7 @@ class User_LDAPTest extends TestCase {
public function testGetUsersViaAPISearchEmptyResult() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
\OC_User::useBackend($backend);
$result = \OCP\User::getUsers('nix');
@@ -450,7 +452,7 @@ class User_LDAPTest extends TestCase {
public function testUserExists() {
$access = $this->getAccessMock();
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
$this->prepareMockForUserExists($access);
$access->expects($this->any())
@@ -472,7 +474,7 @@ class User_LDAPTest extends TestCase {
*/
public function testUserExistsForDeleted() {
$access = $this->getAccessMock();
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
$this->prepareMockForUserExists($access);
$access->expects($this->any())
@@ -490,7 +492,7 @@ class User_LDAPTest extends TestCase {
public function testUserExistsForNeverExisting() {
$access = $this->getAccessMock();
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
$this->prepareMockForUserExists($access);
$access->expects($this->any())
@@ -509,7 +511,7 @@ class User_LDAPTest extends TestCase {
public function testUserExistsPublicAPI() {
$access = $this->getAccessMock();
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
$this->prepareMockForUserExists($access);
\OC_User::useBackend($backend);
@@ -532,7 +534,7 @@ class User_LDAPTest extends TestCase {
*/
public function testUserExistsPublicAPIForDeleted() {
$access = $this->getAccessMock();
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
$this->prepareMockForUserExists($access);
\OC_User::useBackend($backend);
@@ -551,7 +553,7 @@ class User_LDAPTest extends TestCase {
public function testUserExistsPublicAPIForNeverExisting() {
$access = $this->getAccessMock();
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
$this->prepareMockForUserExists($access);
\OC_User::useBackend($backend);
@@ -571,7 +573,7 @@ class User_LDAPTest extends TestCase {
public function testDeleteUser() {
$access = $this->getAccessMock();
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
//we do not support deleting users at all
$result = $backend->deleteUser('gunslinger');
@@ -581,7 +583,8 @@ class User_LDAPTest extends TestCase {
public function testGetHomeAbsolutePath() {
$access = $this->getAccessMock();
$config = $this->createMock(IConfig::class);
- $backend = new UserLDAP($access, $config);
+ $noti = $this->createMock(INotificationManager::class);
+ $backend = new UserLDAP($access, $config, $noti);
$this->prepareMockForUserExists($access);
$access->connection->expects($this->any())
@@ -616,7 +619,8 @@ class User_LDAPTest extends TestCase {
public function testGetHomeRelative() {
$access = $this->getAccessMock();
$config = $this->createMock(IConfig::class);
- $backend = new UserLDAP($access, $config);
+ $noti = $this->createMock(INotificationManager::class);
+ $backend = new UserLDAP($access, $config, $noti);
$this->prepareMockForUserExists($access);
$dataDir = \OC::$server->getConfig()->getSystemValue(
@@ -659,7 +663,7 @@ class User_LDAPTest extends TestCase {
*/
public function testGetHomeNoPath() {
$access = $this->getAccessMock();
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
$this->prepareMockForUserExists($access);
$access->connection->expects($this->any())
@@ -690,7 +694,7 @@ class User_LDAPTest extends TestCase {
*/
public function testGetHomeDeletedUser() {
$access = $this->getAccessMock();
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
$this->prepareMockForUserExists($access);
$access->connection->expects($this->any())
@@ -761,7 +765,7 @@ class User_LDAPTest extends TestCase {
public function testGetDisplayName() {
$access = $this->getAccessMock();
$this->prepareAccessForGetDisplayName($access);
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
$this->prepareMockForUserExists($access);
$access->connection->expects($this->any())
@@ -802,7 +806,7 @@ class User_LDAPTest extends TestCase {
}
}));
$this->prepareAccessForGetDisplayName($access);
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
$this->prepareMockForUserExists($access);
$access->connection->expects($this->any())
@@ -832,7 +836,7 @@ class User_LDAPTest extends TestCase {
->method('countUsers')
->will($this->returnValue(5));
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
$result = $backend->countUsers();
$this->assertEquals(5, $result);
@@ -845,7 +849,7 @@ class User_LDAPTest extends TestCase {
->method('countUsers')
->will($this->returnValue(false));
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
$result = $backend->countUsers();
$this->assertFalse($result);
@@ -878,7 +882,7 @@ class User_LDAPTest extends TestCase {
->method('writeToCache')
->with($this->equalTo('loginName2UserName-'.$loginName), $this->equalTo($username));
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
$name = $backend->loginName2UserName($loginName);
$this->assertSame($username, $name);
@@ -907,7 +911,7 @@ class User_LDAPTest extends TestCase {
->method('writeToCache')
->with($this->equalTo('loginName2UserName-'.$loginName), false);
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
$name = $backend->loginName2UserName($loginName);
$this->assertSame(false, $name);
@@ -954,7 +958,7 @@ class User_LDAPTest extends TestCase {
->method('getUserValue')
->willReturn(1);
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
$name = $backend->loginName2UserName($loginName);
$this->assertSame(false, $name);
@@ -1035,7 +1039,7 @@ class User_LDAPTest extends TestCase {
$access = $this->getAccessMock();
$this->prepareAccessForSetPassword($access);
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
\OC_User::useBackend($backend);
$this->assertTrue(\OC_User::setPassword('roland', 'dt'));
@@ -1045,17 +1049,17 @@ class User_LDAPTest extends TestCase {
$access = $this->getAccessMock();
$this->prepareAccessForSetPassword($access);
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
\OC_User::useBackend($backend);
$this->assertTrue(\OC_User::setPassword('roland', 'dt12234$'));
}
-
+
public function testSetPasswordValidDisabled() {
$access = $this->getAccessMock();
$this->prepareAccessForSetPassword($access, false);
- $backend = new UserLDAP($access, $this->createMock(IConfig::class));
+ $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class));
\OC_User::useBackend($backend);
$this->assertFalse(\OC_User::setPassword('roland', 'dt12234$'));
@@ -1074,9 +1078,11 @@ class User_LDAPTest extends TestCase {
->with('NotExistingUser')
->willReturn(null);
$config = $this->createMock(IConfig::class);
+ $noti = $this->createMock(INotificationManager::class);
$ldap = new User_LDAP(
$access,
- $config
+ $config,
+ $noti
);
$ldap->setPassword('NotExistingUser', 'Password');
}
@@ -1095,9 +1101,11 @@ class User_LDAPTest extends TestCase {
->with('NotExistingUser')
->willReturn($user);
$config = $this->createMock(IConfig::class);
+ $noti = $this->createMock(INotificationManager::class);
$ldap = new User_LDAP(
$access,
- $config
+ $config,
+ $noti
);
$this->assertFalse($ldap->setPassword('NotExistingUser', 'Password'));
}
diff --git a/apps/user_ldap/tests/User_ProxyTest.php b/apps/user_ldap/tests/User_ProxyTest.php
index 6d779d758e4..df021a6de3d 100644
--- a/apps/user_ldap/tests/User_ProxyTest.php
+++ b/apps/user_ldap/tests/User_ProxyTest.php
@@ -24,6 +24,7 @@ namespace OCA\User_LDAP\Tests;
use OCA\User_LDAP\ILDAPWrapper;
use OCA\User_LDAP\User_Proxy;
use OCP\IConfig;
+use OCP\Notification\IManager as INotificationManager;
use Test\TestCase;
class User_ProxyTest extends TestCase {
@@ -31,6 +32,8 @@ class User_ProxyTest extends TestCase {
private $ldapWrapper;
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
private $config;
+ /** @var IManager|\PHPUnit_Framework_MockObject_MockObject */
+ private $notificationManager;
/** @var User_Proxy|\PHPUnit_Framework_MockObject_MockObject */
private $proxy;
@@ -39,11 +42,13 @@ class User_ProxyTest extends TestCase {
$this->ldapWrapper = $this->createMock(ILDAPWrapper::class);
$this->config = $this->createMock(IConfig::class);
+ $this->notificationManager = $this->createMock(INotificationManager::class);
$this->proxy = $this->getMockBuilder(User_Proxy::class)
->setConstructorArgs([
[],
$this->ldapWrapper,
$this->config,
+ $this->notificationManager,
])
->setMethods(['handleRequest'])
->getMock();