lower log level for quota manipulation cases

and simplify the forest of ifs a little bit

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2018-06-28 01:11:36 +02:00
parent ad2ef3a81f
commit cc51a00c93
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
3 changed files with 130 additions and 164 deletions

View File

@ -57,6 +57,9 @@ use OCP\ILogger;
* @property string ldapUuidGroupAttribute * @property string ldapUuidGroupAttribute
* @property string ldapExpertUUIDUserAttr * @property string ldapExpertUUIDUserAttr
* @property string ldapExpertUUIDGroupAttr * @property string ldapExpertUUIDGroupAttr
* @property string ldapQuotaAttribute
* @property string ldapQuotaDefault
* @property string ldapEmailAttribute
*/ */
class Connection extends LDAPUtility { class Connection extends LDAPUtility {
private $ldapConnectionRes = null; private $ldapConnectionRes = null;

View File

@ -37,8 +37,8 @@ use OCP\IAvatarManager;
use OCP\IConfig; use OCP\IConfig;
use OCP\ILogger; use OCP\ILogger;
use OCP\Image; use OCP\Image;
use OCP\IUser;
use OCP\IUserManager; use OCP\IUserManager;
use OCP\Util;
use OCP\Notification\IManager as INotificationManager; use OCP\Notification\IManager as INotificationManager;
/** /**
@ -499,44 +499,39 @@ class User {
return; return;
} }
$quota = false; $quotaAttribute = $this->connection->ldapQuotaAttribute;
if(is_null($valueFromLDAP)) { $defaultQuota = $this->connection->ldapQuotaDefault;
$quotaAttribute = $this->connection->ldapQuotaAttribute; if($quotaAttribute === '' && $defaultQuota === '') {
if ($quotaAttribute !== '') { return;
$aQuota = $this->access->readAttribute($this->dn, $quotaAttribute);
if($aQuota && (count($aQuota) > 0)) {
if ($this->verifyQuotaValue($aQuota[0])) {
$quota = $aQuota[0];
} else {
$this->log->log('not suitable LDAP quota found for user ' . $this->uid . ': [' . $aQuota[0] . ']', ILogger::WARN);
}
}
}
} else {
if ($this->verifyQuotaValue($valueFromLDAP)) {
$quota = $valueFromLDAP;
} else {
$this->log->log('not suitable LDAP quota found for user ' . $this->uid . ': [' . $valueFromLDAP . ']', ILogger::WARN);
}
} }
if ($quota === false) { $quota = false;
// quota not found using the LDAP attribute (or not parseable). Try the default quota if(is_null($valueFromLDAP) && $quotaAttribute !== '') {
$defaultQuota = $this->connection->ldapQuotaDefault; $aQuota = $this->access->readAttribute($this->dn, $quotaAttribute);
if ($this->verifyQuotaValue($defaultQuota)) { if($aQuota && (count($aQuota) > 0) && $this->verifyQuotaValue($aQuota[0])) {
$quota = $defaultQuota; $quota = $aQuota[0];
} else if(is_array($aQuota) && isset($aQuota[0])) {
$this->log->log('no suitable LDAP quota found for user ' . $this->uid . ': [' . $aQuota[0] . ']', ILogger::DEBUG);
} }
} else if ($this->verifyQuotaValue($valueFromLDAP)) {
$quota = $valueFromLDAP;
} else {
$this->log->log('no suitable LDAP quota found for user ' . $this->uid . ': [' . $valueFromLDAP . ']', ILogger::DEBUG);
}
if ($quota === false && $this->verifyQuotaValue($defaultQuota)) {
// quota not found using the LDAP attribute (or not parseable). Try the default quota
$quota = $defaultQuota;
} else if($quota === false) {
$this->log->log('no suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', ILogger::DEBUG);
return;
} }
$targetUser = $this->userManager->get($this->uid); $targetUser = $this->userManager->get($this->uid);
if ($targetUser) { if ($targetUser instanceof IUser) {
if($quota !== false) { $targetUser->setQuota($quota);
$targetUser->setQuota($quota);
} else {
$this->log->log('not suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', ILogger::WARN);
}
} else { } else {
$this->log->log('trying to set a quota for user ' . $this->uid . ' but the user is missing', ILogger::ERROR); $this->log->log('trying to set a quota for user ' . $this->uid . ' but the user is missing', ILogger::INFO);
} }
} }

View File

@ -32,14 +32,12 @@ namespace OCA\User_LDAP\Tests\User;
use OCA\User_LDAP\Access; use OCA\User_LDAP\Access;
use OCA\User_LDAP\Connection; use OCA\User_LDAP\Connection;
use OCA\User_LDAP\FilesystemHelper; use OCA\User_LDAP\FilesystemHelper;
use OCA\User_LDAP\ILDAPWrapper;
use OCA\User_LDAP\LogWrapper; use OCA\User_LDAP\LogWrapper;
use OCA\User_LDAP\User\IUserTools; use OCA\User_LDAP\User\IUserTools;
use OCA\User_LDAP\User\User; use OCA\User_LDAP\User\User;
use OCP\IAvatar; use OCP\IAvatar;
use OCP\IAvatarManager; use OCP\IAvatarManager;
use OCP\IConfig; use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Image; use OCP\Image;
use OCP\IUser; use OCP\IUser;
use OCP\IUserManager; use OCP\IUserManager;
@ -79,15 +77,14 @@ class UserTest extends \Test\TestCase {
$log = $this->createMock(LogWrapper::class); $log = $this->createMock(LogWrapper::class);
$avaMgr = $this->createMock(IAvatarManager::class); $avaMgr = $this->createMock(IAvatarManager::class);
$image = $this->createMock(Image::class); $image = $this->createMock(Image::class);
$dbc = $this->createMock(IDBConnection::class);
$userMgr = $this->createMock(IUserManager::class); $userMgr = $this->createMock(IUserManager::class);
$notiMgr = $this->createMock(INotificationManager::class); $notiMgr = $this->createMock(INotificationManager::class);
return array($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr); return array($access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr);
} }
public function testGetDNandUsername() { public function testGetDNandUsername() {
list($access, $config, $filesys, $image, $log, $avaMgr, $db, $userMgr, $notiMgr) = list($access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$uid = 'alice'; $uid = 'alice';
@ -101,7 +98,7 @@ class UserTest extends \Test\TestCase {
} }
public function testUpdateEmailProvided() { public function testUpdateEmailProvided() {
list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$this->connection->expects($this->once()) $this->connection->expects($this->once())
@ -135,7 +132,7 @@ class UserTest extends \Test\TestCase {
} }
public function testUpdateEmailNotProvided() { public function testUpdateEmailNotProvided() {
list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$this->connection->expects($this->once()) $this->connection->expects($this->once())
@ -161,7 +158,7 @@ class UserTest extends \Test\TestCase {
} }
public function testUpdateEmailNotConfigured() { public function testUpdateEmailNotConfigured() {
list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$this->connection->expects($this->once()) $this->connection->expects($this->once())
@ -185,15 +182,15 @@ class UserTest extends \Test\TestCase {
} }
public function testUpdateQuotaAllProvided() { public function testUpdateQuotaAllProvided() {
list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$this->connection->expects($this->at(0)) $this->connection->expects($this->exactly(2))
->method('__get') ->method('__get')
->with($this->equalTo('ldapQuotaAttribute')) ->willReturnMap([
->will($this->returnValue('myquota')); ['ldapQuotaAttribute', 'myquota'],
$this->connection->expects($this->exactly(1)) ['ldapQuotaDefault', '']
->method('__get'); ]);
$this->access->expects($this->once()) $this->access->expects($this->once())
->method('readAttribute') ->method('readAttribute')
@ -206,7 +203,7 @@ class UserTest extends \Test\TestCase {
->method('setQuota') ->method('setQuota')
->with('42 GB'); ->with('42 GB');
$userMgr->expects($this->once()) $userMgr->expects($this->atLeastOnce())
->method('get') ->method('get')
->with('alice') ->with('alice')
->will($this->returnValue($user)); ->will($this->returnValue($user));
@ -221,15 +218,15 @@ class UserTest extends \Test\TestCase {
} }
public function testUpdateQuotaToDefaultAllProvided() { public function testUpdateQuotaToDefaultAllProvided() {
list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$this->connection->expects($this->at(0)) $this->connection->expects($this->exactly(2))
->method('__get') ->method('__get')
->with($this->equalTo('ldapQuotaAttribute')) ->willReturnMap([
->will($this->returnValue('myquota')); ['ldapQuotaAttribute', 'myquota'],
$this->connection->expects($this->exactly(1)) ['ldapQuotaDefault', '']
->method('__get'); ]);
$this->access->expects($this->once()) $this->access->expects($this->once())
->method('readAttribute') ->method('readAttribute')
@ -257,15 +254,15 @@ class UserTest extends \Test\TestCase {
} }
public function testUpdateQuotaToNoneAllProvided() { public function testUpdateQuotaToNoneAllProvided() {
list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$this->connection->expects($this->at(0)) $this->connection->expects($this->exactly(2))
->method('__get') ->method('__get')
->with($this->equalTo('ldapQuotaAttribute')) ->willReturnMap([
->will($this->returnValue('myquota')); ['ldapQuotaAttribute', 'myquota'],
$this->connection->expects($this->exactly(1)) ['ldapQuotaDefault', '']
->method('__get'); ]);
$this->access->expects($this->once()) $this->access->expects($this->once())
->method('readAttribute') ->method('readAttribute')
@ -293,7 +290,7 @@ class UserTest extends \Test\TestCase {
} }
public function testUpdateQuotaDefaultProvided() { public function testUpdateQuotaDefaultProvided() {
list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$this->connection->expects($this->at(0)) $this->connection->expects($this->at(0))
@ -333,15 +330,15 @@ class UserTest extends \Test\TestCase {
} }
public function testUpdateQuotaIndividualProvided() { public function testUpdateQuotaIndividualProvided() {
list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$this->connection->expects($this->at(0)) $this->connection->expects($this->exactly(2))
->method('__get') ->method('__get')
->with($this->equalTo('ldapQuotaAttribute')) ->willReturnMap([
->will($this->returnValue('myquota')); ['ldapQuotaAttribute', 'myquota'],
$this->connection->expects($this->exactly(1)) ['ldapQuotaDefault', '']
->method('__get'); ]);
$this->access->expects($this->once()) $this->access->expects($this->once())
->method('readAttribute') ->method('readAttribute')
@ -369,19 +366,15 @@ class UserTest extends \Test\TestCase {
} }
public function testUpdateQuotaNoneProvided() { public function testUpdateQuotaNoneProvided() {
list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$this->connection->expects($this->at(0))
->method('__get')
->with($this->equalTo('ldapQuotaAttribute'))
->will($this->returnValue('myquota'));
$this->connection->expects($this->at(1))
->method('__get')
->with($this->equalTo('ldapQuotaDefault'))
->will($this->returnValue(''));
$this->connection->expects($this->exactly(2)) $this->connection->expects($this->exactly(2))
->method('__get'); ->method('__get')
->willReturnMap([
['ldapQuotaAttribute', 'myquota'],
['ldapQuotaDefault', '']
]);
$this->access->expects($this->once()) $this->access->expects($this->once())
->method('readAttribute') ->method('readAttribute')
@ -393,10 +386,9 @@ class UserTest extends \Test\TestCase {
$user->expects($this->never()) $user->expects($this->never())
->method('setQuota'); ->method('setQuota');
$userMgr->expects($this->once()) $userMgr->expects($this->never())
->method('get') ->method('get')
->with('alice') ->with('alice');
->will($this->returnValue($user));
$config->expects($this->never()) $config->expects($this->never())
->method('setUserValue'); ->method('setUserValue');
@ -411,28 +403,22 @@ class UserTest extends \Test\TestCase {
} }
public function testUpdateQuotaNoneConfigured() { public function testUpdateQuotaNoneConfigured() {
list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$this->connection->expects($this->at(0))
->method('__get')
->with($this->equalTo('ldapQuotaAttribute'))
->will($this->returnValue(''));
$this->connection->expects($this->at(1))
->method('__get')
->with($this->equalTo('ldapQuotaDefault'))
->will($this->returnValue(''));
$this->connection->expects($this->exactly(2)) $this->connection->expects($this->exactly(2))
->method('__get'); ->method('__get')
->willReturnMap([
['ldapQuotaAttribute', ''],
['ldapQuotaDefault', '']
]);
$user = $this->createMock('\OCP\IUser'); $user = $this->createMock('\OCP\IUser');
$user->expects($this->never()) $user->expects($this->never())
->method('setQuota'); ->method('setQuota');
$userMgr->expects($this->once()) $userMgr->expects($this->never())
->method('get') ->method('get');
->with('alice')
->will($this->returnValue($user));
$this->access->expects($this->never()) $this->access->expects($this->never())
->method('readAttribute'); ->method('readAttribute');
@ -450,14 +436,17 @@ class UserTest extends \Test\TestCase {
} }
public function testUpdateQuotaFromValue() { public function testUpdateQuotaFromValue() {
list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$readQuota = '19 GB'; $readQuota = '19 GB';
$this->connection->expects($this->never()) $this->connection->expects($this->exactly(2))
->method('__get') ->method('__get')
->with($this->equalTo('ldapQuotaDefault')); ->willReturnMap([
['ldapQuotaAttribute', 'myquota'],
['ldapQuotaDefault', '']
]);
$this->access->expects($this->never()) $this->access->expects($this->never())
->method('readAttribute'); ->method('readAttribute');
@ -485,19 +474,15 @@ class UserTest extends \Test\TestCase {
* Unparseable quota will fallback to use the LDAP default * Unparseable quota will fallback to use the LDAP default
*/ */
public function testUpdateWrongQuotaAllProvided() { public function testUpdateWrongQuotaAllProvided() {
list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$this->connection->expects($this->at(0))
->method('__get')
->with($this->equalTo('ldapQuotaAttribute'))
->will($this->returnValue('myquota'));
$this->connection->expects($this->at(1))
->method('__get')
->with($this->equalTo('ldapQuotaDefault'))
->will($this->returnValue('23 GB'));
$this->connection->expects($this->exactly(2)) $this->connection->expects($this->exactly(2))
->method('__get'); ->method('__get')
->willReturnMap([
['ldapQuotaAttribute', 'myquota'],
['ldapQuotaDefault', '23 GB']
]);
$this->access->expects($this->once()) $this->access->expects($this->once())
->method('readAttribute') ->method('readAttribute')
@ -528,19 +513,15 @@ class UserTest extends \Test\TestCase {
* No user quota and wrong default will set 'default' as quota * No user quota and wrong default will set 'default' as quota
*/ */
public function testUpdateWrongDefaultQuotaProvided() { public function testUpdateWrongDefaultQuotaProvided() {
list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$this->connection->expects($this->at(0))
->method('__get')
->with($this->equalTo('ldapQuotaAttribute'))
->will($this->returnValue('myquota'));
$this->connection->expects($this->at(1))
->method('__get')
->with($this->equalTo('ldapQuotaDefault'))
->will($this->returnValue('23 GBwowowo'));
$this->connection->expects($this->exactly(2)) $this->connection->expects($this->exactly(2))
->method('__get'); ->method('__get')
->willReturnMap([
['ldapQuotaAttribute', 'myquota'],
['ldapQuotaDefault', '23 GBwowowo']
]);
$this->access->expects($this->once()) $this->access->expects($this->once())
->method('readAttribute') ->method('readAttribute')
@ -552,10 +533,8 @@ class UserTest extends \Test\TestCase {
$user->expects($this->never()) $user->expects($this->never())
->method('setQuota'); ->method('setQuota');
$userMgr->expects($this->once()) $userMgr->expects($this->never())
->method('get') ->method('get');
->with('alice')
->will($this->returnValue($user));
$uid = 'alice'; $uid = 'alice';
$dn = 'uid=alice,dc=foo,dc=bar'; $dn = 'uid=alice,dc=foo,dc=bar';
@ -570,19 +549,15 @@ class UserTest extends \Test\TestCase {
* Wrong user quota and wrong default will set 'default' as quota * Wrong user quota and wrong default will set 'default' as quota
*/ */
public function testUpdateWrongQuotaAndDefaultAllProvided() { public function testUpdateWrongQuotaAndDefaultAllProvided() {
list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$this->connection->expects($this->at(0))
->method('__get')
->with($this->equalTo('ldapQuotaAttribute'))
->will($this->returnValue('myquota'));
$this->connection->expects($this->at(1))
->method('__get')
->with($this->equalTo('ldapQuotaDefault'))
->will($this->returnValue('23 GBwowowo'));
$this->connection->expects($this->exactly(2)) $this->connection->expects($this->exactly(2))
->method('__get'); ->method('__get')
->willReturnMap([
['ldapQuotaAttribute', 'myquota'],
['ldapQuotaDefault', '23 GBwowowo']
]);
$this->access->expects($this->once()) $this->access->expects($this->once())
->method('readAttribute') ->method('readAttribute')
@ -594,10 +569,8 @@ class UserTest extends \Test\TestCase {
$user->expects($this->never()) $user->expects($this->never())
->method('setQuota'); ->method('setQuota');
$userMgr->expects($this->once()) $userMgr->expects($this->never())
->method('get') ->method('get');
->with('alice')
->will($this->returnValue($user));
$uid = 'alice'; $uid = 'alice';
$dn = 'uid=alice,dc=foo,dc=bar'; $dn = 'uid=alice,dc=foo,dc=bar';
@ -612,19 +585,15 @@ class UserTest extends \Test\TestCase {
* No quota attribute set and wrong default will set 'default' as quota * No quota attribute set and wrong default will set 'default' as quota
*/ */
public function testUpdateWrongDefaultQuotaNotProvided() { public function testUpdateWrongDefaultQuotaNotProvided() {
list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$this->connection->expects($this->at(0))
->method('__get')
->with($this->equalTo('ldapQuotaAttribute'))
->will($this->returnValue(''));
$this->connection->expects($this->at(1))
->method('__get')
->with($this->equalTo('ldapQuotaDefault'))
->will($this->returnValue('23 GBwowowo'));
$this->connection->expects($this->exactly(2)) $this->connection->expects($this->exactly(2))
->method('__get'); ->method('__get')
->willReturnMap([
['ldapQuotaAttribute', ''],
['ldapQuotaDefault', '23 GBwowowo']
]);
$this->access->expects($this->never()) $this->access->expects($this->never())
->method('readAttribute'); ->method('readAttribute');
@ -633,10 +602,8 @@ class UserTest extends \Test\TestCase {
$user->expects($this->never()) $user->expects($this->never())
->method('setQuota'); ->method('setQuota');
$userMgr->expects($this->once()) $userMgr->expects($this->never())
->method('get') ->method('get');
->with('alice')
->will($this->returnValue($user));
$uid = 'alice'; $uid = 'alice';
$dn = 'uid=alice,dc=foo,dc=bar'; $dn = 'uid=alice,dc=foo,dc=bar';
@ -649,7 +616,7 @@ class UserTest extends \Test\TestCase {
//the testUpdateAvatar series also implicitely tests getAvatarImage //the testUpdateAvatar series also implicitely tests getAvatarImage
public function testUpdateAvatarJpegPhotoProvided() { public function testUpdateAvatarJpegPhotoProvided() {
list(, $config, $filesys, $image, $log, $avaMgr, , $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$this->access->expects($this->once()) $this->access->expects($this->once())
@ -695,7 +662,7 @@ class UserTest extends \Test\TestCase {
} }
public function testUpdateAvatarThumbnailPhotoProvided() { public function testUpdateAvatarThumbnailPhotoProvided() {
list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$this->access->expects($this->any()) $this->access->expects($this->any())
@ -750,7 +717,7 @@ class UserTest extends \Test\TestCase {
} }
public function testUpdateAvatarNotProvided() { public function testUpdateAvatarNotProvided() {
list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$this->access->expects($this->any()) $this->access->expects($this->any())
@ -793,7 +760,7 @@ class UserTest extends \Test\TestCase {
} }
public function testUpdateBeforeFirstLogin() { public function testUpdateBeforeFirstLogin() {
list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$config->expects($this->at(0)) $config->expects($this->at(0))
@ -823,7 +790,7 @@ class UserTest extends \Test\TestCase {
} }
public function testUpdateAfterFirstLogin() { public function testUpdateAfterFirstLogin() {
list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$config->expects($this->at(0)) $config->expects($this->at(0))
@ -857,7 +824,7 @@ class UserTest extends \Test\TestCase {
} }
public function testUpdateNoRefresh() { public function testUpdateNoRefresh() {
list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$config->expects($this->at(0)) $config->expects($this->at(0))
@ -894,7 +861,7 @@ class UserTest extends \Test\TestCase {
} }
public function testMarkLogin() { public function testMarkLogin() {
list(, $config, $filesys, $image, $log, $avaMgr, $db, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$config->expects($this->once()) $config->expects($this->once())
@ -915,7 +882,7 @@ class UserTest extends \Test\TestCase {
} }
public function testGetAvatarImageProvided() { public function testGetAvatarImageProvided() {
list(, $config, $filesys, $image, $log, $avaMgr, $db, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$this->access->expects($this->once()) $this->access->expects($this->once())
@ -938,7 +905,7 @@ class UserTest extends \Test\TestCase {
} }
public function testProcessAttributes() { public function testProcessAttributes() {
list(, $config, $filesys, $image, $log, $avaMgr, , $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$uid = 'alice'; $uid = 'alice';
@ -954,7 +921,8 @@ class UserTest extends \Test\TestCase {
'updateAvatar' 'updateAvatar'
); );
$userMock = $this->getMockBuilder('OCA\User_LDAP\User\User') /** @var User|\PHPUnit_Framework_MockObject_MockObject $userMock */
$userMock = $this->getMockBuilder(User::class)
->setConstructorArgs(array($uid, $dn, $this->access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr)) ->setConstructorArgs(array($uid, $dn, $this->access, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr))
->setMethods($requiredMethods) ->setMethods($requiredMethods)
->getMock(); ->getMock();
@ -1002,7 +970,7 @@ class UserTest extends \Test\TestCase {
* @dataProvider emptyHomeFolderAttributeValueProvider * @dataProvider emptyHomeFolderAttributeValueProvider
*/ */
public function testGetHomePathNotConfigured($attributeValue) { public function testGetHomePathNotConfigured($attributeValue) {
list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$this->connection->expects($this->any()) $this->connection->expects($this->any())
@ -1027,7 +995,7 @@ class UserTest extends \Test\TestCase {
} }
public function testGetHomePathConfiguredNotAvailableAllowed() { public function testGetHomePathConfiguredNotAvailableAllowed() {
list(, $config, $filesys, $image, $log, $avaMgr, , $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$this->connection->expects($this->any()) $this->connection->expects($this->any())
@ -1059,7 +1027,7 @@ class UserTest extends \Test\TestCase {
* @expectedException \Exception * @expectedException \Exception
*/ */
public function testGetHomePathConfiguredNotAvailableNotAllowed() { public function testGetHomePathConfiguredNotAvailableNotAllowed() {
list(, $config, $filesys, $image, $log, $avaMgr, , $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$this->connection->expects($this->any()) $this->connection->expects($this->any())
@ -1097,7 +1065,7 @@ class UserTest extends \Test\TestCase {
* @dataProvider displayNameProvider * @dataProvider displayNameProvider
*/ */
public function testComposeAndStoreDisplayName($part1, $part2, $expected) { public function testComposeAndStoreDisplayName($part1, $part2, $expected) {
list(, $config, $filesys, $image, $log, $avaMgr, , $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$config->expects($this->once()) $config->expects($this->once())
@ -1111,7 +1079,7 @@ class UserTest extends \Test\TestCase {
} }
public function testHandlePasswordExpiryWarningDefaultPolicy() { public function testHandlePasswordExpiryWarningDefaultPolicy() {
list(, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$uid = 'alice'; $uid = 'alice';
@ -1181,7 +1149,7 @@ class UserTest extends \Test\TestCase {
} }
public function testHandlePasswordExpiryWarningCustomPolicy() { public function testHandlePasswordExpiryWarningCustomPolicy() {
list(, $config, $filesys, $image, $log, $avaMgr, , $userMgr, $notiMgr) = list(, $config, $filesys, $image, $log, $avaMgr, $userMgr, $notiMgr) =
$this->getTestInstances(); $this->getTestInstances();
$uid = 'alice'; $uid = 'alice';