Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/user_ldap/tests/User_LDAPTest.php8
-rw-r--r--core/Controller/LostController.php6
-rw-r--r--lib/composer/composer/ClassLoader.php18
-rw-r--r--lib/composer/composer/autoload_static.php12
-rw-r--r--lib/private/User/Manager.php10
-rw-r--r--tests/lib/Files/FilesystemTest.php33
-rw-r--r--tests/lib/User/ManagerTest.php28
-rw-r--r--tests/lib/Util/User/Dummy.php7
8 files changed, 57 insertions, 65 deletions
diff --git a/apps/user_ldap/tests/User_LDAPTest.php b/apps/user_ldap/tests/User_LDAPTest.php
index 606eff4e7a7..02a424b489c 100644
--- a/apps/user_ldap/tests/User_LDAPTest.php
+++ b/apps/user_ldap/tests/User_LDAPTest.php
@@ -1013,9 +1013,11 @@ class User_LDAPTest extends TestCase {
->will($this->returnValue('roland'));
$access->expects($this->any())
- ->method('stringResemblesDN')
- ->with($this->equalTo('dnOfRoland,dc=test'))
- ->will($this->returnValue(true));
+ ->method('stringResemblesDN')
+ ->will($this->returnCallback(function($string) {
+ // very simplified
+ return strpos($string, ',') !== false;
+ }));
$access->expects($this->any())
->method('setPassword')
diff --git a/core/Controller/LostController.php b/core/Controller/LostController.php
index 01c107e8326..52eec630750 100644
--- a/core/Controller/LostController.php
+++ b/core/Controller/LostController.php
@@ -206,6 +206,12 @@ class LostController extends Controller {
* @return array
*/
public function email($user){
+ \OCP\Util::emitHook(
+ '\OCA\Files_Sharing\API\Server2Server',
+ 'preLoginNameUsedAsUserName',
+ ['uid' => &$user]
+ );
+
// FIXME: use HTTP error codes
try {
$this->sendEmail($user);
diff --git a/lib/composer/composer/ClassLoader.php b/lib/composer/composer/ClassLoader.php
index 2c72175e772..bebe83706f8 100644
--- a/lib/composer/composer/ClassLoader.php
+++ b/lib/composer/composer/ClassLoader.php
@@ -43,7 +43,7 @@ namespace Composer\Autoload;
class ClassLoader
{
// PSR-4
- private $prefixLengthsPsr4 = array();
+ private $firstCharsPsr4 = array();
private $prefixDirsPsr4 = array();
private $fallbackDirsPsr4 = array();
@@ -170,11 +170,10 @@ class ClassLoader
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
- $length = strlen($prefix);
- if ('\\' !== $prefix[$length - 1]) {
+ if ('\\' !== substr($prefix, -1)) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
- $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
+ $this->firstCharsPsr4[$prefix[0]] = true;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
@@ -221,11 +220,10 @@ class ClassLoader
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
- $length = strlen($prefix);
- if ('\\' !== $prefix[$length - 1]) {
+ if ('\\' !== substr($prefix, -1)) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
- $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
+ $this->firstCharsPsr4[$prefix[0]] = true;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
@@ -373,15 +371,15 @@ class ClassLoader
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
- if (isset($this->prefixLengthsPsr4[$first])) {
+ if (isset($this->firstCharsPsr4[$first])) {
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath.'\\';
if (isset($this->prefixDirsPsr4[$search])) {
+ $pathEnd = substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
- $length = $this->prefixLengthsPsr4[$first][$search];
- if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $pathEnd)) {
return $file;
}
}
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index 86231a49c7b..225c2eb3f20 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -6,14 +6,8 @@ namespace Composer\Autoload;
class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
{
- public static $prefixLengthsPsr4 = array (
- 'O' =>
- array (
- 'OC\\Settings\\' => 12,
- 'OC\\Core\\' => 8,
- 'OC\\' => 3,
- 'OCP\\' => 4,
- ),
+ public static $firstCharsPsr4 = array (
+ 'O' => true,
);
public static $prefixDirsPsr4 = array (
@@ -848,7 +842,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
- $loader->prefixLengthsPsr4 = ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c::$prefixLengthsPsr4;
+ $loader->firstCharsPsr4 = ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c::$firstCharsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c::$classMap;
diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php
index 45400d621cb..db3f0200888 100644
--- a/lib/private/User/Manager.php
+++ b/lib/private/User/Manager.php
@@ -149,16 +149,6 @@ class Manager extends PublicEmitter implements IUserManager {
return $this->cachedUsers[$uid];
}
- if (method_exists($backend, 'loginName2UserName')) {
- $loginName = $backend->loginName2UserName($uid);
- if ($loginName !== false) {
- $uid = $loginName;
- }
- if (isset($this->cachedUsers[$uid])) {
- return $this->cachedUsers[$uid];
- }
- }
-
$user = new User($uid, $backend, $this, $this->config);
if ($cacheUser) {
$this->cachedUsers[$uid] = $user;
diff --git a/tests/lib/Files/FilesystemTest.php b/tests/lib/Files/FilesystemTest.php
index dd4785ecf09..210ce4edc69 100644
--- a/tests/lib/Files/FilesystemTest.php
+++ b/tests/lib/Files/FilesystemTest.php
@@ -368,39 +368,6 @@ class FilesystemTest extends \Test\TestCase {
$this->assertEquals(2, $thrown);
}
- public function testUserNameCasing() {
- $this->logout();
- $userId = $this->getUniqueID('user_');
-
- \OC_User::clearBackends();
- // needed for loginName2UserName mapping
- $userBackend = $this->createMock(\OC\User\Database::class);
- \OC::$server->getUserManager()->registerBackend($userBackend);
-
- $userBackend->expects($this->once())
- ->method('userExists')
- ->with(strtoupper($userId))
- ->will($this->returnValue(true));
- $userBackend->expects($this->once())
- ->method('loginName2UserName')
- ->with(strtoupper($userId))
- ->will($this->returnValue($userId));
-
- $view = new \OC\Files\View();
- $this->assertFalse($view->file_exists('/' . $userId));
-
- \OC\Files\Filesystem::initMountPoints(strtoupper($userId));
-
- list($storage1, $path1) = $view->resolvePath('/' . $userId);
- list($storage2, $path2) = $view->resolvePath('/' . strtoupper($userId));
-
- $this->assertTrue($storage1->instanceOfStorage('\OCP\Files\IHomeStorage'));
- $this->assertEquals('', $path1);
-
- // not mounted, still on the local root storage
- $this->assertEquals(strtoupper($userId), $path2);
- }
-
/**
* Tests that the home storage is used for the user's mount point
*/
diff --git a/tests/lib/User/ManagerTest.php b/tests/lib/User/ManagerTest.php
index 671b2ac57c1..72f078ef759 100644
--- a/tests/lib/User/ManagerTest.php
+++ b/tests/lib/User/ManagerTest.php
@@ -184,6 +184,8 @@ class ManagerTest extends TestCase {
->method('userExists')
->with($this->equalTo('foo'))
->will($this->returnValue(true));
+ $backend->expects($this->never())
+ ->method('loginName2UserName');
$manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend);
@@ -207,6 +209,24 @@ class ManagerTest extends TestCase {
$this->assertEquals(null, $manager->get('foo'));
}
+ public function testGetOneBackendDoNotTranslateLoginNames() {
+ /**
+ * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
+ */
+ $backend = $this->createMock(\Test\Util\User\Dummy::class);
+ $backend->expects($this->once())
+ ->method('userExists')
+ ->with($this->equalTo('bLeNdEr'))
+ ->will($this->returnValue(true));
+ $backend->expects($this->never())
+ ->method('loginName2UserName');
+
+ $manager = new \OC\User\Manager($this->config);
+ $manager->registerBackend($backend);
+
+ $this->assertEquals('bLeNdEr', $manager->get('bLeNdEr')->getUID());
+ }
+
public function testSearchOneBackend() {
/**
* @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
@@ -216,6 +236,8 @@ class ManagerTest extends TestCase {
->method('getUsers')
->with($this->equalTo('fo'))
->will($this->returnValue(array('foo', 'afoo')));
+ $backend->expects($this->never())
+ ->method('loginName2UserName');
$manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend);
@@ -235,6 +257,8 @@ class ManagerTest extends TestCase {
->method('getUsers')
->with($this->equalTo('fo'), $this->equalTo(3), $this->equalTo(1))
->will($this->returnValue(array('foo1', 'foo2')));
+ $backend1->expects($this->never())
+ ->method('loginName2UserName');
/**
* @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2
@@ -244,6 +268,8 @@ class ManagerTest extends TestCase {
->method('getUsers')
->with($this->equalTo('fo'), $this->equalTo(3), $this->equalTo(1))
->will($this->returnValue(array('foo3')));
+ $backend2->expects($this->never())
+ ->method('loginName2UserName');
$manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend1);
@@ -316,6 +342,8 @@ class ManagerTest extends TestCase {
->method('userExists')
->with($this->equalTo('foo'))
->will($this->returnValue(false));
+ $backend->expects($this->never())
+ ->method('loginName2UserName');
$manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend);
diff --git a/tests/lib/Util/User/Dummy.php b/tests/lib/Util/User/Dummy.php
index ea47f5d7d15..375a5f4b8e6 100644
--- a/tests/lib/Util/User/Dummy.php
+++ b/tests/lib/Util/User/Dummy.php
@@ -108,6 +108,13 @@ class Dummy extends Backend implements \OCP\IUserBackend {
}
}
+ public function loginName2UserName($loginName) {
+ if(isset($this->users[strtolower($loginName)])) {
+ return strtolower($loginName);
+ }
+ return false;
+ }
+
/**
* Get a list of all users
*