fix a few minor code smells

This commit is contained in:
Jörn Friedrich Dreyer 2016-08-17 09:46:54 +02:00 committed by Lukas Reschke
parent 3647fbe7cd
commit 4d31caa6f8
No known key found for this signature in database
GPG Key ID: B9F6980CF6E759B1
12 changed files with 11 additions and 23 deletions

View File

@ -70,7 +70,7 @@ OCA = OCA || {};
controller.setView(view); controller.setView(view);
controller.setModel(model); controller.setModel(model);
controller.run(); controller.run();
} };
OCA.LDAP.Wizard.Wizard = Wizard; OCA.LDAP.Wizard.Wizard = Wizard;
})(); })();

View File

@ -869,7 +869,7 @@ class Access extends LDAPUtility implements IUserTools {
//browsing through prior pages to get the cookie for the new one //browsing through prior pages to get the cookie for the new one
if($skipHandling) { if($skipHandling) {
return; return false;
} }
// if count is bigger, then the server does not support // if count is bigger, then the server does not support
// paged search. Instead, he did a normal search. We set a // paged search. Instead, he did a normal search. We set a
@ -983,7 +983,6 @@ class Access extends LDAPUtility implements IUserTools {
$findings = array(); $findings = array();
$savedoffset = $offset; $savedoffset = $offset;
do { do {
$continue = false;
$search = $this->executeSearch($filter, $base, $attr, $limit, $offset); $search = $this->executeSearch($filter, $base, $attr, $limit, $offset);
if($search === false) { if($search === false) {
return array(); return array();

View File

@ -106,12 +106,13 @@ class Configuration {
/** /**
* @param string $name * @param string $name
* @return mixed|void * @return mixed|null
*/ */
public function __get($name) { public function __get($name) {
if(isset($this->config[$name])) { if(isset($this->config[$name])) {
return $this->config[$name]; return $this->config[$name];
} }
return null;
} }
/** /**
@ -182,7 +183,7 @@ class Configuration {
$applied[] = $inputKey; $applied[] = $inputKey;
} }
} }
return null;
} }
public function readConfiguration() { public function readConfiguration() {

View File

@ -558,6 +558,7 @@ class Connection extends LDAPUtility {
} }
return $bindStatus; return $bindStatus;
} }
return null;
} }
/** /**
@ -580,6 +581,7 @@ class Connection extends LDAPUtility {
} else { } else {
throw new \OC\ServerNotAvailableException('Could not set required LDAP Protocol version.'); throw new \OC\ServerNotAvailableException('Could not set required LDAP Protocol version.');
} }
return true;
} }
/** /**

View File

@ -44,7 +44,6 @@ class UpdateGroups extends \OC\BackgroundJob\TimedJob {
static private $groupsFromDB; static private $groupsFromDB;
static private $groupBE; static private $groupBE;
static private $connector;
public function __construct(){ public function __construct(){
$this->interval = self::getRefreshInterval(); $this->interval = self::getRefreshInterval();

View File

@ -259,6 +259,7 @@ class LDAP implements ILDAPWrapper {
} }
return $result; return $result;
} }
return null;
} }
/** /**

View File

@ -189,11 +189,6 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
$this->access->connection->ldapUserDisplayName . '=*', $this->access->connection->ldapUserDisplayName . '=*',
$this->access->getFilterPartForUserSearch($search) $this->access->getFilterPartForUserSearch($search)
)); ));
$attrs = array($this->access->connection->ldapUserDisplayName, 'dn');
$additionalAttribute = $this->access->connection->ldapUserDisplayName2;
if(!empty($additionalAttribute)) {
$attrs[] = $additionalAttribute;
}
\OCP\Util::writeLog('user_ldap', \OCP\Util::writeLog('user_ldap',
'getUsers: Options: search '.$search.' limit '.$limit.' offset '.$offset.' Filter: '.$filter, 'getUsers: Options: search '.$search.' limit '.$limit.' offset '.$offset.' Filter: '.$filter,

View File

@ -943,7 +943,6 @@ class Wizard extends LDAPUtility {
$cns = $this->configuration->ldapGroupFilterGroups; $cns = $this->configuration->ldapGroupFilterGroups;
if(is_array($cns) && count($cns) > 0) { if(is_array($cns) && count($cns) > 0) {
$filter .= '(|'; $filter .= '(|';
$base = $this->configuration->ldapBase[0];
foreach($cns as $cn) { foreach($cns as $cn) {
$filter .= '(cn=' . $cn . ')'; $filter .= '(cn=' . $cn . ')';
} }

View File

@ -201,6 +201,7 @@ class AccessTest extends \Test\TestCase {
return $case['interResult']; return $case['interResult'];
} }
} }
return null;
})); }));
foreach($cases as $case) { foreach($cases as $case) {

View File

@ -93,14 +93,6 @@ class ConfigurationTest extends \Test\TestCase {
public function testSetValue($key, $input, $expected) { public function testSetValue($key, $input, $expected) {
$configuration = new \OCA\User_LDAP\Configuration('t01', false); $configuration = new \OCA\User_LDAP\Configuration('t01', false);
$settingsInput = array(
'ldapBaseUsers' => array(
'cn=someUsers,dc=example,dc=org',
' ',
' cn=moreUsers,dc=example,dc=org '
)
);
$configuration->setConfiguration([$key => $input]); $configuration->setConfiguration([$key => $input]);
$this->assertSame($configuration->$key, $expected); $this->assertSame($configuration->$key, $expected);
} }

View File

@ -111,7 +111,7 @@ class IntegrationTestUserHome extends AbstractIntegrationTest {
*/ */
protected function case2() { protected function case2() {
\OC::$server->getConfig()->setAppValue('user_ldap', 'enforce_home_folder_naming_rule', true); \OC::$server->getConfig()->setAppValue('user_ldap', 'enforce_home_folder_naming_rule', true);
$userManager = \oc::$server->getUserManager(); $userManager = \OC::$server->getUserManager();
// clearing backends is critical, otherwise the userManager will have // clearing backends is critical, otherwise the userManager will have
// the user objects cached and the value from case1 returned // the user objects cached and the value from case1 returned
$userManager->clearBackends(); $userManager->clearBackends();
@ -144,7 +144,7 @@ class IntegrationTestUserHome extends AbstractIntegrationTest {
$this->connection->setConfiguration([ $this->connection->setConfiguration([
'homeFolderNamingRule' => 'attr:', 'homeFolderNamingRule' => 'attr:',
]); ]);
$userManager = \oc::$server->getUserManager(); $userManager = \OC::$server->getUserManager();
$userManager->clearBackends(); $userManager->clearBackends();
$userManager->registerBackend($this->backend); $userManager->registerBackend($this->backend);
$users = $userManager->search('', 5, 0); $users = $userManager->search('', 5, 0);

View File

@ -208,7 +208,6 @@ class ManagerTest extends \Test\TestCase {
list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) = list($access, $config, $filesys, $image, $log, $avaMgr, $dbc, $userMgr) =
$this->getTestInstances(); $this->getTestInstances();
$dn = 'cn=foo,dc=foobar,dc=bar';
$uid = 'gone'; $uid = 'gone';
$access->expects($this->never()) $access->expects($this->never())