summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/AppInfo/Application.php1
-rw-r--r--apps/dav/lib/CalDAV/CalDavBackend.php30
-rw-r--r--apps/dav/lib/CalDAV/Publishing/Xml/Publisher.php1
-rw-r--r--apps/dav/lib/CalDAV/Schedule/IMipPlugin.php1
-rw-r--r--apps/dav/lib/CardDAV/CardDavBackend.php49
-rw-r--r--apps/dav/lib/CardDAV/Xml/Groups.php1
-rw-r--r--apps/dav/lib/Command/CreateAddressBook.php5
-rw-r--r--apps/dav/lib/Command/SyncSystemAddressBook.php2
-rw-r--r--apps/dav/lib/Connector/Sabre/BlockLegacyClientPlugin.php1
-rw-r--r--apps/dav/lib/Connector/Sabre/ChecksumList.php1
-rw-r--r--apps/dav/lib/Connector/Sabre/DavAclPlugin.php6
-rw-r--r--apps/dav/lib/Connector/Sabre/FilesPlugin.php3
-rw-r--r--apps/dav/lib/Connector/Sabre/LockPlugin.php1
-rw-r--r--apps/dav/lib/Connector/Sabre/SharesPlugin.php2
-rw-r--r--apps/dav/lib/DAV/Sharing/Plugin.php2
-rw-r--r--apps/dav/lib/HookManager.php1
-rw-r--r--apps/dav/lib/SystemTag/SystemTagPlugin.php3
-rw-r--r--apps/dav/lib/SystemTag/SystemTagsByIdCollection.php2
-rw-r--r--apps/dav/lib/SystemTag/SystemTagsObjectMappingCollection.php1
-rw-r--r--apps/dav/lib/SystemTag/SystemTagsObjectTypeCollection.php1
-rw-r--r--apps/dav/lib/Upload/FutureFile.php1
-rw-r--r--apps/dav/tests/unit/CalDAV/AbstractCalDavBackendTest.php3
-rw-r--r--apps/dav/tests/unit/CalDAV/CalDavBackendTest.php2
-rw-r--r--apps/dav/tests/unit/CardDAV/CardDavBackendTest.php4
-rw-r--r--apps/dav/tests/unit/CardDAV/ConverterTest.php1
-rw-r--r--apps/dav/tests/unit/Comments/CommentsNodeTest.php1
-rw-r--r--apps/dav/tests/unit/Comments/CommentsPluginTest.php1
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/ExceptionLoggerPluginTest.php1
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php1
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/RequestTest/DeleteTest.php2
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/RequestTest/ExceptionPlugin.php2
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php3
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTest.php4
-rw-r--r--apps/dav/tests/unit/DAV/HookManagerTest.php3
-rw-r--r--apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php1
-rw-r--r--apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php1
-rw-r--r--apps/federatedfilesharing/lib/Controller/RequestHandlerController.php1
-rw-r--r--apps/federatedfilesharing/tests/js/externalSpec.js6
-rw-r--r--apps/federation/lib/AppInfo/Application.php4
-rw-r--r--apps/federation/lib/Command/SyncFederationAddressBooks.php1
-rw-r--r--apps/files/lib/Command/DeleteOrphanedFiles.php2
-rw-r--r--apps/files/lib/Command/ScanAppData.php2
-rw-r--r--apps/files/lib/Controller/ViewController.php1
-rw-r--r--apps/files/tests/Controller/ApiControllerTest.php2
-rw-r--r--apps/files/tests/js/filelistSpec.js2
-rw-r--r--apps/files_external/lib/Lib/Backend/SFTP.php3
-rw-r--r--apps/files_external/lib/Lib/Storage/SFTP.php1
-rw-r--r--apps/files_external/lib/Lib/Storage/SMB.php3
-rw-r--r--apps/files_external/tests/js/settingsSpec.js2
-rw-r--r--apps/files_sharing/css/sharetabview.scss5
-rw-r--r--apps/files_sharing/lib/AppInfo/Application.php1
-rw-r--r--apps/files_sharing/lib/Cache.php1
-rw-r--r--apps/files_sharing/lib/External/Manager.php1
-rw-r--r--apps/files_sharing/lib/External/Storage.php1
-rw-r--r--apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php1
-rw-r--r--apps/provisioning_api/lib/Controller/AppsController.php1
-rw-r--r--apps/testing/locking/provisioning.php1
-rw-r--r--apps/user_ldap/ajax/wizard.php3
-rw-r--r--apps/user_ldap/appinfo/app.php19
-rw-r--r--apps/user_ldap/appinfo/register_command.php3
-rw-r--r--apps/user_ldap/appinfo/routes.php10
-rw-r--r--apps/user_ldap/css/renewPassword.css20
-rw-r--r--apps/user_ldap/js/renewPassword.js50
-rw-r--r--apps/user_ldap/js/wizard/wizardTabAdvanced.js15
-rw-r--r--apps/user_ldap/lib/Access.php2
-rw-r--r--apps/user_ldap/lib/AppInfo/Application.php52
-rw-r--r--apps/user_ldap/lib/Command/Search.php2
-rw-r--r--apps/user_ldap/lib/Configuration.php3
-rw-r--r--apps/user_ldap/lib/Controller/RenewPasswordController.php180
-rw-r--r--apps/user_ldap/lib/Exceptions/ConstraintViolationException.php2
-rw-r--r--apps/user_ldap/lib/Helper.php3
-rw-r--r--apps/user_ldap/lib/Jobs/CleanUp.php3
-rw-r--r--apps/user_ldap/lib/Jobs/UpdateGroups.php3
-rw-r--r--apps/user_ldap/lib/Migration/UUIDFixGroup.php3
-rw-r--r--apps/user_ldap/lib/Notification/Notifier.php71
-rw-r--r--apps/user_ldap/lib/Proxy.php5
-rw-r--r--apps/user_ldap/lib/User/Manager.php34
-rw-r--r--apps/user_ldap/lib/User/User.php129
-rw-r--r--apps/user_ldap/lib/User_LDAP.php23
-rw-r--r--apps/user_ldap/lib/User_Proxy.php6
-rw-r--r--apps/user_ldap/templates/renewpassword.php73
-rw-r--r--apps/user_ldap/templates/settings.php1
-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
92 files changed, 1059 insertions, 275 deletions
diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php
index 669c52d1489..b4f16f3cadf 100644
--- a/apps/dav/lib/AppInfo/Application.php
+++ b/apps/dav/lib/AppInfo/Application.php
@@ -25,7 +25,6 @@
namespace OCA\DAV\AppInfo;
use OCA\DAV\CalDAV\Activity\Backend;
-use OCA\DAV\CalDAV\Activity\Extension;
use OCA\DAV\CalDAV\Activity\Provider\Event;
use OCA\DAV\CalDAV\BirthdayService;
use OCA\DAV\Capabilities;
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php
index 631593974e7..a4fed4f1982 100644
--- a/apps/dav/lib/CalDAV/CalDavBackend.php
+++ b/apps/dav/lib/CalDAV/CalDavBackend.php
@@ -248,6 +248,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
$calendar[$xmlName] = $row[$dbName];
}
+ $this->addOwnerPrincipal($calendar);
+
if (!isset($calendars[$calendar['id']])) {
$calendars[$calendar['id']] = $calendar;
}
@@ -319,6 +321,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
$calendar[$xmlName] = $row[$dbName];
}
+ $this->addOwnerPrincipal($calendar);
+
$calendars[$calendar['id']] = $calendar;
}
$result->closeCursor();
@@ -359,6 +363,9 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
foreach($this->propertyMap as $xmlName=>$dbName) {
$calendar[$xmlName] = $row[$dbName];
}
+
+ $this->addOwnerPrincipal($calendar);
+
if (!isset($calendars[$calendar['id']])) {
$calendars[$calendar['id']] = $calendar;
}
@@ -428,6 +435,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
$calendar[$xmlName] = $row[$dbName];
}
+ $this->addOwnerPrincipal($calendar);
+
if (!isset($calendars[$calendar['id']])) {
$calendars[$calendar['id']] = $calendar;
}
@@ -492,6 +501,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
$calendar[$xmlName] = $row[$dbName];
}
+ $this->addOwnerPrincipal($calendar);
+
return $calendar;
}
@@ -543,6 +554,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
$calendar[$xmlName] = $row[$dbName];
}
+ $this->addOwnerPrincipal($calendar);
+
return $calendar;
}
@@ -587,6 +600,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
$calendar[$xmlName] = $row[$dbName];
}
+ $this->addOwnerPrincipal($calendar);
+
return $calendar;
}
@@ -1815,4 +1830,19 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
}
return $principalUri;
}
+
+ private function addOwnerPrincipal(&$calendarInfo) {
+ $ownerPrincipalKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal';
+ $displaynameKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname';
+ if (isset($calendarInfo[$ownerPrincipalKey])) {
+ $uri = $calendarInfo[$ownerPrincipalKey];
+ } else {
+ $uri = $calendarInfo['principaluri'];
+ }
+
+ $principalInformation = $this->principalBackend->getPrincipalByPath($uri);
+ if (isset($principalInformation['{DAV:}displayname'])) {
+ $calendarInfo[$displaynameKey] = $principalInformation['{DAV:}displayname'];
+ }
+ }
}
diff --git a/apps/dav/lib/CalDAV/Publishing/Xml/Publisher.php b/apps/dav/lib/CalDAV/Publishing/Xml/Publisher.php
index 1fdba22e9e0..5adbe71c433 100644
--- a/apps/dav/lib/CalDAV/Publishing/Xml/Publisher.php
+++ b/apps/dav/lib/CalDAV/Publishing/Xml/Publisher.php
@@ -20,7 +20,6 @@
*/
namespace OCA\DAV\CalDAV\Publishing\Xml;
-use OCA\DAV\CalDAV\Publishing\PublishPlugin as Plugin;
use Sabre\Xml\Writer;
use Sabre\Xml\XmlSerializable;
diff --git a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
index 843da65ce25..c21edb45848 100644
--- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
+++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
@@ -23,7 +23,6 @@ namespace OCA\DAV\CalDAV\Schedule;
use OCP\ILogger;
use OCP\Mail\IMailer;
-use Sabre\DAV;
use Sabre\VObject\ITip;
use Sabre\CalDAV\Schedule\IMipPlugin as SabreIMipPlugin;
/**
diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php
index f7963c0fa2b..cd010b87f08 100644
--- a/apps/dav/lib/CardDAV/CardDavBackend.php
+++ b/apps/dav/lib/CardDAV/CardDavBackend.php
@@ -155,6 +155,8 @@ class CardDavBackend implements BackendInterface, SyncSupport {
'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
];
+
+ $this->addOwnerPrincipal($addressBooks[$row['id']]);
}
$result->closeCursor();
@@ -206,6 +208,8 @@ class CardDavBackend implements BackendInterface, SyncSupport {
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'],
$readOnlyPropertyName => $readOnly,
];
+
+ $this->addOwnerPrincipal($addressBooks[$row['id']]);
}
$result->closeCursor();
@@ -232,6 +236,8 @@ class CardDavBackend implements BackendInterface, SyncSupport {
'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
];
+
+ $this->addOwnerPrincipal($addressBooks[$row['id']]);
}
$result->closeCursor();
@@ -268,7 +274,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
return null;
}
- return [
+ $addressBook = [
'id' => $row['id'],
'uri' => $row['uri'],
'principaluri' => $row['principaluri'],
@@ -277,6 +283,10 @@ class CardDavBackend implements BackendInterface, SyncSupport {
'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
];
+
+ $this->addOwnerPrincipal($addressBook);
+
+ return $addressBook;
}
/**
@@ -298,15 +308,19 @@ class CardDavBackend implements BackendInterface, SyncSupport {
return null;
}
- return [
- 'id' => $row['id'],
- 'uri' => $row['uri'],
- 'principaluri' => $row['principaluri'],
- '{DAV:}displayname' => $row['displayname'],
- '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
- '{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
- '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
- ];
+ $addressBook = [
+ 'id' => $row['id'],
+ 'uri' => $row['uri'],
+ 'principaluri' => $row['principaluri'],
+ '{DAV:}displayname' => $row['displayname'],
+ '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
+ '{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
+ '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
+ ];
+
+ $this->addOwnerPrincipal($addressBook);
+
+ return $addressBook;
}
/**
@@ -1086,4 +1100,19 @@ class CardDavBackend implements BackendInterface, SyncSupport {
}
return $principalUri;
}
+
+ private function addOwnerPrincipal(&$addressbookInfo) {
+ $ownerPrincipalKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal';
+ $displaynameKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname';
+ if (isset($addressbookInfo[$ownerPrincipalKey])) {
+ $uri = $addressbookInfo[$ownerPrincipalKey];
+ } else {
+ $uri = $addressbookInfo['principaluri'];
+ }
+
+ $principalInformation = $this->principalBackend->getPrincipalByPath($uri);
+ if (isset($principalInformation['{DAV:}displayname'])) {
+ $addressbookInfo[$displaynameKey] = $principalInformation['{DAV:}displayname'];
+ }
+ }
}
diff --git a/apps/dav/lib/CardDAV/Xml/Groups.php b/apps/dav/lib/CardDAV/Xml/Groups.php
index 1b439b6b821..9240b90a1eb 100644
--- a/apps/dav/lib/CardDAV/Xml/Groups.php
+++ b/apps/dav/lib/CardDAV/Xml/Groups.php
@@ -22,7 +22,6 @@
namespace OCA\DAV\CardDAV\Xml;
use Sabre\Xml\XmlSerializable;
-use Sabre\Xml\Element;
use Sabre\Xml\Writer;
class Groups implements XmlSerializable {
diff --git a/apps/dav/lib/Command/CreateAddressBook.php b/apps/dav/lib/Command/CreateAddressBook.php
index a0416966f05..96ad350121c 100644
--- a/apps/dav/lib/Command/CreateAddressBook.php
+++ b/apps/dav/lib/Command/CreateAddressBook.php
@@ -23,11 +23,6 @@
namespace OCA\DAV\Command;
use OCA\DAV\CardDAV\CardDavBackend;
-use OCA\DAV\Connector\Sabre\Principal;
-use OCP\IConfig;
-use OCP\IDBConnection;
-use OCP\IGroupManager;
-use OCP\ILogger;
use OCP\IUserManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
diff --git a/apps/dav/lib/Command/SyncSystemAddressBook.php b/apps/dav/lib/Command/SyncSystemAddressBook.php
index e642d9af5aa..e91ab38593d 100644
--- a/apps/dav/lib/Command/SyncSystemAddressBook.php
+++ b/apps/dav/lib/Command/SyncSystemAddressBook.php
@@ -22,10 +22,8 @@
namespace OCA\DAV\Command;
use OCA\DAV\CardDAV\SyncService;
-use OCP\IUserManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
-use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
diff --git a/apps/dav/lib/Connector/Sabre/BlockLegacyClientPlugin.php b/apps/dav/lib/Connector/Sabre/BlockLegacyClientPlugin.php
index 616816d3496..0a70d44395b 100644
--- a/apps/dav/lib/Connector/Sabre/BlockLegacyClientPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/BlockLegacyClientPlugin.php
@@ -26,7 +26,6 @@ namespace OCA\DAV\Connector\Sabre;
use OCP\IConfig;
use Sabre\HTTP\RequestInterface;
use Sabre\DAV\ServerPlugin;
-use Sabre\DAV\Exception;
/**
* Class BlockLegacyClientPlugin is used to detect old legacy sync clients and
diff --git a/apps/dav/lib/Connector/Sabre/ChecksumList.php b/apps/dav/lib/Connector/Sabre/ChecksumList.php
index 17e04a4c7a8..1bc38f75fb9 100644
--- a/apps/dav/lib/Connector/Sabre/ChecksumList.php
+++ b/apps/dav/lib/Connector/Sabre/ChecksumList.php
@@ -22,7 +22,6 @@
namespace OCA\DAV\Connector\Sabre;
use Sabre\Xml\XmlSerializable;
-use Sabre\Xml\Element;
use Sabre\Xml\Writer;
/**
diff --git a/apps/dav/lib/Connector/Sabre/DavAclPlugin.php b/apps/dav/lib/Connector/Sabre/DavAclPlugin.php
index 427a3756019..e77edd48651 100644
--- a/apps/dav/lib/Connector/Sabre/DavAclPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/DavAclPlugin.php
@@ -25,14 +25,8 @@ namespace OCA\DAV\Connector\Sabre;
use Sabre\CalDAV\Principal\User;
use Sabre\DAV\Exception\NotFound;
-use Sabre\DAV\IFile;
use Sabre\DAV\INode;
use \Sabre\DAV\PropFind;
-use \Sabre\DAV\PropPatch;
-use Sabre\DAVACL\Exception\NeedPrivileges;
-use \Sabre\HTTP\RequestInterface;
-use \Sabre\HTTP\ResponseInterface;
-use Sabre\HTTP\URLUtil;
/**
* Class DavAclPlugin is a wrapper around \Sabre\DAVACL\Plugin that returns 404
diff --git a/apps/dav/lib/Connector/Sabre/FilesPlugin.php b/apps/dav/lib/Connector/Sabre/FilesPlugin.php
index 2f86ce5bf41..5a08e37a153 100644
--- a/apps/dav/lib/Connector/Sabre/FilesPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/FilesPlugin.php
@@ -31,7 +31,6 @@
namespace OCA\DAV\Connector\Sabre;
use OC\Files\View;
-use OCA\DAV\Upload\FutureFile;
use OCP\Files\ForbiddenException;
use OCP\IPreview;
use Sabre\DAV\Exception\Forbidden;
@@ -46,8 +45,6 @@ use \Sabre\HTTP\ResponseInterface;
use OCP\Files\StorageNotAvailableException;
use OCP\IConfig;
use OCP\IRequest;
-use Sabre\DAV\Exception\BadRequest;
-use OCA\DAV\Connector\Sabre\Directory;
class FilesPlugin extends ServerPlugin {
diff --git a/apps/dav/lib/Connector/Sabre/LockPlugin.php b/apps/dav/lib/Connector/Sabre/LockPlugin.php
index de0aaed4c69..9731bc15f86 100644
--- a/apps/dav/lib/Connector/Sabre/LockPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/LockPlugin.php
@@ -26,7 +26,6 @@
namespace OCA\DAV\Connector\Sabre;
use OCA\DAV\Connector\Sabre\Exception\FileLocked;
-use OCA\DAV\Connector\Sabre\Node;
use OCP\Lock\ILockingProvider;
use OCP\Lock\LockedException;
use Sabre\DAV\Exception\NotFound;
diff --git a/apps/dav/lib/Connector/Sabre/SharesPlugin.php b/apps/dav/lib/Connector/Sabre/SharesPlugin.php
index 2b640d74fd4..9b06ef07810 100644
--- a/apps/dav/lib/Connector/Sabre/SharesPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/SharesPlugin.php
@@ -22,10 +22,8 @@
namespace OCA\DAV\Connector\Sabre;
use \Sabre\DAV\PropFind;
-use \Sabre\DAV\PropPatch;
use OCP\IUserSession;
use OCP\Share\IShare;
-use OCA\DAV\Connector\Sabre\ShareTypeList;
/**
* Sabre Plugin to provide share-related properties
diff --git a/apps/dav/lib/DAV/Sharing/Plugin.php b/apps/dav/lib/DAV/Sharing/Plugin.php
index 4cd95fe8a34..a1f034d54b5 100644
--- a/apps/dav/lib/DAV/Sharing/Plugin.php
+++ b/apps/dav/lib/DAV/Sharing/Plugin.php
@@ -25,7 +25,6 @@ namespace OCA\DAV\DAV\Sharing;
use OCA\DAV\Connector\Sabre\Auth;
use OCA\DAV\DAV\Sharing\Xml\Invite;
use OCP\IRequest;
-use Sabre\DAV\Exception\BadRequest;
use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\INode;
use Sabre\DAV\PropFind;
@@ -37,6 +36,7 @@ use Sabre\HTTP\ResponseInterface;
class Plugin extends ServerPlugin {
const NS_OWNCLOUD = 'http://owncloud.org/ns';
+ const NS_NEXTCLOUD = 'http://nextcloud.com/ns';
/** @var Auth */
private $auth;
diff --git a/apps/dav/lib/HookManager.php b/apps/dav/lib/HookManager.php
index 8148df2d37b..624e45dc55f 100644
--- a/apps/dav/lib/HookManager.php
+++ b/apps/dav/lib/HookManager.php
@@ -28,7 +28,6 @@ use OCP\IUser;
use OCP\IUserManager;
use OCP\Util;
use Symfony\Component\EventDispatcher\EventDispatcher;
-use Symfony\Component\EventDispatcher\GenericEvent;
class HookManager {
diff --git a/apps/dav/lib/SystemTag/SystemTagPlugin.php b/apps/dav/lib/SystemTag/SystemTagPlugin.php
index 87aebe51bee..d76bf2e689b 100644
--- a/apps/dav/lib/SystemTag/SystemTagPlugin.php
+++ b/apps/dav/lib/SystemTag/SystemTagPlugin.php
@@ -30,15 +30,12 @@ use Sabre\DAV\PropPatch;
use Sabre\DAV\Exception\BadRequest;
use Sabre\DAV\Exception\Conflict;
use Sabre\DAV\Exception\Forbidden;
-use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\Exception\UnsupportedMediaType;
-
use OCP\SystemTag\ISystemTag;
use OCP\SystemTag\ISystemTagManager;
use OCP\SystemTag\TagAlreadyExistsException;
use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface;
-use OCA\DAV\SystemTag\SystemTagMappingNode;
/**
* Sabre plugin to handle system tags:
diff --git a/apps/dav/lib/SystemTag/SystemTagsByIdCollection.php b/apps/dav/lib/SystemTag/SystemTagsByIdCollection.php
index 176a130774d..ca423739de4 100644
--- a/apps/dav/lib/SystemTag/SystemTagsByIdCollection.php
+++ b/apps/dav/lib/SystemTag/SystemTagsByIdCollection.php
@@ -27,13 +27,11 @@ use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\Exception\BadRequest;
use Sabre\DAV\ICollection;
-
use OCP\SystemTag\ISystemTagManager;
use OCP\SystemTag\ISystemTag;
use OCP\SystemTag\TagNotFoundException;
use OCP\IGroupManager;
use OCP\IUserSession;
-use OC\User\NoUserException;
class SystemTagsByIdCollection implements ICollection {
diff --git a/apps/dav/lib/SystemTag/SystemTagsObjectMappingCollection.php b/apps/dav/lib/SystemTag/SystemTagsObjectMappingCollection.php
index 124ed6184c1..5d54a7f4430 100644
--- a/apps/dav/lib/SystemTag/SystemTagsObjectMappingCollection.php
+++ b/apps/dav/lib/SystemTag/SystemTagsObjectMappingCollection.php
@@ -27,7 +27,6 @@ use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\Exception\BadRequest;
use Sabre\DAV\Exception\PreconditionFailed;
use Sabre\DAV\ICollection;
-
use OCP\SystemTag\ISystemTagManager;
use OCP\SystemTag\ISystemTagObjectMapper;
use OCP\SystemTag\ISystemTag;
diff --git a/apps/dav/lib/SystemTag/SystemTagsObjectTypeCollection.php b/apps/dav/lib/SystemTag/SystemTagsObjectTypeCollection.php
index 608a781cd77..0ed246faa5a 100644
--- a/apps/dav/lib/SystemTag/SystemTagsObjectTypeCollection.php
+++ b/apps/dav/lib/SystemTag/SystemTagsObjectTypeCollection.php
@@ -28,7 +28,6 @@ use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\Exception\MethodNotAllowed;
use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\ICollection;
-
use OCP\SystemTag\ISystemTagManager;
use OCP\SystemTag\ISystemTagObjectMapper;
use OCP\IUserSession;
diff --git a/apps/dav/lib/Upload/FutureFile.php b/apps/dav/lib/Upload/FutureFile.php
index 5dac34b4d6f..d86603fd8c2 100644
--- a/apps/dav/lib/Upload/FutureFile.php
+++ b/apps/dav/lib/Upload/FutureFile.php
@@ -23,7 +23,6 @@
namespace OCA\DAV\Upload;
use OCA\DAV\Connector\Sabre\Directory;
-use OCA\DAV\Upload\AssemblyStream;
use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\IFile;
diff --git a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackendTest.php
index ffdba9c5c8a..bc161b00d91 100644
--- a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackendTest.php
+++ b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackendTest.php
@@ -68,7 +68,8 @@ abstract class AbstractCalDavBackendTest extends TestCase {
->getMock();
$this->principal->expects($this->any())->method('getPrincipalByPath')
->willReturn([
- 'uri' => 'principals/best-friend'
+ 'uri' => 'principals/best-friend',
+ '{DAV:}displayname' => 'User\'s displayname',
]);
$this->principal->expects($this->any())->method('getGroupMembership')
->withAnyParameters()
diff --git a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
index 63ca03b0d3d..5adda30c19d 100644
--- a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
+++ b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
@@ -61,6 +61,7 @@ class CalDavBackendTest extends AbstractCalDavBackendTest {
$this->assertCount(1, $calendars);
$this->assertEquals('Unit test', $calendars[0]['{DAV:}displayname']);
$this->assertEquals('Calendar used for unit testing', $calendars[0]['{urn:ietf:params:xml:ns:caldav}calendar-description']);
+ $this->assertEquals('User\'s displayname', $calendars[0]['{http://nextcloud.com/ns}owner-displayname']);
// delete the address book
$this->dispatcher->expects($this->at(0))
@@ -410,6 +411,7 @@ EOD;
$publicCalendars = $this->backend->getPublicCalendars();
$this->assertCount(1, $publicCalendars);
$this->assertEquals(true, $publicCalendars[0]['{http://owncloud.org/ns}public']);
+ $this->assertEquals('User\'s displayname', $publicCalendars[0]['{http://nextcloud.com/ns}owner-displayname']);
$publicCalendarURI = $publicCalendars[0]['uri'];
$publicCalendar = $this->backend->getPublicCalendar($publicCalendarURI);
diff --git a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php
index a4445217469..c108432d65b 100644
--- a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php
+++ b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php
@@ -82,7 +82,8 @@ class CardDavBackendTest extends TestCase {
->getMock();
$this->principal->method('getPrincipalByPath')
->willReturn([
- 'uri' => 'principals/best-friend'
+ 'uri' => 'principals/best-friend',
+ '{DAV:}displayname' => 'User\'s displayname',
]);
$this->principal->method('getGroupMembership')
->withAnyParameters()
@@ -123,6 +124,7 @@ class CardDavBackendTest extends TestCase {
$books = $this->backend->getAddressBooksForUser(self::UNIT_TEST_USER);
$this->assertEquals(1, count($books));
$this->assertEquals('Example', $books[0]['{DAV:}displayname']);
+ $this->assertEquals('User\'s displayname', $books[0]['{http://nextcloud.com/ns}owner-displayname']);
// update it's display name
$patch = new PropPatch([
diff --git a/apps/dav/tests/unit/CardDAV/ConverterTest.php b/apps/dav/tests/unit/CardDAV/ConverterTest.php
index 448d80f3070..39853cfd5c8 100644
--- a/apps/dav/tests/unit/CardDAV/ConverterTest.php
+++ b/apps/dav/tests/unit/CardDAV/ConverterTest.php
@@ -29,7 +29,6 @@ use OCA\DAV\CardDAV\Converter;
use OCP\IDBConnection;
use OCP\IImage;
use OCP\IUser;
-use OpenCloud\ObjectStore\Resource\Account;
use PHPUnit_Framework_MockObject_MockObject;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Test\TestCase;
diff --git a/apps/dav/tests/unit/Comments/CommentsNodeTest.php b/apps/dav/tests/unit/Comments/CommentsNodeTest.php
index 94eaea01d56..226aa57598c 100644
--- a/apps/dav/tests/unit/Comments/CommentsNodeTest.php
+++ b/apps/dav/tests/unit/Comments/CommentsNodeTest.php
@@ -26,7 +26,6 @@
namespace OCA\DAV\Tests\unit\Comments;
use OCA\DAV\Comments\CommentNode;
-use OCP\Comments\IComment;
use OCP\Comments\ICommentsManager;
use OCP\Comments\MessageTooLongException;
diff --git a/apps/dav/tests/unit/Comments/CommentsPluginTest.php b/apps/dav/tests/unit/Comments/CommentsPluginTest.php
index bb512465a89..265afad96c3 100644
--- a/apps/dav/tests/unit/Comments/CommentsPluginTest.php
+++ b/apps/dav/tests/unit/Comments/CommentsPluginTest.php
@@ -28,7 +28,6 @@ namespace OCA\DAV\Tests\unit\Comments;
use OC\Comments\Comment;
use OCA\DAV\Comments\CommentsPlugin as CommentsPluginImplementation;
use OCP\Comments\IComment;
-use Sabre\DAV\Exception\NotFound;
class CommentsPluginTest extends \Test\TestCase {
/** @var \Sabre\DAV\Server */
diff --git a/apps/dav/tests/unit/Connector/Sabre/ExceptionLoggerPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/ExceptionLoggerPluginTest.php
index 225955beb07..8088ee6dc4d 100644
--- a/apps/dav/tests/unit/Connector/Sabre/ExceptionLoggerPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/ExceptionLoggerPluginTest.php
@@ -26,7 +26,6 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre;
use OCA\DAV\Connector\Sabre\Exception\InvalidPath;
use OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin as PluginToTest;
use OC\Log;
-use OCP\ILogger;
use PHPUnit_Framework_MockObject_MockObject;
use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\Server;
diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
index 54e5283c7c1..4d8a87b093f 100644
--- a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
@@ -28,7 +28,6 @@ use OCA\DAV\Connector\Sabre\FilesReportPlugin as FilesReportPluginImplementation
use OCP\IPreview;
use OCP\ITagManager;
use OCP\IUserSession;
-use Sabre\DAV\Exception\NotFound;
use OCP\SystemTag\ISystemTagObjectMapper;
use OC\Files\View;
use OCP\Files\Folder;
diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/DeleteTest.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/DeleteTest.php
index 240a51d01f2..7468e981020 100644
--- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/DeleteTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/DeleteTest.php
@@ -22,9 +22,7 @@
namespace OCA\DAV\Tests\unit\Connector\Sabre\RequestTest;
-use OC\Connector\Sabre\Exception\FileLocked;
use OCP\AppFramework\Http;
-use OCP\Lock\ILockingProvider;
/**
* Class DeleteTest
diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/ExceptionPlugin.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/ExceptionPlugin.php
index 0be2bc5ef79..16cd6ab9c2d 100644
--- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/ExceptionPlugin.php
+++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/ExceptionPlugin.php
@@ -24,8 +24,6 @@
namespace OCA\DAV\Tests\unit\Connector\Sabre\RequestTest;
-use Sabre\DAV\Exception;
-
class ExceptionPlugin extends \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin {
/**
* @var \Exception[]
diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php
index 00e012197d9..3f3bf16a422 100644
--- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php
@@ -24,9 +24,6 @@
namespace OCA\DAV\Tests\unit\Connector\Sabre\RequestTest;
-use OC\Files\View;
-use Test\Traits\EncryptionTrait;
-
/**
* Class PartFileInRootUploadTest
*
diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTest.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTest.php
index 10cd73baf63..63bd3cf19cc 100644
--- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTest.php
@@ -28,11 +28,7 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre\RequestTest;
use OCA\DAV\Connector\Sabre\Server;
use OCA\DAV\Connector\Sabre\ServerFactory;
-use OC\Files\Mount\MountPoint;
-use OC\Files\Storage\StorageFactory;
-use OC\Files\Storage\Temporary;
use OC\Files\View;
-use OCP\IUser;
use Sabre\HTTP\Request;
use Test\TestCase;
use Test\Traits\MountProviderTrait;
diff --git a/apps/dav/tests/unit/DAV/HookManagerTest.php b/apps/dav/tests/unit/DAV/HookManagerTest.php
index 375bda9f3c2..a78ffea5af4 100644
--- a/apps/dav/tests/unit/DAV/HookManagerTest.php
+++ b/apps/dav/tests/unit/DAV/HookManagerTest.php
@@ -23,7 +23,6 @@
namespace OCA\DAV\Tests\unit\DAV;
-use OCA\DAV\CalDAV\BirthdayService;
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\CardDAV\CardDavBackend;
use OCA\DAV\CardDAV\SyncService;
@@ -31,7 +30,7 @@ use OCA\DAV\HookManager;
use OCP\IL10N;
use OCP\IUser;
use OCP\IUserManager;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+use Symfony\Component\EventDispatcher\EventDispatcher;
use Test\TestCase;
class HookManagerTest extends TestCase {
diff --git a/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php b/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php
index c52b8fb1cf3..1831210546d 100644
--- a/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php
+++ b/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php
@@ -24,7 +24,6 @@
namespace OCA\DAV\Tests\unit\SystemTag;
-use Sabre\DAV\Exception\NotFound;
use OC\SystemTag\SystemTag;
use OCP\SystemTag\TagNotFoundException;
use OCP\SystemTag\ISystemTag;
diff --git a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
index 5cdba0cfffd..89fdbc64d9a 100644
--- a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
+++ b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
@@ -29,7 +29,6 @@ use OC\Files\Filesystem;
use OC\HintException;
use OC\Share\Helper;
use OCA\FederatedFileSharing\AddressHandler;
-use OCA\FederatedFileSharing\DiscoveryManager;
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\Files_Sharing\External\Manager;
use OCP\AppFramework\Controller;
diff --git a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
index 2b643810fb4..8a7a1188c28 100644
--- a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
+++ b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
@@ -26,7 +26,6 @@
namespace OCA\FederatedFileSharing\Controller;
-use OCA\FederatedFileSharing\DiscoveryManager;
use OCA\Files_Sharing\Activity\Providers\RemoteShares;
use OCA\FederatedFileSharing\AddressHandler;
use OCA\FederatedFileSharing\FederatedShareProvider;
diff --git a/apps/federatedfilesharing/tests/js/externalSpec.js b/apps/federatedfilesharing/tests/js/externalSpec.js
index 362df49252b..596c0ae60ac 100644
--- a/apps/federatedfilesharing/tests/js/externalSpec.js
+++ b/apps/federatedfilesharing/tests/js/externalSpec.js
@@ -8,6 +8,8 @@
*
*/
+/* global sinon */
+
describe('OCA.Sharing external tests', function() {
var plugin;
var urlQueryStub;
@@ -24,8 +26,8 @@ describe('OCA.Sharing external tests', function() {
plugin = OCA.Sharing.ExternalShareDialogPlugin;
urlQueryStub = sinon.stub(OC.Util.History, 'parseUrlQuery');
- confirmDialogStub = sinon.stub(OC.dialogs, 'confirm', dummyShowDialog);
- promptDialogStub = sinon.stub(OC.dialogs, 'prompt', dummyShowDialog);
+ confirmDialogStub = sinon.stub(OC.dialogs, 'confirm').callsFake(dummyShowDialog);
+ promptDialogStub = sinon.stub(OC.dialogs, 'prompt').callsFake(dummyShowDialog);
plugin.filesApp = {
fileList: {
diff --git a/apps/federation/lib/AppInfo/Application.php b/apps/federation/lib/AppInfo/Application.php
index 3166316b108..55647622915 100644
--- a/apps/federation/lib/AppInfo/Application.php
+++ b/apps/federation/lib/AppInfo/Application.php
@@ -24,17 +24,13 @@
namespace OCA\Federation\AppInfo;
-use OCA\Federation\API\OCSAuthAPI;
use OCA\Federation\Controller\SettingsController;
use OCA\Federation\DAV\FedAuth;
use OCA\Federation\DbHandler;
use OCA\Federation\Hooks;
use OCA\Federation\Middleware\AddServerMiddleware;
use OCA\Federation\SyncFederationAddressBooks;
-use OCA\Federation\SyncJob;
use OCA\Federation\TrustedServers;
-use OCP\API;
-use OCP\App;
use OCP\AppFramework\IAppContainer;
use OCP\SabrePluginEvent;
use OCP\Util;
diff --git a/apps/federation/lib/Command/SyncFederationAddressBooks.php b/apps/federation/lib/Command/SyncFederationAddressBooks.php
index bea75cc83a1..fb3a2749ff8 100644
--- a/apps/federation/lib/Command/SyncFederationAddressBooks.php
+++ b/apps/federation/lib/Command/SyncFederationAddressBooks.php
@@ -23,7 +23,6 @@
*/
namespace OCA\Federation\Command;
-use OCA\Federation\DbHandler;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
diff --git a/apps/files/lib/Command/DeleteOrphanedFiles.php b/apps/files/lib/Command/DeleteOrphanedFiles.php
index 77a22945a9a..2e5893cfd1f 100644
--- a/apps/files/lib/Command/DeleteOrphanedFiles.php
+++ b/apps/files/lib/Command/DeleteOrphanedFiles.php
@@ -23,8 +23,6 @@
namespace OCA\Files\Command;
-use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
-use Doctrine\DBAL\Platforms\SqlitePlatform;
use OCP\IDBConnection;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
diff --git a/apps/files/lib/Command/ScanAppData.php b/apps/files/lib/Command/ScanAppData.php
index 6ad83d9a182..7212717ee40 100644
--- a/apps/files/lib/Command/ScanAppData.php
+++ b/apps/files/lib/Command/ScanAppData.php
@@ -12,8 +12,6 @@ use OCP\Files\NotFoundException;
use OCP\Files\StorageNotAvailableException;
use OCP\IConfig;
use OCP\IDBConnection;
-use OCP\IUserManager;
-use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php
index 499961ca2dc..f7a4318e595 100644
--- a/apps/files/lib/Controller/ViewController.php
+++ b/apps/files/lib/Controller/ViewController.php
@@ -35,7 +35,6 @@ use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\IConfig;
use OCP\IL10N;
-use OCP\INavigationManager;
use OCP\IRequest;
use OCP\IURLGenerator;
use OCP\IUserSession;
diff --git a/apps/files/tests/Controller/ApiControllerTest.php b/apps/files/tests/Controller/ApiControllerTest.php
index 56d0f6c8dee..eba87289300 100644
--- a/apps/files/tests/Controller/ApiControllerTest.php
+++ b/apps/files/tests/Controller/ApiControllerTest.php
@@ -26,7 +26,6 @@
namespace OCA\Files\Controller;
-use OC\Files\FileInfo;
use OCP\AppFramework\Http;
use OCP\Files\File;
use OCP\Files\Folder;
@@ -42,7 +41,6 @@ use OCP\IRequest;
use OCA\Files\Service\TagService;
use OCP\AppFramework\Http\DataResponse;
use OCP\IPreview;
-use OCP\Image;
/**
* Class ApiController
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js
index 865aa35ac6a..ee73914f166 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -2273,7 +2273,7 @@ describe('OCA.Files.FileList tests', function() {
var actionStub = sinon.stub();
var readyHandler = sinon.stub();
var clock = sinon.useFakeTimers();
- var debounceStub = sinon.stub(_, 'debounce', function(callback) {
+ var debounceStub = sinon.stub(_, 'debounce').callsFake(function(callback) {
return function() {
// defer instead of debounce, to make it work with clock
_.defer(callback);
diff --git a/apps/files_external/lib/Lib/Backend/SFTP.php b/apps/files_external/lib/Lib/Backend/SFTP.php
index cc3c72d2832..c9b31272999 100644
--- a/apps/files_external/lib/Lib/Backend/SFTP.php
+++ b/apps/files_external/lib/Lib/Backend/SFTP.php
@@ -23,11 +23,8 @@
namespace OCA\Files_External\Lib\Backend;
use \OCP\IL10N;
-use \OCA\Files_External\Lib\Backend\Backend;
use \OCA\Files_External\Lib\DefinitionParameter;
use \OCA\Files_External\Lib\Auth\AuthMechanism;
-use \OCA\Files_External\Service\BackendService;
-
use \OCA\Files_External\Lib\Auth\Password\Password;
class SFTP extends Backend {
diff --git a/apps/files_external/lib/Lib/Storage/SFTP.php b/apps/files_external/lib/Lib/Storage/SFTP.php
index 1d9affa8d68..a4dfea94bf7 100644
--- a/apps/files_external/lib/Lib/Storage/SFTP.php
+++ b/apps/files_external/lib/Lib/Storage/SFTP.php
@@ -33,7 +33,6 @@
*/
namespace OCA\Files_External\Lib\Storage;
use Icewind\Streams\IteratorDirectory;
-
use Icewind\Streams\RetryWrapper;
use phpseclib\Net\SFTP\Stream;
diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php
index 690f8e2a334..cc4cd641ce5 100644
--- a/apps/files_external/lib/Lib/Storage/SMB.php
+++ b/apps/files_external/lib/Lib/Storage/SMB.php
@@ -31,14 +31,11 @@
namespace OCA\Files_External\Lib\Storage;
-use Icewind\SMB\Change;
use Icewind\SMB\Exception\ConnectException;
use Icewind\SMB\Exception\Exception;
use Icewind\SMB\Exception\ForbiddenException;
use Icewind\SMB\Exception\NotFoundException;
-use Icewind\SMB\INotifyHandler;
use Icewind\SMB\IFileInfo;
-use Icewind\SMB\IShare;
use Icewind\SMB\NativeServer;
use Icewind\SMB\Server;
use Icewind\Streams\CallbackWrapper;
diff --git a/apps/files_external/tests/js/settingsSpec.js b/apps/files_external/tests/js/settingsSpec.js
index 2639f634b26..d6b96a47189 100644
--- a/apps/files_external/tests/js/settingsSpec.js
+++ b/apps/files_external/tests/js/settingsSpec.js
@@ -15,7 +15,7 @@ describe('OCA.External.Settings tests', function() {
beforeEach(function() {
clock = sinon.useFakeTimers();
- select2Stub = sinon.stub($.fn, 'select2', function(args) {
+ select2Stub = sinon.stub($.fn, 'select2').callsFake(function(args) {
if (args === 'val') {
return select2ApplicableUsers;
}
diff --git a/apps/files_sharing/css/sharetabview.scss b/apps/files_sharing/css/sharetabview.scss
index 82f0ffa5822..cb2bb463352 100644
--- a/apps/files_sharing/css/sharetabview.scss
+++ b/apps/files_sharing/css/sharetabview.scss
@@ -14,7 +14,8 @@
}
.shareTabView .shareWithRemoteInfo,
-.shareTabView .clipboardButton {
+.shareTabView .clipboardButton,
+.shareTabView .linkPass .icon-loading-small {
position: absolute;
right: -7px;
top: -4px;
@@ -152,7 +153,7 @@
}
.shareTabView .linkPass .icon-loading-small {
- margin-top: 9px;
+ margin-right: 0px;
}
.shareTabView .icon {
diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php
index f502d905fe8..db2175c3445 100644
--- a/apps/files_sharing/lib/AppInfo/Application.php
+++ b/apps/files_sharing/lib/AppInfo/Application.php
@@ -27,7 +27,6 @@
namespace OCA\Files_Sharing\AppInfo;
-use OCA\FederatedFileSharing\DiscoveryManager;
use OCA\Files_Sharing\Middleware\OCSShareAPIMiddleware;
use OCA\Files_Sharing\MountProvider;
use OCP\AppFramework\App;
diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php
index d7dcb426d85..d9cf5d80b80 100644
--- a/apps/files_sharing/lib/Cache.php
+++ b/apps/files_sharing/lib/Cache.php
@@ -29,7 +29,6 @@ namespace OCA\Files_Sharing;
use OC\Files\Cache\Wrapper\CacheJail;
use OCP\Files\Cache\ICacheEntry;
-use OCP\Files\Storage\IStorage;
/**
* Metadata cache for shared files
diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php
index 2c348907384..2adcc7cf5cb 100644
--- a/apps/files_sharing/lib/External/Manager.php
+++ b/apps/files_sharing/lib/External/Manager.php
@@ -30,7 +30,6 @@
namespace OCA\Files_Sharing\External;
use OC\Files\Filesystem;
-use OCA\FederatedFileSharing\DiscoveryManager;
use OCP\Files;
use OCP\Files\Storage\IStorageFactory;
use OCP\Http\Client\IClientService;
diff --git a/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php
index b84ba5d96ab..95f45dc3691 100644
--- a/apps/files_sharing/lib/External/Storage.php
+++ b/apps/files_sharing/lib/External/Storage.php
@@ -32,7 +32,6 @@ use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Exception\ConnectException;
use OC\Files\Storage\DAV;
use OC\ForbiddenException;
-use OCA\FederatedFileSharing\DiscoveryManager;
use OCA\Files_Sharing\ISharedStorage;
use OCP\AppFramework\Http;
use OCP\Federation\ICloudId;
diff --git a/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php b/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php
index d366a401e2f..cd662b1fb5e 100644
--- a/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php
+++ b/apps/files_trashbin/lib/BackgroundJob/ExpireTrash.php
@@ -24,7 +24,6 @@
namespace OCA\Files_Trashbin\BackgroundJob;
-use OCP\IConfig;
use OCP\IUser;
use OCP\IUserManager;
use OCA\Files_Trashbin\AppInfo\Application;
diff --git a/apps/provisioning_api/lib/Controller/AppsController.php b/apps/provisioning_api/lib/Controller/AppsController.php
index 1165c7b8564..70316875762 100644
--- a/apps/provisioning_api/lib/Controller/AppsController.php
+++ b/apps/provisioning_api/lib/Controller/AppsController.php
@@ -28,7 +28,6 @@ namespace OCA\Provisioning_API\Controller;
use \OC_App;
use OCP\App\AppPathNotFoundException;
use OCP\App\IAppManager;
-use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCSController;
diff --git a/apps/testing/locking/provisioning.php b/apps/testing/locking/provisioning.php
index 84587fa9a62..7e3256ec605 100644
--- a/apps/testing/locking/provisioning.php
+++ b/apps/testing/locking/provisioning.php
@@ -23,7 +23,6 @@
namespace OCA\Testing\Locking;
use OC\Lock\DBLockingProvider;
-use OC\Lock\MemcacheLockingProvider;
use OC\User\NoUserException;
use OCP\AppFramework\Http;
use OCP\Files\NotFoundException;
diff --git a/apps/user_ldap/ajax/wizard.php b/apps/user_ldap/ajax/wizard.php
index 5d994f40dcb..60102c72b40 100644
--- a/apps/user_ldap/ajax/wizard.php
+++ b/apps/user_ldap/ajax/wizard.php
@@ -58,7 +58,8 @@ $userManager = new \OCA\User_LDAP\User\Manager(
\OC::$server->getAvatarManager(),
new \OCP\Image(),
\OC::$server->getDatabaseConnection(),
- \OC::$server->getUserManager());
+ \OC::$server->getUserManager(),
+ \OC::$server->getNotificationManager());
$access = new \OCA\User_LDAP\Access($con, $ldapWrapper, $userManager, new \OCA\User_LDAP\Helper(
\OC::$server->getConfig()
diff --git a/apps/user_ldap/appinfo/app.php b/apps/user_ldap/appinfo/app.php
index 6f930ea39f0..cbdcafc58d6 100644
--- a/apps/user_ldap/appinfo/app.php
+++ b/apps/user_ldap/appinfo/app.php
@@ -31,6 +31,18 @@ $helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig());
$configPrefixes = $helper->getServerConfigurationPrefixes(true);
$ldapWrapper = new OCA\User_LDAP\LDAP();
$ocConfig = \OC::$server->getConfig();
+$notificationManager = \OC::$server->getNotificationManager();
+$notificationManager->registerNotifier(function() {
+ return new \OCA\User_LDAP\Notification\Notifier(
+ \OC::$server->getL10NFactory()
+ );
+}, function() {
+ $l = \OC::$server->getL10N('user_ldap');
+ return [
+ 'id' => 'user_ldap',
+ 'name' => $l->t('LDAP user and group backend'),
+ ];
+});
if(count($configPrefixes) === 1) {
$dbc = \OC::$server->getDatabaseConnection();
$userManager = new OCA\User_LDAP\User\Manager($ocConfig,
@@ -39,18 +51,19 @@ if(count($configPrefixes) === 1) {
\OC::$server->getAvatarManager(),
new \OCP\Image(),
$dbc,
- \OC::$server->getUserManager()
+ \OC::$server->getUserManager(),
+ $notificationManager
);
$connector = new OCA\User_LDAP\Connection($ldapWrapper, $configPrefixes[0]);
$ldapAccess = new OCA\User_LDAP\Access($connector, $ldapWrapper, $userManager, $helper);
$ldapAccess->setUserMapper(new OCA\User_LDAP\Mapping\UserMapping($dbc));
$ldapAccess->setGroupMapper(new OCA\User_LDAP\Mapping\GroupMapping($dbc));
- $userBackend = new OCA\User_LDAP\User_LDAP($ldapAccess, $ocConfig);
+ $userBackend = new OCA\User_LDAP\User_LDAP($ldapAccess, $ocConfig, $notificationManager);
$groupBackend = new \OCA\User_LDAP\Group_LDAP($ldapAccess);
} else if(count($configPrefixes) > 1) {
$userBackend = new OCA\User_LDAP\User_Proxy(
- $configPrefixes, $ldapWrapper, $ocConfig
+ $configPrefixes, $ldapWrapper, $ocConfig, $notificationManager
);
$groupBackend = new OCA\User_LDAP\Group_Proxy($configPrefixes, $ldapWrapper);
}
diff --git a/apps/user_ldap/appinfo/register_command.php b/apps/user_ldap/appinfo/register_command.php
index 41083f8d12a..3ae8bdbfc13 100644
--- a/apps/user_ldap/appinfo/register_command.php
+++ b/apps/user_ldap/appinfo/register_command.php
@@ -35,7 +35,8 @@ $ocConfig = \OC::$server->getConfig();
$uBackend = new User_Proxy(
$helper->getServerConfigurationPrefixes(true),
new LDAP(),
- $ocConfig
+ $ocConfig,
+ \OC::$server->getNotificationManager()
);
$deletedUsersIndex = new DeletedUsersIndex(
$ocConfig, $dbConnection, $userMapping
diff --git a/apps/user_ldap/appinfo/routes.php b/apps/user_ldap/appinfo/routes.php
index 45b43c21409..39964838d48 100644
--- a/apps/user_ldap/appinfo/routes.php
+++ b/apps/user_ldap/appinfo/routes.php
@@ -46,3 +46,13 @@ $application->registerRoutes($this, [
['name' => 'ConfigAPI#delete', 'url' => '/api/v1/config/{configID}', 'verb' => 'DELETE'],
]
]);
+
+$application = new OCA\User_LDAP\AppInfo\Application();
+$application->registerRoutes($this, [
+ 'routes' => [
+ ['name' => 'renewPassword#tryRenewPassword', 'url' => '/renewpassword', 'verb' => 'POST'],
+ ['name' => 'renewPassword#showRenewPasswordForm', 'url' => '/renewpassword/{user}', 'verb' => 'GET'],
+ ['name' => 'renewPassword#cancel', 'url' => '/renewpassword/cancel', 'verb' => 'GET'],
+ ['name' => 'renewPassword#showLoginFormInvalidPassword', 'url' => '/renewpassword/invalidlogin/{user}', 'verb' => 'GET'],
+ ]
+]);
diff --git a/apps/user_ldap/css/renewPassword.css b/apps/user_ldap/css/renewPassword.css
new file mode 100644
index 00000000000..a06a101efe5
--- /dev/null
+++ b/apps/user_ldap/css/renewPassword.css
@@ -0,0 +1,20 @@
+#personal-show + label {
+ left: 222px !important;
+ margin-top: 3px !important;
+}
+
+#renewpassword .strengthify-wrapper {
+ left: 10px;
+ margin-top: 65px;
+ position: absolute;
+ width: 219px;
+}
+
+#cancel-container p.info {
+ margin-top: 10px;
+ text-align: center;
+}
+
+#renewpassword .title {
+ background-color: transparent;
+}
diff --git a/apps/user_ldap/js/renewPassword.js b/apps/user_ldap/js/renewPassword.js
new file mode 100644
index 00000000000..bea2c0409f7
--- /dev/null
+++ b/apps/user_ldap/js/renewPassword.js
@@ -0,0 +1,50 @@
+/**
+ *
+ * @copyright Copyright (c) 2016, Roger Szabo (roger.szabo@web.de)
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+OCA = OCA || {};
+OCA.LDAP = _.extend(OC.LDAP || {}, {
+ onRenewPassword: function () {
+ $('#submit')
+ .removeClass('icon-confirm-white')
+ .addClass('icon-loading-small')
+ .attr('value', t('core', 'Renewing …'));
+ return true;
+ },
+});
+
+$(document).ready(function() {
+ $('form[name=renewpassword]').submit(OCA.LDAP.onRenewPassword);
+
+ if($('#newPassword').length) {
+ $('#newPassword').showPassword().keyup();
+ }
+ $('#newPassword').strengthify({
+ zxcvbn: OC.linkTo('core','vendor/zxcvbn/dist/zxcvbn.js'),
+ titles: [
+ t('core', 'Very weak password'),
+ t('core', 'Weak password'),
+ t('core', 'So-so password'),
+ t('core', 'Good password'),
+ t('core', 'Strong password')
+ ],
+ drawTitles: true,
+ });
+});
diff --git a/apps/user_ldap/js/wizard/wizardTabAdvanced.js b/apps/user_ldap/js/wizard/wizardTabAdvanced.js
index 7d8d0b70269..9302104b1f6 100644
--- a/apps/user_ldap/js/wizard/wizardTabAdvanced.js
+++ b/apps/user_ldap/js/wizard/wizardTabAdvanced.js
@@ -99,6 +99,10 @@ OCA = OCA || {};
$element: $('#ldap_turn_on_pwd_change'),
setMethod: 'setPasswordChangeEnabled'
},
+ ldap_default_ppolicy_dn: {
+ $element: $('#ldap_default_ppolicy_dn'),
+ setMethod: 'setDefaultPPolicyDN'
+ },
//Special Attributes
ldap_quota_attr: {
@@ -292,7 +296,7 @@ OCA = OCA || {};
setPagingSize: function(size) {
this.setElementValue(this.managedItems.ldap_paging_size.$element, size);
},
-
+
/**
* sets whether the password changes per user should be enabled
*
@@ -305,6 +309,15 @@ OCA = OCA || {};
},
/**
+ * sets the default ppolicy attribute
+ *
+ * @param {string} attribute
+ */
+ setDefaultPPolicyDN: function(attribute) {
+ this.setElementValue(this.managedItems.ldap_default_ppolicy_dn.$element, attribute);
+ },
+
+ /**
* sets the email attribute
*
* @param {string} attribute
diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php
index 959a8dd2b8e..973b23e81cc 100644
--- a/apps/user_ldap/lib/Access.php
+++ b/apps/user_ldap/lib/Access.php
@@ -1096,7 +1096,7 @@ class Access extends LDAPUtility implements IUserTools {
* @param bool $skipHandling
* @return array with the search result
*/
- private function search($filter, $base, $attr = null, $limit = null, $offset = null, $skipHandling = false) {
+ public function search($filter, $base, $attr = null, $limit = null, $offset = null, $skipHandling = false) {
if($limit <= 0) {
//otherwise search will fail
$limit = null;
diff --git a/apps/user_ldap/lib/AppInfo/Application.php b/apps/user_ldap/lib/AppInfo/Application.php
new file mode 100644
index 00000000000..c3fa1ce9f94
--- /dev/null
+++ b/apps/user_ldap/lib/AppInfo/Application.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Roger Szabo <roger.szabo@web.de>
+ *
+ * @author Roger Szabo <roger.szabo@web.de>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\User_LDAP\AppInfo;
+
+use OCA\User_LDAP\Controller\RenewPasswordController;
+use OCP\AppFramework\App;
+use OCP\AppFramework\IAppContainer;
+
+class Application extends App {
+ public function __construct () {
+ parent::__construct('user_ldap');
+ $container = $this->getContainer();
+
+ /**
+ * Controller
+ */
+ $container->registerService('RenewPasswordController', function(IAppContainer $c) {
+ /** @var \OC\Server $server */
+ $server = $c->query('ServerContainer');
+
+ return new RenewPasswordController(
+ $c->getAppName(),
+ $server->getRequest(),
+ $c->query('UserManager'),
+ $server->getConfig(),
+ $c->query('OCP\IL10N'),
+ $server->getURLGenerator()
+ );
+ });
+ }
+}
diff --git a/apps/user_ldap/lib/Command/Search.php b/apps/user_ldap/lib/Command/Search.php
index 57970b1ac5d..463ad2eaeb4 100644
--- a/apps/user_ldap/lib/Command/Search.php
+++ b/apps/user_ldap/lib/Command/Search.php
@@ -120,7 +120,7 @@ class Search extends Command {
$limit = null;
}
} else {
- $proxy = new User_Proxy($configPrefixes, $ldapWrapper, $this->ocConfig);
+ $proxy = new User_Proxy($configPrefixes, $ldapWrapper, $this->ocConfig, \OC::$server->getNotificationManager());
$getMethod = 'getDisplayNames';
$printID = true;
}
diff --git a/apps/user_ldap/lib/Configuration.php b/apps/user_ldap/lib/Configuration.php
index 65ee9c70807..654a63cdc73 100644
--- a/apps/user_ldap/lib/Configuration.php
+++ b/apps/user_ldap/lib/Configuration.php
@@ -93,6 +93,7 @@ class Configuration {
'ldapPagingSize' => null,
'turnOnPasswordChange' => false,
'ldapDynamicGroupMemberURL' => null,
+ 'ldapDefaultPPolicyDN' => null,
);
/**
@@ -457,6 +458,7 @@ class Configuration {
'ldap_turn_on_pwd_change' => 0,
'ldap_experienced_admin' => 0,
'ldap_dynamic_group_member_url' => '',
+ 'ldap_default_ppolicy_dn' => '',
);
}
@@ -514,6 +516,7 @@ class Configuration {
'ldap_turn_on_pwd_change' => 'turnOnPasswordChange',
'ldap_experienced_admin' => 'ldapExperiencedAdmin',
'ldap_dynamic_group_member_url' => 'ldapDynamicGroupMemberURL',
+ 'ldap_default_ppolicy_dn' => 'ldapDefaultPPolicyDN',
);
return $array;
}
diff --git a/apps/user_ldap/lib/Controller/RenewPasswordController.php b/apps/user_ldap/lib/Controller/RenewPasswordController.php
new file mode 100644
index 00000000000..4714c0646cd
--- /dev/null
+++ b/apps/user_ldap/lib/Controller/RenewPasswordController.php
@@ -0,0 +1,180 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Roger Szabo <roger.szabo@web.de>
+ *
+ * @author Roger Szabo <roger.szabo@web.de>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\User_LDAP\Controller;
+
+use OC\HintException;
+use OC_Util;
+use OCP\AppFramework\Controller;
+use OCP\AppFramework\Http\RedirectResponse;
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\IConfig;
+use OCP\IL10N;
+use OCP\IRequest;
+use OCP\ISession;
+use OCP\IURLGenerator;
+use OCP\IUser;
+use OCP\IUserManager;
+
+class RenewPasswordController extends Controller {
+ /** @var IUserManager */
+ private $userManager;
+ /** @var IConfig */
+ private $config;
+ /** @var IL10N */
+ protected $l10n;
+ /** @var ISession */
+ private $session;
+ /** @var IURLGenerator */
+ private $urlGenerator;
+
+ /**
+ * @param string $appName
+ * @param IRequest $request
+ * @param IUserManager $userManager
+ * @param IConfig $config
+ * @param IURLGenerator $urlGenerator
+ */
+ function __construct($appName, IRequest $request, IUserManager $userManager,
+ IConfig $config, IL10N $l10n, ISession $session, IURLGenerator $urlGenerator) {
+ parent::__construct($appName, $request);
+ $this->userManager = $userManager;
+ $this->config = $config;
+ $this->l10n = $l10n;
+ $this->session = $session;
+ $this->urlGenerator = $urlGenerator;
+ }
+
+ /**
+ * @PublicPage
+ * @NoCSRFRequired
+ *
+ * @return RedirectResponse
+ */
+ public function cancel() {
+ return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'));
+ }
+
+ /**
+ * @PublicPage
+ * @NoCSRFRequired
+ * @UseSession
+ *
+ * @param string $user
+ *
+ * @return TemplateResponse|RedirectResponse
+ */
+ public function showRenewPasswordForm($user) {
+ if($this->config->getUserValue($user, 'user_ldap', 'needsPasswordReset') !== 'true') {
+ return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'));
+ }
+ $parameters = [];
+ $renewPasswordMessages = $this->session->get('renewPasswordMessages');
+ $errors = [];
+ $messages = [];
+ if (is_array($renewPasswordMessages)) {
+ list($errors, $messages) = $renewPasswordMessages;
+ }
+ $this->session->remove('renewPasswordMessages');
+ foreach ($errors as $value) {
+ $parameters[$value] = true;
+ }
+
+ $parameters['messages'] = $messages;
+ $parameters['user'] = $user;
+
+ $parameters['canResetPassword'] = true;
+ $parameters['resetPasswordLink'] = $this->config->getSystemValue('lost_password_link', '');
+ if (!$parameters['resetPasswordLink']) {
+ $userObj = $this->userManager->get($user);
+ if ($userObj instanceof IUser) {
+ $parameters['canResetPassword'] = $userObj->canChangePassword();
+ }
+ }
+ $parameters['cancelLink'] = $this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm');
+
+ return new TemplateResponse(
+ $this->appName, 'renewpassword', $parameters, 'guest'
+ );
+ }
+
+ /**
+ * @PublicPage
+ * @UseSession
+ *
+ * @param string $user
+ * @param string $oldPassword
+ * @param string $newPassword
+ *
+ * @return RedirectResponse
+ */
+ public function tryRenewPassword($user, $oldPassword, $newPassword) {
+ if($this->config->getUserValue($user, 'user_ldap', 'needsPasswordReset') !== 'true') {
+ return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'));
+ }
+ $args = !is_null($user) ? ['user' => $user] : [];
+ $loginResult = $this->userManager->checkPassword($user, $oldPassword);
+ if ($loginResult === false) {
+ $this->session->set('renewPasswordMessages', [
+ ['invalidpassword'], []
+ ]);
+ return new RedirectResponse($this->urlGenerator->linkToRoute('user_ldap.renewPassword.showRenewPasswordForm', $args));
+ }
+
+ try {
+ if (!is_null($newPassword) && \OC_User::setPassword($user, $newPassword)) {
+ $this->session->set('loginMessages', [
+ [], [$this->l10n->t("Please login with the new password")]
+ ]);
+ $this->session->remove('needPasswordRenewal');
+ return new RedirectResponse($this->urlGenerator->linkToRoute('core.login.showLoginForm', $args));
+ } else {
+ $this->session->set('renewPasswordMessages', [
+ ['internalexception'], []
+ ]);
+ }
+ } catch (HintException $e) {
+ $this->session->set('renewPasswordMessages', [
+ [], [$e->getHint()]
+ ]);
+ }
+
+ return new RedirectResponse($this->urlGenerator->linkToRoute('user_ldap.renewPassword.showRenewPasswordForm', $args));
+ }
+
+ /**
+ * @PublicPage
+ * @NoCSRFRequired
+ * @UseSession
+ *
+ * @return RedirectResponse
+ */
+ public function showLoginFormInvalidPassword($user) {
+ $args = !is_null($user) ? ['user' => $user] : [];
+ $this->session->set('loginMessages', [
+ ['invalidpassword'], []
+ ]);
+ return new RedirectResponse($this->urlGenerator->linkToRoute('core.login.showLoginForm', $args));
+ }
+
+}
diff --git a/apps/user_ldap/lib/Exceptions/ConstraintViolationException.php b/apps/user_ldap/lib/Exceptions/ConstraintViolationException.php
index 997b01b2d4e..586a80b9ebe 100644
--- a/apps/user_ldap/lib/Exceptions/ConstraintViolationException.php
+++ b/apps/user_ldap/lib/Exceptions/ConstraintViolationException.php
@@ -1,6 +1,6 @@
<?php
/**
- * @copyright Copyright (c) 2016 Roger Szabo <roger.szabo@web.de>
+ * @copyright Copyright (c) 2017 Roger Szabo <roger.szabo@web.de>
*
* @author Roger Szabo <roger.szabo@web.de>
*
diff --git a/apps/user_ldap/lib/Helper.php b/apps/user_ldap/lib/Helper.php
index f1186ffa310..83b2f05f1d2 100644
--- a/apps/user_ldap/lib/Helper.php
+++ b/apps/user_ldap/lib/Helper.php
@@ -293,9 +293,10 @@ class Helper {
$configPrefixes = $helper->getServerConfigurationPrefixes(true);
$ldapWrapper = new LDAP();
$ocConfig = \OC::$server->getConfig();
+ $notificationManager = \OC::$server->getNotificationManager();
$userBackend = new User_Proxy(
- $configPrefixes, $ldapWrapper, $ocConfig
+ $configPrefixes, $ldapWrapper, $ocConfig, $notificationManager
);
$uid = $userBackend->loginName2UserName($param['uid'] );
if($uid !== false) {
diff --git a/apps/user_ldap/lib/Jobs/CleanUp.php b/apps/user_ldap/lib/Jobs/CleanUp.php
index e69d24dfd06..a4dd4ba32ad 100644
--- a/apps/user_ldap/lib/Jobs/CleanUp.php
+++ b/apps/user_ldap/lib/Jobs/CleanUp.php
@@ -98,7 +98,8 @@ class CleanUp extends TimedJob {
$this->userBackend = new User_Proxy(
$this->ldapHelper->getServerConfigurationPrefixes(true),
new LDAP(),
- $this->ocConfig
+ $this->ocConfig,
+ \OC::$server->getNotificationManager()
);
}
diff --git a/apps/user_ldap/lib/Jobs/UpdateGroups.php b/apps/user_ldap/lib/Jobs/UpdateGroups.php
index b4259425fcc..4c9a06a5f68 100644
--- a/apps/user_ldap/lib/Jobs/UpdateGroups.php
+++ b/apps/user_ldap/lib/Jobs/UpdateGroups.php
@@ -185,7 +185,8 @@ class UpdateGroups extends \OC\BackgroundJob\TimedJob {
\OC::$server->getAvatarManager(),
new \OCP\Image(),
$dbc,
- \OC::$server->getUserManager());
+ \OC::$server->getUserManager(),
+ \OC::$server->getNotificationManager());
$connector = new Connection($ldapWrapper, $configPrefixes[0]);
$ldapAccess = new Access($connector, $ldapWrapper, $userManager, $helper);
$groupMapper = new GroupMapping($dbc);
diff --git a/apps/user_ldap/lib/Migration/UUIDFixGroup.php b/apps/user_ldap/lib/Migration/UUIDFixGroup.php
index cbc38366984..6aacb37257e 100644
--- a/apps/user_ldap/lib/Migration/UUIDFixGroup.php
+++ b/apps/user_ldap/lib/Migration/UUIDFixGroup.php
@@ -32,6 +32,7 @@ use OCP\IConfig;
class UUIDFixGroup extends UUIDFix {
public function __construct(GroupMapping $mapper, LDAP $ldap, IConfig $config, Helper $helper) {
$this->mapper = $mapper;
- $this->proxy = new User_Proxy($helper->getServerConfigurationPrefixes(true), $ldap, $config);
+ $this->proxy = new User_Proxy($helper->getServerConfigurationPrefixes(true), $ldap, $config,
+ \OC::$server->getNotificationManager());
}
}
diff --git a/apps/user_ldap/lib/Notification/Notifier.php b/apps/user_ldap/lib/Notification/Notifier.php
new file mode 100644
index 00000000000..a6053cfcb19
--- /dev/null
+++ b/apps/user_ldap/lib/Notification/Notifier.php
@@ -0,0 +1,71 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Roger Szabo <roger.szabo@web.de>
+ *
+ * @author Roger Szabo <roger.szabo@web.de>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\User_LDAP\Notification;
+
+
+use OCP\IUser;
+use OCP\IUserManager;
+use OCP\L10N\IFactory;
+use OCP\Notification\INotification;
+use OCP\Notification\INotifier;
+
+class Notifier implements INotifier {
+
+ /** @var IFactory */
+ protected $l10nFactory;
+
+ /**
+ * @param IFactory $l10nFactory
+ */
+ public function __construct(\OCP\L10N\IFactory $l10nFactory) {
+ $this->l10nFactory = $l10nFactory;
+ }
+
+ /**
+ * @param INotification $notification
+ * @param string $languageCode The code of the language that should be used to prepare the notification
+ * @return INotification
+ * @throws \InvalidArgumentException When the notification was not prepared by a notifier
+ */
+ public function prepare(INotification $notification, $languageCode) {
+ if ($notification->getApp() !== 'user_ldap') {
+ // Not my app => throw
+ throw new \InvalidArgumentException();
+ }
+
+ // Read the language from the notification
+ $l = $this->l10nFactory->get('user_ldap', $languageCode);
+
+ switch ($notification->getSubject()) {
+ // Deal with known subjects
+ case 'pwd_exp_warn_days':
+ $notification->setParsedSubject($l->t('Your password will expire within %s day(s).', $notification->getSubjectParameters()));
+ return $notification;
+
+ default:
+ // Unknown subject => Unknown notification => throw
+ throw new \InvalidArgumentException();
+ }
+ }
+}
diff --git a/apps/user_ldap/lib/Proxy.php b/apps/user_ldap/lib/Proxy.php
index 7f998314e20..96bb670b789 100644
--- a/apps/user_ldap/lib/Proxy.php
+++ b/apps/user_ldap/lib/Proxy.php
@@ -64,6 +64,7 @@ abstract class Proxy {
static $groupMap;
static $db;
static $coreUserManager;
+ static $coreNotificationManager;
if(is_null($fs)) {
$ocConfig = \OC::$server->getConfig();
$fs = new FilesystemHelper();
@@ -73,9 +74,11 @@ abstract class Proxy {
$userMap = new UserMapping($db);
$groupMap = new GroupMapping($db);
$coreUserManager = \OC::$server->getUserManager();
+ $coreNotificationManager = \OC::$server->getNotificationManager();
}
$userManager =
- new Manager($ocConfig, $fs, $log, $avatarM, new \OCP\Image(), $db, $coreUserManager);
+ new Manager($ocConfig, $fs, $log, $avatarM, new \OCP\Image(), $db,
+ $coreUserManager, $coreNotificationManager);
$connector = new Connection($this->ldap, $configPrefix);
$access = new Access($connector, $this->ldap, $userManager, new Helper(\OC::$server->getConfig()));
$access->setUserMapper($userMap);
diff --git a/apps/user_ldap/lib/User/Manager.php b/apps/user_ldap/lib/User/Manager.php
index 18430a90cc7..ea4d071b646 100644
--- a/apps/user_ldap/lib/User/Manager.php
+++ b/apps/user_ldap/lib/User/Manager.php
@@ -34,6 +34,7 @@ use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Image;
use OCP\IUserManager;
+use OCP\Notification\IManager as INotificationManager;
/**
* Manager
@@ -51,6 +52,12 @@ class Manager {
/** @var IDBConnection */
protected $db;
+ /** @var IUserManager */
+ protected $userManager;
+
+ /** @var INotificationManager */
+ protected $notificationManager;
+
/** @var FilesystemHelper */
protected $ocFilesystem;
@@ -85,17 +92,19 @@ class Manager {
public function __construct(IConfig $ocConfig,
FilesystemHelper $ocFilesystem, LogWrapper $ocLog,
IAvatarManager $avatarManager, Image $image,
- IDBConnection $db, IUserManager $userManager) {
-
- $this->ocConfig = $ocConfig;
- $this->ocFilesystem = $ocFilesystem;
- $this->ocLog = $ocLog;
- $this->avatarManager = $avatarManager;
- $this->image = $image;
- $this->db = $db;
- $this->userManager = $userManager;
- $this->usersByDN = new CappedMemoryCache();
- $this->usersByUid = new CappedMemoryCache();
+ IDBConnection $db, IUserManager $userManager,
+ INotificationManager $notificationManager) {
+
+ $this->ocConfig = $ocConfig;
+ $this->ocFilesystem = $ocFilesystem;
+ $this->ocLog = $ocLog;
+ $this->avatarManager = $avatarManager;
+ $this->image = $image;
+ $this->db = $db;
+ $this->userManager = $userManager;
+ $this->notificationManager = $notificationManager;
+ $this->usersByDN = new CappedMemoryCache();
+ $this->usersByUid = new CappedMemoryCache();
}
/**
@@ -118,7 +127,8 @@ class Manager {
$this->checkAccess();
$user = new User($uid, $dn, $this->access, $this->ocConfig,
$this->ocFilesystem, clone $this->image, $this->ocLog,
- $this->avatarManager, $this->userManager);
+ $this->avatarManager, $this->userManager,
+ $this->notificationManager);
$this->usersByDN[$dn] = $user;
$this->usersByUid[$uid] = $user;
return $user;
diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php
index 4419c4983d4..a9e7eb6cc0c 100644
--- a/apps/user_ldap/lib/User/User.php
+++ b/apps/user_ldap/lib/User/User.php
@@ -7,6 +7,7 @@
* @author Morris Jobke <hey@morrisjobke.de>
* @author Thomas Müller <thomas.mueller@tmit.eu>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
+ * @author Roger Szabo <roger.szabo@web.de>
*
* @license AGPL-3.0
*
@@ -34,6 +35,7 @@ use OCP\IConfig;
use OCP\Image;
use OCP\IUserManager;
use OCP\Util;
+use OCP\Notification\IManager as INotificationManager;
/**
* User
@@ -74,6 +76,10 @@ class User {
*/
protected $userManager;
/**
+ * @var INotificationManager
+ */
+ protected $notificationManager;
+ /**
* @var string
*/
protected $dn;
@@ -108,11 +114,13 @@ class User {
* @param LogWrapper $log
* @param IAvatarManager $avatarManager
* @param IUserManager $userManager
+ * @param INotificationManager $notificationManager
*/
public function __construct($username, $dn, IUserTools $access,
IConfig $config, FilesystemHelper $fs, Image $image,
- LogWrapper $log, IAvatarManager $avatarManager, IUserManager $userManager) {
-
+ LogWrapper $log, IAvatarManager $avatarManager, IUserManager $userManager,
+ INotificationManager $notificationManager) {
+
if ($username === null) {
$log->log("uid for '$dn' must not be null!", Util::ERROR);
throw new \InvalidArgumentException('uid must not be null!');
@@ -121,16 +129,19 @@ class User {
throw new \InvalidArgumentException('uid must not be an empty string!');
}
- $this->access = $access;
- $this->connection = $access->getConnection();
- $this->config = $config;
- $this->fs = $fs;
- $this->dn = $dn;
- $this->uid = $username;
- $this->image = $image;
- $this->log = $log;
- $this->avatarManager = $avatarManager;
- $this->userManager = $userManager;
+ $this->access = $access;
+ $this->connection = $access->getConnection();
+ $this->config = $config;
+ $this->fs = $fs;
+ $this->dn = $dn;
+ $this->uid = $username;
+ $this->image = $image;
+ $this->log = $log;
+ $this->avatarManager = $avatarManager;
+ $this->userManager = $userManager;
+ $this->notificationManager = $notificationManager;
+
+ \OCP\Util::connectHook('OC_User', 'post_login', $this, 'handlePasswordExpiry');
}
/**
@@ -587,4 +598,98 @@ class User {
}
}
+ /**
+ * called by a post_login hook to handle password expiry
+ *
+ * @param array $params
+ */
+ public function handlePasswordExpiry($params) {
+ $ppolicyDN = $this->connection->ldapDefaultPPolicyDN;
+ if (empty($ppolicyDN) || (intval($this->connection->turnOnPasswordChange) !== 1)) {
+ return;//password expiry handling disabled
+ }
+ $uid = $params['uid'];
+ if(isset($uid) && $uid === $this->getUsername()) {
+ //retrieve relevant user attributes
+ $result = $this->access->search('objectclass=*', $this->dn, ['pwdpolicysubentry', 'pwdgraceusetime', 'pwdreset', 'pwdchangedtime']);
+
+ if(array_key_exists('pwdpolicysubentry', $result[0])) {
+ $pwdPolicySubentry = $result[0]['pwdpolicysubentry'];
+ if($pwdPolicySubentry && (count($pwdPolicySubentry) > 0)){
+ $ppolicyDN = $pwdPolicySubentry[0];//custom ppolicy DN
+ }
+ }
+
+ $pwdGraceUseTime = array_key_exists('pwdgraceusetime', $result[0]) ? $result[0]['pwdgraceusetime'] : null;
+ $pwdReset = array_key_exists('pwdreset', $result[0]) ? $result[0]['pwdreset'] : null;
+ $pwdChangedTime = array_key_exists('pwdchangedtime', $result[0]) ? $result[0]['pwdchangedtime'] : null;
+
+ //retrieve relevant password policy attributes
+ $cacheKey = 'ppolicyAttributes' . $ppolicyDN;
+ $result = $this->connection->getFromCache($cacheKey);
+ if(is_null($result)) {
+ $result = $this->access->search('objectclass=*', $ppolicyDN, ['pwdgraceauthnlimit', 'pwdmaxage', 'pwdexpirewarning']);
+ $this->connection->writeToCache($cacheKey, $result);
+ }
+
+ $pwdGraceAuthNLimit = array_key_exists('pwdgraceauthnlimit', $result[0]) ? $result[0]['pwdgraceauthnlimit'] : null;
+ $pwdMaxAge = array_key_exists('pwdmaxage', $result[0]) ? $result[0]['pwdmaxage'] : null;
+ $pwdExpireWarning = array_key_exists('pwdexpirewarning', $result[0]) ? $result[0]['pwdexpirewarning'] : null;
+
+ //handle grace login
+ $pwdGraceUseTimeCount = count($pwdGraceUseTime);
+ if($pwdGraceUseTime && $pwdGraceUseTimeCount > 0) { //was this a grace login?
+ if($pwdGraceAuthNLimit
+ && (count($pwdGraceAuthNLimit) > 0)
+ &&($pwdGraceUseTimeCount < intval($pwdGraceAuthNLimit[0]))) { //at least one more grace login available?
+ $this->config->setUserValue($uid, 'user_ldap', 'needsPasswordReset', 'true');
+ header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute(
+ 'user_ldap.renewPassword.showRenewPasswordForm', array('user' => $uid)));
+ } else { //no more grace login available
+ header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute(
+ 'user_ldap.renewPassword.showLoginFormInvalidPassword', array('user' => $uid)));
+ }
+ exit();
+ }
+ //handle pwdReset attribute
+ if($pwdReset && (count($pwdReset) > 0) && $pwdReset[0] === 'TRUE') { //user must change his password
+ $this->config->setUserValue($uid, 'user_ldap', 'needsPasswordReset', 'true');
+ header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute(
+ 'user_ldap.renewPassword.showRenewPasswordForm', array('user' => $uid)));
+ exit();
+ }
+ //handle password expiry warning
+ if($pwdChangedTime && (count($pwdChangedTime) > 0)) {
+ if($pwdMaxAge && (count($pwdMaxAge) > 0)
+ && $pwdExpireWarning && (count($pwdExpireWarning) > 0)) {
+ $pwdMaxAgeInt = intval($pwdMaxAge[0]);
+ $pwdExpireWarningInt = intval($pwdExpireWarning[0]);
+ if($pwdMaxAgeInt > 0 && $pwdExpireWarningInt > 0){
+ $pwdChangedTimeDt = \DateTime::createFromFormat('YmdHisZ', $pwdChangedTime[0]);
+ $pwdChangedTimeDt->add(new \DateInterval('PT'.$pwdMaxAgeInt.'S'));
+ $currentDateTime = new \DateTime();
+ $secondsToExpiry = $pwdChangedTimeDt->getTimestamp() - $currentDateTime->getTimestamp();
+ if($secondsToExpiry <= $pwdExpireWarningInt) {
+ //remove last password expiry warning if any
+ $notification = $this->notificationManager->createNotification();
+ $notification->setApp('user_ldap')
+ ->setUser($uid)
+ ->setObject('pwd_exp_warn', $uid)
+ ;
+ $this->notificationManager->markProcessed($notification);
+ //create new password expiry warning
+ $notification = $this->notificationManager->createNotification();
+ $notification->setApp('user_ldap')
+ ->setUser($uid)
+ ->setDateTime($currentDateTime)
+ ->setObject('pwd_exp_warn', $uid)
+ ->setSubject('pwd_exp_warn_days', [strval(ceil($secondsToExpiry / 60 / 60 / 24))])
+ ;
+ $this->notificationManager->notify($notification);
+ }
+ }
+ }
+ }
+ }
+ }
}
diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php
index fa959fd9a81..75cdb3951ca 100644
--- a/apps/user_ldap/lib/User_LDAP.php
+++ b/apps/user_ldap/lib/User_LDAP.php
@@ -41,6 +41,7 @@ use OCA\User_LDAP\Exceptions\NotOnLDAP;
use OCA\User_LDAP\User\OfflineUser;
use OCA\User_LDAP\User\User;
use OCP\IConfig;
+use OCP\Notification\IManager as INotificationManager;
use OCP\Util;
class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserInterface, IUserLDAP {
@@ -50,13 +51,18 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
/** @var \OCP\IConfig */
protected $ocConfig;
+ /** @var INotificationManager */
+ protected $notificationManager;
+
/**
* @param Access $access
* @param \OCP\IConfig $ocConfig
+ * @param \OCP\Notification\IManager $notificationManager
*/
- public function __construct(Access $access, IConfig $ocConfig) {
+ public function __construct(Access $access, IConfig $ocConfig, INotificationManager $notificationManager) {
parent::__construct($access);
$this->ocConfig = $ocConfig;
+ $this->notificationManager = $notificationManager;
}
/**
@@ -190,8 +196,19 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
throw new \Exception('LDAP setPassword: Could not get user object for uid ' . $uid .
'. Maybe the LDAP entry has no set display name attribute?');
}
- if($user->getUsername() !== false) {
- return $this->access->setPassword($user->getDN(), $password);
+ if($user->getUsername() !== false && $this->access->setPassword($user->getDN(), $password)) {
+ $ldapDefaultPPolicyDN = $this->access->connection->ldapDefaultPPolicyDN;
+ $turnOnPasswordChange = $this->access->connection->turnOnPasswordChange;
+ if (!empty($ldapDefaultPPolicyDN) && (intval($turnOnPasswordChange) === 1)) {
+ //remove last password expiry warning if any
+ $notification = $this->notificationManager->createNotification();
+ $notification->setApp('user_ldap')
+ ->setUser($uid)
+ ->setObject('pwd_exp_warn', $uid)
+ ;
+ $this->notificationManager->markProcessed($notification);
+ }
+ return true;
}
return false;
diff --git a/apps/user_ldap/lib/User_Proxy.php b/apps/user_ldap/lib/User_Proxy.php
index 6417841f245..8e81b10f7b3 100644
--- a/apps/user_ldap/lib/User_Proxy.php
+++ b/apps/user_ldap/lib/User_Proxy.php
@@ -31,6 +31,7 @@ namespace OCA\User_LDAP;
use OCA\User_LDAP\User\User;
use OCP\IConfig;
+use OCP\Notification\IManager as INotificationManager;
class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface, IUserLDAP {
private $backends = array();
@@ -40,11 +41,12 @@ class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface,
* Constructor
* @param array $serverConfigPrefixes array containing the config Prefixes
*/
- public function __construct(array $serverConfigPrefixes, ILDAPWrapper $ldap, IConfig $ocConfig) {
+ public function __construct(array $serverConfigPrefixes, ILDAPWrapper $ldap, IConfig $ocConfig,
+ INotificationManager $notificationManager) {
parent::__construct($ldap);
foreach($serverConfigPrefixes as $configPrefix) {
$this->backends[$configPrefix] =
- new User_LDAP($this->getAccess($configPrefix), $ocConfig);
+ new User_LDAP($this->getAccess($configPrefix), $ocConfig, $notificationManager);
if(is_null($this->refBackend)) {
$this->refBackend = &$this->backends[$configPrefix];
}
diff --git a/apps/user_ldap/templates/renewpassword.php b/apps/user_ldap/templates/renewpassword.php
new file mode 100644
index 00000000000..7b1df75e06b
--- /dev/null
+++ b/apps/user_ldap/templates/renewpassword.php
@@ -0,0 +1,73 @@
+<?php /** @var $l OC_L10N */ ?>
+<?php
+script('core', [
+ 'jquery-showpassword',
+]);
+script('user_ldap', [
+ 'renewPassword',
+]);
+style('user_ldap', 'renewPassword');
+\OC_Util::addVendorScript('strengthify/jquery.strengthify');
+\OC_Util::addVendorStyle('strengthify/strengthify');
+
+?>
+
+<!--[if IE 8]><style>input[type="checkbox"]{padding:0;}</style><![endif]-->
+<form method="post" name="renewpassword" id="renewpassword" action="<?php p(\OC::$server->getURLGenerator()->linkToRoute('user_ldap.renewPassword.tryRenewPassword')); ?>">
+ <fieldset>
+ <div class="warning title">
+ <?php p($l->t('Please renew your password.')); ?><br>
+ </div>
+ <?php foreach($_['messages'] as $message): ?>
+ <div class="warning">
+ <?php p($message); ?><br>
+ </div>
+ <?php endforeach; ?>
+ <?php if (isset($_['internalexception']) && ($_['internalexception'])): ?>
+ <div class="warning">
+ <?php p($l->t('An internal error occurred.')); ?><br>
+ <small><?php p($l->t('Please try again or contact your administrator.')); ?></small>
+ </div>
+ <?php endif; ?>
+ <div id="message" class="hidden">
+ <img class="float-spinner" alt=""
+ src="<?php p(image_path('core', 'loading-dark.gif'));?>">
+ <span id="messageText"></span>
+ <!-- the following div ensures that the spinner is always inside the #message div -->
+ <div style="clear: both;"></div>
+ </div>
+ <p class="grouptop">
+ <input type="password" id="oldPassword" name="oldPassword"
+ placeholder="<?php echo $l->t('Current password');?>"
+ autofocus autocomplete="off" autocapitalize="off" autocorrect="off" required/>
+ <label for="oldPassword" class="infield"><?php p($l->t('Current password')); ?></label>
+ </p>
+
+ <p class="groupbottom">
+ <input type="checkbox" id="personal-show" name="show" /><label for="personal-show"></label>
+ <label id="newPassword-label" for="newPassword" class="infield"><?php p($l->t('New password')); ?></label>
+ <input type="password" id="newPassword" name="newPassword"
+ placeholder="<?php echo $l->t('New password');?>"
+ data-typetoggle="#personal-show" autofocus autocomplete="off" autocapitalize="off" autocorrect="off" required/>
+ </p>
+
+ <input type="submit" id="submit" class="login primary icon-confirm-white" title="" value="<?php p($l->t('Renew password')); ?>"/>
+
+ <?php if (!empty($_['invalidpassword']) && !empty($_['canResetPassword'])) { ?>
+ <a id="lost-password" class="warning" href="<?php p($_['resetPasswordLink']); ?>">
+ <?php p($l->t('Wrong password. Reset it?')); ?>
+ </a>
+ <?php } else if (!empty($_['invalidpassword'])) { ?>
+ <p class="warning">
+ <?php p($l->t('Wrong password.')); ?>
+ </p>
+ <?php } ?>
+ <p id="cancel-container" class="info">
+ <a id="cancel" href="<?php p($_['cancelLink']); ?>">
+ <?php p($l->t('Cancel')); ?>
+ </a>
+ </p>
+ <input type="hidden" name="user" id="user" value="<?php p($_['user']) ?>">
+ <input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>">
+ </fieldset>
+</form>
diff --git a/apps/user_ldap/templates/settings.php b/apps/user_ldap/templates/settings.php
index 6942b2eb2b1..0d4ca804dd3 100644
--- a/apps/user_ldap/templates/settings.php
+++ b/apps/user_ldap/templates/settings.php
@@ -103,6 +103,7 @@ style('user_ldap', 'settings');
<p><label for="ldap_paging_size"><?php p($l->t('Paging chunksize'));?></label><input type="number" id="ldap_paging_size" name="ldap_paging_size" title="<?php p($l->t('Chunksize used for paged LDAP searches that may return bulky results like user or group enumeration. (Setting it 0 disables paged LDAP searches in those situations.)'));?>" data-default="<?php p($_['ldap_paging_size_default']); ?>" /></p>
<p><label for="ldap_turn_on_pwd_change"><?php p($l->t('Enable LDAP password changes per user'));?></label><span class="inlinetable"><span class="tablerow left"><input type="checkbox" id="ldap_turn_on_pwd_change" name="ldap_turn_on_pwd_change" value="1" data-default="<?php p($_['ldap_turn_on_pwd_change_default']); ?>" title="<?php p($l->t('Allow LDAP users to change their password and allow Super Administrators and Group Administrators to change the password of their LDAP users. Only works when access control policies are configured accordingly on the LDAP server. As passwords are sent in plaintext to the LDAP server, transport encryption must be used and password hashing should be configured on the LDAP server.'));?>" /><span class="tablecell"><?php p($l->t('(New password is sent as plain text to LDAP)'));?></span></span>
</span><br/></p>
+ <p><label for="ldap_default_ppolicy_dn"><?php p($l->t('Default password policy DN'));?></label><input type="text" id="ldap_default_ppolicy_dn" name="ldap_default_ppolicy_dn" title="<?php p($l->t('The DN of a default password policy that will be used for password expiry handling. Works only when LDAP password changes per user are enabled and is only supported by OpenLDAP. Leave empty to disable password expiry handling.'));?>" data-default="<?php p($_['ldap_default_ppolicy_dn_default']); ?>" /></p>
</div>
<h3><?php p($l->t('Special Attributes'));?></h3>
<div>
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();